Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use styled components #30

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 142 additions & 18 deletions app/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,142 @@
"use client"

import { links } from "../siteConfig"
import styled, { css } from "styled-components"

const LogoImage = styled.img`
border-radius: 0.25rem;
width: 3rem;
`
Comment on lines +6 to +9
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put all local components below the exported. Priority should be:

  1. Metadata stuff (interfaces/types, config, or constants)
  2. Public stuff (exports)
  3. Private stuff (local stuff like components or utilities).


const Anchor = styled.a<{
ghost?: boolean
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ghost isn't used. Why is it added in this commit?

}>`
display: inline-flex;
justify-content: center;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixup the previous commit for the typo. Should we consider using JS instead of the string template in order for type checking to help us with typos?

align-items: center;

font-size: 0.875rem;
text-align: center;
border-radius: 0.5rem;
transition: background 200ms ease-in-out;

color: #a7adba;

height: 3rem;
padding: 0 1rem;
font-weight: 600;
line-height: 1em;

${(props) => {
const backgroundColor = props.ghost ? "transparent" : "#1a1e23"

return css`
background: ${backgroundColor};
border: 1px solid ${backgroundColor};
`
}}

&:hover {
${(props) => {
if (props.ghost)
return css`
background: color-mix(in srgb, white 5%, transparent 100%);
border: 1px solid transparent;
`
else
return css`
background: #15181d;
border: 1px solid #15181d;
`
}}
}
Comment on lines +30 to +52
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all becomes simpler with no border.

`

const Button = styled.a<{
ghost?: boolean
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If ghost is used everywhere or nowhere, then why is it even a parameter?

}>`
display: inline-flex;
justify-content: center;
align-items: center;

font-size: 0.875rem;
text-align: center;
border-radius: 0.5rem;
transition: background 200ms ease-in-out;

color: #a7adba;

height: 3rem;
padding: 0 1rem;
font-weight: 600;
line-height: 1em;

${(props) => {
const backgroundColor = props.ghost ? "transparent" : "#1a1e23"

return css`
background: ${backgroundColor};
border: 1px solid ${backgroundColor};
`
}}

&:hover {
${(props) => {
if (props.ghost)
return css`
background: color-mix(in srgb, white 5%, transparent 100%);
border: 1px solid transparent;
`
else
return css`
background: #15181d;
border: 1px solid #15181d;
`
}}
}
`

const ImageAnchor = styled(Anchor)`
padding: 0;
`

const NavLink = styled.a`
display: inline-flex;
justify-content: center;
align-items: center;

font-size: 0.875rem;
text-align: center;
border-radius: 0.5rem;
transition: background 200ms ease-in-out;

color: #a7adba;

padding: 0.5rem 1rem;
line-height: 1.4em;

background: transparent;
border: 1px solid transparent;

&:hover {
background: color-mix(in srgb, white 5%, transparent 100%);
border: 1px solid transparent;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the border is not using the same color function for its tweening? But perhaps the border should be removed anyway, but if not then this question is relevant.

}
`

const DropdownButton = styled(Button)`
@media (min-width: 1024px) {
display: none;
}
`

const Header = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like export const instead of export default. It's clearer and allows you to export types an other things that a module may want to export.

return (
<header>
<nav className="navbar bg-base-100">
<div className="navbar-start">
<div className="dropdown">
<div tabIndex={0} role="button" className="btn btn-ghost lg:hidden">
<DropdownButton tabIndex={0} ghost>
<svg
xmlns="http://www.w3.org/2000/svg"
className="w-5 h-5"
Expand All @@ -21,27 +151,25 @@ const Header = () => {
d="M4 6h16M4 12h8m-8 6h16"
/>
</svg>
</div>
</DropdownButton>
<ul
tabIndex={0}
className="menu menu-lg dropdown-content bg-base-100 rounded-box z-[1] mt-3 w-52 p-2 shadow"
>
<NavLinks />
</ul>
</div>
<a className="inline p-0 btn btn-ghost" href="/">
<img src="/images/logo.jpeg" className="w-12 rounded" />
</a>
<ImageAnchor ghost href="/">
<LogoImage src="/images/logo.jpeg" />
</ImageAnchor>
</div>
<div className="hidden navbar-center lg:flex">
<ul className="px-1 menu menu-horizontal">
<NavLinks />
</ul>
</div>
<div className="navbar-end">
<a className="btn" href={links.discord}>
Join Us on Discord
</a>
<Anchor href={links.discord}>Join Us on Discord</Anchor>
</div>
</nav>
</header>
Expand All @@ -52,24 +180,20 @@ const NavLinks = () => {
return (
<>
<li>
<a href="/">Home</a>
<NavLink href="/">Home</NavLink>
</li>
<li>
<a href="/about">About</a>
<NavLink href="/about">About</NavLink>
</li>
<li>
<a target="_blank" href={links.lumaUrl}>
<NavLink target="_blank" href={links.lumaUrl}>
Event Calendar
</a>
</NavLink>
</li>
{/* Hide Events until the page design is ready and finalized */}
{/* <li>
<a href="/events">Events</a>
</li> */}
<li>
<a target="_blank" href={links.talkSubmissionUrl}>
<NavLink target="_blank" href={links.talkSubmissionUrl}>
Give a Talk!
</a>
</NavLink>
</li>
</>
)
Expand Down
Loading