The existence of the TopBar widget depends on some props related to it.master
@@ -34,12 +34,21 @@ export const Layout: React.FC<Props> = ({ | |||||
return ( | return ( | ||||
<> | <> | ||||
<Config /> | <Config /> | ||||
<TopBar | |||||
brand={brand} | |||||
userLink={userLink} | |||||
> | |||||
{topBarCenter} | |||||
</TopBar> | |||||
{ | |||||
( | |||||
brand | |||||
|| userLink | |||||
|| topBarCenter | |||||
) | |||||
&& ( | |||||
<TopBar | |||||
brand={brand} | |||||
userLink={userLink} | |||||
> | |||||
{topBarCenter} | |||||
</TopBar> | |||||
) | |||||
} | |||||
<ContentBase> | <ContentBase> | ||||
{children} | {children} | ||||
</ContentBase> | </ContentBase> | ||||
@@ -34,12 +34,22 @@ export const Layout: React.FC<Props> = ({ | |||||
return ( | return ( | ||||
<> | <> | ||||
<Config /> | <Config /> | ||||
<TopBar | |||||
brand={brand} | |||||
userLink={userLink} | |||||
> | |||||
{topBarCenter} | |||||
</TopBar> | |||||
{ | |||||
( | |||||
brand | |||||
|| userLink | |||||
|| topBarCenter | |||||
) | |||||
&& ( | |||||
<TopBar | |||||
span="narrow" | |||||
brand={brand} | |||||
userLink={userLink} | |||||
> | |||||
{topBarCenter} | |||||
</TopBar> | |||||
) | |||||
} | |||||
<ContentBase> | <ContentBase> | ||||
{children} | {children} | ||||
</ContentBase> | </ContentBase> | ||||
@@ -108,7 +108,7 @@ export const Layout: React.FC<Props> = ({ | |||||
) | ) | ||||
} | } | ||||
<TopBar | <TopBar | ||||
wide | |||||
span="wide" | |||||
brand={brand} | brand={brand} | ||||
menuLink={menuLink} | menuLink={menuLink} | ||||
userLink={userLink} | userLink={userLink} | ||||
@@ -350,14 +350,24 @@ export const Layout: React.FC<Props> = ({ | |||||
) | ) | ||||
} | } | ||||
<> | <> | ||||
<TopBar | |||||
wide | |||||
brand={brand} | |||||
menuLink={sidebarMain ? menuLink : undefined} | |||||
userLink={userLink} | |||||
> | |||||
{topBarCenter} | |||||
</TopBar> | |||||
{ | |||||
( | |||||
brand | |||||
|| userLink | |||||
|| topBarCenter | |||||
|| sidebarMain | |||||
) | |||||
&& ( | |||||
<TopBar | |||||
span="wide" | |||||
brand={brand} | |||||
menuLink={sidebarMain ? menuLink : undefined} | |||||
userLink={userLink} | |||||
> | |||||
{topBarCenter} | |||||
</TopBar> | |||||
) | |||||
} | |||||
<SidebarBase> | <SidebarBase> | ||||
<SidebarMenu> | <SidebarMenu> | ||||
<SidebarMenuSize> | <SidebarMenuSize> | ||||
@@ -75,13 +75,22 @@ export const Layout: React.FC<Props> = ({ | |||||
return ( | return ( | ||||
<> | <> | ||||
<Config /> | <Config /> | ||||
<TopBar | |||||
wide | |||||
brand={brand} | |||||
userLink={userLink} | |||||
> | |||||
{topBarCenter} | |||||
</TopBar> | |||||
{ | |||||
( | |||||
brand | |||||
|| userLink | |||||
|| topBarCenter | |||||
) | |||||
&& ( | |||||
<TopBar | |||||
span="wide" | |||||
brand={brand} | |||||
userLink={userLink} | |||||
> | |||||
{topBarCenter} | |||||
</TopBar> | |||||
) | |||||
} | |||||
<ContentBase> | <ContentBase> | ||||
{children} | {children} | ||||
</ContentBase> | </ContentBase> | ||||
@@ -35,6 +35,10 @@ const Container = styled('div')({ | |||||
alignItems: 'center', | alignItems: 'center', | ||||
}) | }) | ||||
const NarrowContainer = styled(Container)({ | |||||
maxWidth: configVar('base-width'), | |||||
}) | |||||
const WideContainer = styled(Container)({ | const WideContainer = styled(Container)({ | ||||
...minWidthFactor(3)({ | ...minWidthFactor(3)({ | ||||
maxWidth: `calc(${configVar('base-width')} * 3)`, | maxWidth: `calc(${configVar('base-width')} * 3)`, | ||||
@@ -82,21 +86,27 @@ const MenuLinkContainer = styled(LinkContainer)({ | |||||
}), | }), | ||||
}) | }) | ||||
const CONTAINER_COMPONENTS = { | |||||
narrow: NarrowContainer, | |||||
normal: Container, | |||||
wide: WideContainer, | |||||
} | |||||
type Props = { | type Props = { | ||||
wide?: boolean, | |||||
span?: keyof typeof CONTAINER_COMPONENTS, | |||||
brand?: React.ReactNode, | brand?: React.ReactNode, | ||||
menuLink?: React.ReactNode, | menuLink?: React.ReactNode, | ||||
userLink?: React.ReactNode, | userLink?: React.ReactNode, | ||||
} | } | ||||
const TopBar: React.FC<Props> = ({ | const TopBar: React.FC<Props> = ({ | ||||
wide, | |||||
span = 'normal', | |||||
brand, | brand, | ||||
menuLink, | menuLink, | ||||
userLink, | userLink, | ||||
children, | children, | ||||
}) => { | }) => { | ||||
const ContainerComponent = wide ? WideContainer : Container | |||||
const { [span as keyof typeof CONTAINER_COMPONENTS]: ContainerComponent = Container } = CONTAINER_COMPONENTS | |||||
return ( | return ( | ||||
<Base> | <Base> | ||||
<ContainerComponent> | <ContainerComponent> | ||||