@@ -7,7 +7,6 @@ import Brand from '../../molecules/Brand' | |||||
type Props = { | type Props = { | ||||
query: string, | query: string, | ||||
sidebarMainOpen: boolean, | |||||
menuLinkLabel: string, | menuLinkLabel: string, | ||||
userLinkLabel: string, | userLinkLabel: string, | ||||
searchQueryKey: string, | searchQueryKey: string, | ||||
@@ -15,12 +14,13 @@ type Props = { | |||||
searchHint: string, | searchHint: string, | ||||
popupQueryKey: string, | popupQueryKey: string, | ||||
userPopupQueryValue: string, | userPopupQueryValue: string, | ||||
sidebarQueryKey: string, | |||||
sidebarSubpageQueryValue: string, | |||||
subpageQueryKey: string, | |||||
subpage: string, | |||||
} | } | ||||
const LeftSidebarLayoutTemplate: React.FC<Props> = ({ | const LeftSidebarLayoutTemplate: React.FC<Props> = ({ | ||||
query, | query, | ||||
sidebarMainOpen, | |||||
menuLinkLabel, | menuLinkLabel, | ||||
userLinkLabel, | userLinkLabel, | ||||
searchQueryKey, | searchQueryKey, | ||||
@@ -28,14 +28,16 @@ const LeftSidebarLayoutTemplate: React.FC<Props> = ({ | |||||
searchHint, | searchHint, | ||||
popupQueryKey, | popupQueryKey, | ||||
userPopupQueryValue, | userPopupQueryValue, | ||||
sidebarQueryKey, | |||||
sidebarSubpageQueryValue, | |||||
subpageQueryKey, | |||||
subpage, | |||||
}) => { | }) => { | ||||
return ( | return ( | ||||
<LeftSidebar.Layout | <LeftSidebar.Layout | ||||
brand={ | brand={ | ||||
<Brand /> | <Brand /> | ||||
} | } | ||||
sidebarMainOpen={sidebarMainOpen} | |||||
sidebarMainOpen={subpage === sidebarSubpageQueryValue} | |||||
topBarCenter={ | topBarCenter={ | ||||
<form> | <form> | ||||
<T.TextInput | <T.TextInput | ||||
@@ -52,7 +54,7 @@ const LeftSidebarLayoutTemplate: React.FC<Props> = ({ | |||||
<Link | <Link | ||||
href={{ | href={{ | ||||
query: { | query: { | ||||
[sidebarQueryKey]: '', | |||||
[subpageQueryKey]: sidebarSubpageQueryValue, | |||||
}, | }, | ||||
}} | }} | ||||
> | > | ||||
@@ -7,36 +7,36 @@ import Brand from '../../molecules/Brand' | |||||
type Props = { | type Props = { | ||||
query: string, | query: string, | ||||
sidebarMainOpen: boolean, | |||||
menuLinkLabel: string, | menuLinkLabel: string, | ||||
userLinkLabel: string, | userLinkLabel: string, | ||||
moreItemsOpen: boolean, | |||||
searchQueryKey: string, | searchQueryKey: string, | ||||
searchLabel: string, | searchLabel: string, | ||||
searchHint: string, | searchHint: string, | ||||
popupQueryKey: string, | popupQueryKey: string, | ||||
moreQueryKey: string, | |||||
sidebarQueryKey: string, | |||||
moreSubpageQueryValue: string, | |||||
sidebarSubpageQueryValue: string, | |||||
moreLinkLabel: string, | moreLinkLabel: string, | ||||
sidebarMenuItems: LeftSidebarWithMenu.MenuItem[], | sidebarMenuItems: LeftSidebarWithMenu.MenuItem[], | ||||
userPopupQueryValue: string, | userPopupQueryValue: string, | ||||
subpageQueryKey: string, | |||||
subpage: string, | |||||
} | } | ||||
const LeftSidebarLayoutTemplate: React.FC<Props> = ({ | const LeftSidebarLayoutTemplate: React.FC<Props> = ({ | ||||
query, | query, | ||||
sidebarMainOpen, | |||||
menuLinkLabel, | menuLinkLabel, | ||||
userLinkLabel, | userLinkLabel, | ||||
moreItemsOpen, | |||||
searchQueryKey, | searchQueryKey, | ||||
searchLabel, | searchLabel, | ||||
searchHint, | searchHint, | ||||
popupQueryKey, | popupQueryKey, | ||||
moreQueryKey, | |||||
sidebarQueryKey, | |||||
moreSubpageQueryValue, | |||||
sidebarSubpageQueryValue, | |||||
moreLinkLabel, | moreLinkLabel, | ||||
sidebarMenuItems, | sidebarMenuItems, | ||||
userPopupQueryValue, | userPopupQueryValue, | ||||
subpageQueryKey, | |||||
subpage, | |||||
}) => { | }) => { | ||||
return ( | return ( | ||||
<LeftSidebarWithMenu.Layout | <LeftSidebarWithMenu.Layout | ||||
@@ -59,7 +59,7 @@ const LeftSidebarLayoutTemplate: React.FC<Props> = ({ | |||||
<Link | <Link | ||||
href={{ | href={{ | ||||
query: { | query: { | ||||
[sidebarQueryKey]: '', | |||||
[subpageQueryKey]: sidebarSubpageQueryValue, | |||||
}, | }, | ||||
}} | }} | ||||
> | > | ||||
@@ -87,7 +87,7 @@ const LeftSidebarLayoutTemplate: React.FC<Props> = ({ | |||||
label: moreLinkLabel, | label: moreLinkLabel, | ||||
url: { | url: { | ||||
query: { | query: { | ||||
[moreQueryKey]: '', | |||||
[subpageQueryKey]: moreSubpageQueryValue, | |||||
}, | }, | ||||
}, | }, | ||||
icon: ( | icon: ( | ||||
@@ -97,7 +97,7 @@ const LeftSidebarLayoutTemplate: React.FC<Props> = ({ | |||||
/> | /> | ||||
), | ), | ||||
}} | }} | ||||
moreItemsOpen={moreItemsOpen} | |||||
moreItemsOpen={subpage === moreSubpageQueryValue} | |||||
moreLinkComponent={({ url, icon, label, }) => ( | moreLinkComponent={({ url, icon, label, }) => ( | ||||
<Link | <Link | ||||
href={url} | href={url} | ||||
@@ -122,7 +122,7 @@ const LeftSidebarLayoutTemplate: React.FC<Props> = ({ | |||||
</LeftSidebarWithMenu.SidebarMenuContainer> | </LeftSidebarWithMenu.SidebarMenuContainer> | ||||
</Link> | </Link> | ||||
)} | )} | ||||
sidebarMainOpen={sidebarMainOpen} | |||||
sidebarMainOpen={subpage === sidebarSubpageQueryValue} | |||||
sidebarMain={ | sidebarMain={ | ||||
<LeftSidebarWithMenu.SidebarMainContainer> | <LeftSidebarWithMenu.SidebarMainContainer> | ||||
<DummyContent /> | <DummyContent /> | ||||
@@ -1,21 +1,22 @@ | |||||
import {GetServerSideProps, NextPage} from 'next' | import {GetServerSideProps, NextPage} from 'next' | ||||
import Template from '../../../components/templates/LeftSidebarLayout' | import Template from '../../../components/templates/LeftSidebarLayout' | ||||
import {POPUP, QUERY, SIDEBAR} from '../../../utilities/queryKeys' | |||||
import {POPUP, QUERY, SUBPAGE} from '../../../utilities/queryKeys' | |||||
import {USER} from '../../../utilities/popups' | import {USER} from '../../../utilities/popups' | ||||
import {SIDEBAR} from '../../../utilities/subpages' | |||||
type Props = { | type Props = { | ||||
query: string, | query: string, | ||||
sidebarMainOpen: boolean, | |||||
subpage: string, | |||||
} | } | ||||
const Page: NextPage<Props> = ({ | const Page: NextPage<Props> = ({ | ||||
query, | query, | ||||
sidebarMainOpen, | |||||
subpage, | |||||
}) => { | }) => { | ||||
return ( | return ( | ||||
<Template | <Template | ||||
subpage={subpage} | |||||
query={query} | query={query} | ||||
sidebarMainOpen={sidebarMainOpen} | |||||
userLinkLabel="User" | userLinkLabel="User" | ||||
searchQueryKey={QUERY} | searchQueryKey={QUERY} | ||||
searchLabel="Search" | searchLabel="Search" | ||||
@@ -23,7 +24,8 @@ const Page: NextPage<Props> = ({ | |||||
popupQueryKey={POPUP} | popupQueryKey={POPUP} | ||||
userPopupQueryValue={USER} | userPopupQueryValue={USER} | ||||
menuLinkLabel="Menu" | menuLinkLabel="Menu" | ||||
sidebarQueryKey={SIDEBAR} | |||||
subpageQueryKey={SUBPAGE} | |||||
sidebarSubpageQueryValue={SIDEBAR} | |||||
/> | /> | ||||
) | ) | ||||
} | } | ||||
@@ -31,11 +33,11 @@ const Page: NextPage<Props> = ({ | |||||
export default Page | export default Page | ||||
export const getServerSideProps: GetServerSideProps = async (ctx) => { | export const getServerSideProps: GetServerSideProps = async (ctx) => { | ||||
const { [QUERY]: query = '', } = ctx.query | |||||
const { [QUERY]: query = '', [SUBPAGE]: subpage = null, } = ctx.query | |||||
return { | return { | ||||
props: { | props: { | ||||
query, | query, | ||||
sidebarMainOpen: 'sidebar' in ctx.query, | |||||
subpage, | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -2,24 +2,23 @@ import * as React from 'react' | |||||
import * as T from '@tesseract-design/react-common' | import * as T from '@tesseract-design/react-common' | ||||
import {GetServerSideProps, NextPage} from 'next' | import {GetServerSideProps, NextPage} from 'next' | ||||
import Template from '../../../../components/templates/LeftSidebarWithMenuLayout' | import Template from '../../../../components/templates/LeftSidebarWithMenuLayout' | ||||
import {MORE, POPUP, QUERY, SIDEBAR} from '../../../../utilities/queryKeys' | |||||
import {POPUP, QUERY, SUBPAGE} from '../../../../utilities/queryKeys' | |||||
import {USER} from '../../../../utilities/popups' | import {USER} from '../../../../utilities/popups' | ||||
import {MORE, SIDEBAR} from '../../../../utilities/subpages' | |||||
type Props = { | type Props = { | ||||
query: string, | query: string, | ||||
sidebarMainOpen: boolean, | |||||
moreItemsOpen: boolean, | |||||
subpage: string, | |||||
} | } | ||||
const Page: NextPage<Props> = ({ | const Page: NextPage<Props> = ({ | ||||
query, | query, | ||||
sidebarMainOpen, | |||||
moreItemsOpen, | |||||
subpage, | |||||
}) => { | }) => { | ||||
return ( | return ( | ||||
<Template | <Template | ||||
query={query} | query={query} | ||||
moreQueryKey={MORE} | |||||
subpage={subpage} | |||||
userLinkLabel="User" | userLinkLabel="User" | ||||
searchQueryKey={QUERY} | searchQueryKey={QUERY} | ||||
searchLabel="Search" | searchLabel="Search" | ||||
@@ -27,10 +26,10 @@ const Page: NextPage<Props> = ({ | |||||
popupQueryKey={POPUP} | popupQueryKey={POPUP} | ||||
userPopupQueryValue={USER} | userPopupQueryValue={USER} | ||||
menuLinkLabel="Menu" | menuLinkLabel="Menu" | ||||
sidebarQueryKey={SIDEBAR} | |||||
sidebarMainOpen={sidebarMainOpen} | |||||
moreLinkLabel="More" | moreLinkLabel="More" | ||||
moreItemsOpen={moreItemsOpen} | |||||
subpageQueryKey={SUBPAGE} | |||||
sidebarSubpageQueryValue={SIDEBAR} | |||||
moreSubpageQueryValue={MORE} | |||||
sidebarMenuItems={[ | sidebarMenuItems={[ | ||||
{ | { | ||||
id: '1', | id: '1', | ||||
@@ -133,12 +132,11 @@ const Page: NextPage<Props> = ({ | |||||
export default Page | export default Page | ||||
export const getServerSideProps: GetServerSideProps = async (ctx) => { | export const getServerSideProps: GetServerSideProps = async (ctx) => { | ||||
const { q: query = '', } = ctx.query | |||||
const { [QUERY]: query = '', [SUBPAGE]: subpage = null, } = ctx.query | |||||
return { | return { | ||||
props: { | props: { | ||||
query, | query, | ||||
sidebarMainOpen: 'sidebar' in ctx.query, | |||||
moreItemsOpen: 'more' in ctx.query, | |||||
subpage, | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -2,6 +2,4 @@ export const QUERY = 'q' | |||||
export const POPUP = 'popup' | export const POPUP = 'popup' | ||||
export const SIDEBAR = 'sidebar' | |||||
export const MORE = 'more' | |||||
export const SUBPAGE = 'subpage' |
@@ -0,0 +1,3 @@ | |||||
export const SIDEBAR = 'sidebar' | |||||
export const MORE = 'more' |