|
|
@@ -1,7 +1,8 @@ |
|
|
|
import * as React from 'react' |
|
|
|
import styled from 'styled-components' |
|
|
|
import styled, { createGlobalStyle } from 'styled-components' |
|
|
|
import SecondaryNavItem from '../SecondaryNavItem/SecondaryNavItem' |
|
|
|
import PrimaryNavItem from '../PrimaryNavItem/PrimaryNavItem' |
|
|
|
import Link from 'next/link' |
|
|
|
|
|
|
|
const Base = styled('aside')({ |
|
|
|
width: 360, |
|
|
@@ -59,9 +60,37 @@ const PrimaryNavItemGroup = styled('div')({ |
|
|
|
}) |
|
|
|
|
|
|
|
const SecondaryNavItems = styled('nav')({ |
|
|
|
width: '100%', |
|
|
|
height: '100%', |
|
|
|
position: 'fixed', |
|
|
|
top: 0, |
|
|
|
left: 0, |
|
|
|
paddingBottom: '4rem', |
|
|
|
boxSizing: 'border-box', |
|
|
|
pointerEvents: 'none', |
|
|
|
'@media (min-width: 1080px)': { |
|
|
|
position: 'relative', |
|
|
|
top: 'auto', |
|
|
|
left: 'auto', |
|
|
|
flex: 'auto', |
|
|
|
width: 'auto', |
|
|
|
paddingBottom: 0, |
|
|
|
pointerEvents: 'initial', |
|
|
|
}, |
|
|
|
}) |
|
|
|
|
|
|
|
const SecondaryNavItemsFg = styled('div')({ |
|
|
|
height: '100%', |
|
|
|
position: 'relative', |
|
|
|
backgroundColor: 'var(--color-bg)', |
|
|
|
width: 360, |
|
|
|
position: 'absolute', |
|
|
|
top: 0, |
|
|
|
left: -360, |
|
|
|
paddingBottom: '4rem', |
|
|
|
boxSizing: 'border-box', |
|
|
|
transitionProperty: 'left', |
|
|
|
transitionDuration: '350ms', |
|
|
|
transitionTimingFunction: 'ease-out', |
|
|
|
'::before': { |
|
|
|
content: "''", |
|
|
|
display: 'block', |
|
|
@@ -73,27 +102,34 @@ const SecondaryNavItems = styled('nav')({ |
|
|
|
backgroundColor: 'black', |
|
|
|
opacity: 0.03125, |
|
|
|
}, |
|
|
|
'@media (min-width: 1080px)': { |
|
|
|
flex: 'auto', |
|
|
|
}, |
|
|
|
}) |
|
|
|
|
|
|
|
const VisibleSecondaryNavItems = styled(SecondaryNavItems)({ |
|
|
|
position: 'fixed', |
|
|
|
top: 0, |
|
|
|
left: 0, |
|
|
|
width: '100%', |
|
|
|
paddingBottom: '4rem', |
|
|
|
boxSizing: 'border-box', |
|
|
|
'@media (min-width: 1080px)': { |
|
|
|
position: 'relative', |
|
|
|
top: 'auto', |
|
|
|
left: 'auto', |
|
|
|
flex: 'auto', |
|
|
|
width: 'auto', |
|
|
|
paddingBottom: 0, |
|
|
|
}, |
|
|
|
}) |
|
|
|
|
|
|
|
const SecondaryNavItemsBg = styled('a')({ |
|
|
|
opacity: 0, |
|
|
|
transitionProperty: 'opacity', |
|
|
|
transitionDuration: '350ms', |
|
|
|
transitionTimingFunction: 'ease-out', |
|
|
|
'::before': { |
|
|
|
content: "''", |
|
|
|
display: 'block', |
|
|
|
top: 0, |
|
|
|
left: 0, |
|
|
|
width: '100%', |
|
|
|
height: '100%', |
|
|
|
position: 'absolute', |
|
|
|
backgroundColor: 'black', |
|
|
|
opacity: 0.75, |
|
|
|
}, |
|
|
|
}) |
|
|
|
|
|
|
|
const SecondaryNavItemsOverflow = styled('div')({ |
|
|
|
overflow: 'auto', |
|
|
|
width: '100%', |
|
|
@@ -116,15 +152,40 @@ const NavbarContainer = styled('div')({ |
|
|
|
maxWidth: 360, |
|
|
|
}) |
|
|
|
|
|
|
|
const SecondaryVisibleDummy = styled('div')({ |
|
|
|
display: 'none', |
|
|
|
}) |
|
|
|
|
|
|
|
const Visible = createGlobalStyle({ |
|
|
|
[`div + ${SecondaryNavItems}`]: { |
|
|
|
pointerEvents: 'initial', |
|
|
|
}, |
|
|
|
[`div + ${SecondaryNavItems} ${SecondaryNavItemsFg}`]: { |
|
|
|
left: 0, |
|
|
|
}, |
|
|
|
[`div + ${SecondaryNavItems} ${SecondaryNavItemsBg}`]: { |
|
|
|
opacity: 1, |
|
|
|
}, |
|
|
|
'@media (min-width: 1080px)': { |
|
|
|
[`div + ${SecondaryNavItems} ${SecondaryNavItemsFg}`]: { |
|
|
|
left: 'auto', |
|
|
|
}, |
|
|
|
[`div + ${SecondaryNavItems} ${SecondaryNavItemsBg}`]: { |
|
|
|
opacity: 0, |
|
|
|
}, |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
const Navbar = ({ |
|
|
|
closeHref, |
|
|
|
secondaryVisible, |
|
|
|
primaryItemsStart = [], |
|
|
|
primaryItemsEnd = [], |
|
|
|
secondaryItemsHeader = [], |
|
|
|
secondaryItems = [], |
|
|
|
}) => { |
|
|
|
const SecondaryNavItemsComponent = secondaryVisible ? VisibleSecondaryNavItems : SecondaryNavItems |
|
|
|
return ( |
|
|
|
}) => ( |
|
|
|
<React.Fragment> |
|
|
|
<Visible /> |
|
|
|
<Base> |
|
|
|
<NavbarContainer> |
|
|
|
<NavbarItems> |
|
|
@@ -165,42 +226,57 @@ const Navbar = ({ |
|
|
|
} |
|
|
|
</PrimaryNavItemsContainer> |
|
|
|
</PrimaryNavItems> |
|
|
|
<SecondaryNavItemsComponent> |
|
|
|
<SecondaryNavItemsOverflow> |
|
|
|
{ |
|
|
|
secondaryItemsHeader.map(i => ( |
|
|
|
<SecondaryNavItem |
|
|
|
key={i.id} |
|
|
|
active={i.active} |
|
|
|
href={i.href} |
|
|
|
replace={i.replace} |
|
|
|
iconName={i.iconName} |
|
|
|
title={i.title} |
|
|
|
subtitle={i.subtitle} |
|
|
|
actions={i.actions} |
|
|
|
/> |
|
|
|
)) |
|
|
|
} |
|
|
|
{ |
|
|
|
secondaryItems.map(i => ( |
|
|
|
<SecondaryNavItem |
|
|
|
key={i.id} |
|
|
|
active={i.active} |
|
|
|
href={i.href} |
|
|
|
replace={i.replace} |
|
|
|
iconName={i.iconName} |
|
|
|
title={i.title} |
|
|
|
subtitle={i.subtitle} |
|
|
|
actions={i.actions} |
|
|
|
/> |
|
|
|
)) |
|
|
|
} |
|
|
|
</SecondaryNavItemsOverflow> |
|
|
|
</SecondaryNavItemsComponent> |
|
|
|
{ |
|
|
|
secondaryVisible |
|
|
|
&& ( |
|
|
|
<SecondaryVisibleDummy /> |
|
|
|
) |
|
|
|
} |
|
|
|
<SecondaryNavItems> |
|
|
|
<Link |
|
|
|
href={closeHref} |
|
|
|
passHref |
|
|
|
shallow |
|
|
|
> |
|
|
|
<SecondaryNavItemsBg /> |
|
|
|
</Link> |
|
|
|
<SecondaryNavItemsFg> |
|
|
|
<SecondaryNavItemsOverflow> |
|
|
|
{ |
|
|
|
secondaryItemsHeader.map(i => ( |
|
|
|
<SecondaryNavItem |
|
|
|
key={i.id} |
|
|
|
active={i.active} |
|
|
|
href={i.href} |
|
|
|
replace={i.replace} |
|
|
|
iconName={i.iconName} |
|
|
|
title={i.title} |
|
|
|
subtitle={i.subtitle} |
|
|
|
actions={i.actions} |
|
|
|
/> |
|
|
|
)) |
|
|
|
} |
|
|
|
{ |
|
|
|
secondaryItems.map(i => ( |
|
|
|
<SecondaryNavItem |
|
|
|
key={i.id} |
|
|
|
active={i.active} |
|
|
|
href={i.href} |
|
|
|
replace={i.replace} |
|
|
|
iconName={i.iconName} |
|
|
|
title={i.title} |
|
|
|
subtitle={i.subtitle} |
|
|
|
actions={i.actions} |
|
|
|
/> |
|
|
|
)) |
|
|
|
} |
|
|
|
</SecondaryNavItemsOverflow> |
|
|
|
</SecondaryNavItemsFg> |
|
|
|
</SecondaryNavItems> |
|
|
|
</NavbarItems> |
|
|
|
</NavbarContainer> |
|
|
|
</Base> |
|
|
|
) |
|
|
|
} |
|
|
|
</React.Fragment> |
|
|
|
) |
|
|
|
|
|
|
|
export default Navbar |