Skip to content

Commit

Permalink
Merge pull request #19 from saitamau-maximum/feat/header
Browse files Browse the repository at this point in the history
feat: Header
  • Loading branch information
sor4chi authored Sep 23, 2023
2 parents 2db2ad3 + 10fa40d commit 45659f0
Show file tree
Hide file tree
Showing 11 changed files with 598 additions and 6 deletions.
2 changes: 2 additions & 0 deletions packages/components/src/__stories__/containter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export const Container = ({ children, theme }: HStackProps) => (
if (theme === 'light') return 'var(--color-gray-900)';
if (theme === 'dark') return 'var(--color-gray-50)';
})(),
overflow: 'hidden',
position: 'relative',
}}
>
{children}
Expand Down
21 changes: 18 additions & 3 deletions packages/components/src/__stories__/h-stack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,28 @@ import { ReactNode } from 'react';
interface HStackProps {
children: ReactNode;
theme?: 'light' | 'dark';
align?: 'flex-start' | 'center' | 'flex-end' | 'stretch';
noPadding?: boolean;
width?: number | string;
height?: number | string;
}

export const HStack = ({ children, theme }: HStackProps) => (
export const HStack = ({
children,
theme,
align = 'flex-start',
noPadding,
width,
height,
}: HStackProps) => (
<div
className={theme}
style={{
display: 'flex',
flexDirection: 'row',
gap: 16,
padding: 16,
alignItems: 'flex-start',
padding: noPadding ? 0 : 16,
alignItems: align,
backgroundColor: (() => {
if (theme === 'light') return 'var(--color-gray-100)';
if (theme === 'dark') return 'var(--color-gray-800)';
Expand All @@ -22,6 +33,10 @@ export const HStack = ({ children, theme }: HStackProps) => (
if (theme === 'light') return 'var(--color-gray-900)';
if (theme === 'dark') return 'var(--color-gray-50)';
})(),
width,
height,
overflow: 'hidden',
position: 'relative',
}}
>
{children}
Expand Down
21 changes: 18 additions & 3 deletions packages/components/src/__stories__/v-stack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,28 @@ import { ReactNode } from 'react';
interface VStackProps {
children: ReactNode;
theme?: 'light' | 'dark';
align?: 'flex-start' | 'center' | 'flex-end' | 'stretch';
noPadding?: boolean;
width?: number | string;
height?: number | string;
}

export const VStack = ({ children, theme }: VStackProps) => (
export const VStack = ({
children,
theme,
align = 'flex-start',
noPadding,
width,
height,
}: VStackProps) => (
<div
className={theme}
style={{
display: 'flex',
flexDirection: 'column',
gap: 16,
padding: 16,
alignItems: 'flex-start',
padding: noPadding ? 0 : 16,
alignItems: align,
backgroundColor: (() => {
if (theme === 'light') return 'var(--color-gray-100)';
if (theme === 'dark') return 'var(--color-gray-800)';
Expand All @@ -22,6 +33,10 @@ export const VStack = ({ children, theme }: VStackProps) => (
if (theme === 'light') return 'var(--color-gray-900)';
if (theme === 'dark') return 'var(--color-gray-50)';
})(),
width,
height,
overflow: 'hidden',
position: 'relative',
}}
>
{children}
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/foundation/_z-index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$z-index-header: 1000;
241 changes: 241 additions & 0 deletions packages/components/src/header/Header.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
:root {
--header-inner-vertical-padding: 1rem;
--header-side-padding: 2rem;
--header-logo-height: 4rem;
--header-action-area-gap: 1rem;
}

.sm {
--header-inner-vertical-padding: 0;
--header-side-padding: 1rem;
--header-logo-height: 3rem;
--header-action-area-gap: 0.5rem;
}

.header {
width: 100%;
padding: 0 var(--header-side-padding);
box-sizing: border-box;
transition: border 0.2s ease-in-out;
z-index: $z-index-header;

:global(.light) & {
background: $color-gray-100;
}

:global(.dark) & {
background: $color-gray-800;
}
}

.open {
:global(.light) & {
box-shadow: $shadow-light;
}

:global(.dark) & {
box-shadow: $shadow-dark;
}

border-radius: 0 0 1.5rem 1.5rem;
}

.headerSticky {
position: sticky;
top: 0;
left: 0;
}

.headerInner {
width: 100%;
max-width: 70rem;
margin: 0 auto;
padding: var(--header-inner-vertical-padding) 0;
display: flex;
align-items: center;
justify-content: space-between;
}

:global(.light) .headerInner {
border-bottom: 1px solid $color-gray-200;
}

:global(.dark) .headerInner {
border-bottom: 1px solid $color-gray-700;
}

.logoLink {
line-height: 0;

&:focus-visible {
border-radius: 0.5rem;
}
}

.logo {
fill: $color-accent-gradient;
height: var(--header-logo-height);
aspect-ratio: 172 / 64;
}

.nav {
display: flex;
align-items: center;
justify-content: space-between;
gap: 2rem;
}

.navList {
display: flex;
align-items: center;
justify-content: space-between;
list-style: none;
margin: 0;
padding: 0;
gap: 0.5rem;
}

$nav-text-padding-x: 1rem;

.navText {
font-size: 1rem;
font-weight: 700;
padding: 0.5rem $nav-text-padding-x;

transition: color 0.2s ease-in-out;

position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
}

:global(.light) .navText {
color: $color-gray-700;
}

:global(.dark) .navText {
color: $color-gray-300;
}

.currentNavText::after {
content: '';
position: absolute;
inset: auto 0 -0.25rem 0;
margin: auto;
width: 80%;
height: 0.125rem;
border-radius: 9999px;
}

:global(.light) .currentNavText::after {
background: $color-green-600;
}

:global(.dark) .currentNavText::after {
background: $color-green-500;
}

.notCurrentNavText {
cursor: pointer;
text-decoration: none;
}

.navItem {
a:focus-visible {
border-radius: 0.5rem;
}

:global(.light) & a:hover {
color: $color-green-600;
}

:global(.dark) & a:hover {
color: $color-green-500;
}
}

.actionArea {
display: flex;
align-items: center;
justify-content: space-between;
gap: var(--header-action-area-gap);
}

.dropdown {
display: flex;
flex-direction: column;
align-items: center;
padding: 2rem;
padding-bottom: 1.5rem;
gap: 1.5rem;
}

.dropdownLinks {
display: flex;
justify-content: space-evenly;
align-items: center;
width: 100%;
}

.dropdownLinksItem {
margin: 0;
list-style: none;
padding: 0;
display: flex;
flex-direction: column;
gap: 1.5rem;
}

.dropdownLinkText {
font-weight: 500;
text-decoration: none;
transition: color 0.2s ease-in-out;
display: inline-flex;
align-items: center;
padding: 0.25rem 0.5rem;

:global(.light) & {
color: $color-gray-700;

&:hover {
color: $color-green-500;
}
}

:global(.dark) & {
color: $color-gray-100;

&:hover {
color: $color-green-400;
}
}
}

.dropdownDivider {
width: 100%;
height: 1px;

:global(.light) & {
background: $color-gray-200;
}

:global(.dark) & {
background: $color-gray-700;
}
}

.dropdownActions {
display: flex;
flex-direction: column;
gap: 1rem;
}

.dropdownBackdrop {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
z-index: $z-index-header - 1;
background: rgba(0, 0, 0, 0.5);
}
Loading

0 comments on commit 45659f0

Please sign in to comment.