From 81a57bd21243e38b42fe75ac280da87ad63156ab Mon Sep 17 00:00:00 2001 From: Grace Park Date: Mon, 7 Jun 2021 15:41:56 -0700 Subject: [PATCH 01/15] starting point set --- components/Breadcrumbs.tsx | 40 +++++++++++++------ .../context/ProductSubLandingContext.tsx | 24 +++++++++++ components/landing/ProductSubLanding.tsx | 23 +++++++++++ pages/[versionId]/[productId]/index.tsx | 16 +++++++- 4 files changed, 88 insertions(+), 15 deletions(-) create mode 100644 components/context/ProductSubLandingContext.tsx create mode 100644 components/landing/ProductSubLanding.tsx diff --git a/components/Breadcrumbs.tsx b/components/Breadcrumbs.tsx index 31cd481c6b..2393efe687 100644 --- a/components/Breadcrumbs.tsx +++ b/components/Breadcrumbs.tsx @@ -27,19 +27,33 @@ export const Breadcrumbs = (props: Props) => { {breadcrumb.title} - ) : ( - - {breadcrumb.title} - - ) + ) : pathWithLocale.includes('/guides') ? ( + + + {breadcrumb.title} + + + ) : ( + + {breadcrumb.title} + + ) })} ) diff --git a/components/context/ProductSubLandingContext.tsx b/components/context/ProductSubLandingContext.tsx new file mode 100644 index 0000000000..f24883e5c1 --- /dev/null +++ b/components/context/ProductSubLandingContext.tsx @@ -0,0 +1,24 @@ +import { createContext, useContext } from 'react' +import pick from 'lodash/pick' + +export type ProductSubLandingContextT = { +} + +export const ProductSubLandingContext = createContext(null) + +export const useProductSubLandingContext = (): ProductSubLandingContextT => { + const context = useContext(ProductSubLandingContext) + + if (!context) { + throw new Error( + '"useProductSubLandingContext" may only be used inside "ProductSubLandingContext.Provider"' + ) + } + + return context +} + +export const getProductSubLandingContextFromRequest = (req: any): ProductSubLandingContextT => { + const page = req.context.page + return {} +} diff --git a/components/landing/ProductSubLanding.tsx b/components/landing/ProductSubLanding.tsx new file mode 100644 index 0000000000..b94d7185e2 --- /dev/null +++ b/components/landing/ProductSubLanding.tsx @@ -0,0 +1,23 @@ +import { DefaultLayout } from 'components/DefaultLayout' +import { useProductSubLandingContext } from 'components/context/ProductSubLandingContext' +import { useTranslation } from 'components/hooks/useTranslation' +import cx from 'classnames' + +import React from 'react' +import { GuideCards } from './GuideCards' +import { LandingSection } from './LandingSection' +import { Breadcrumbs } from 'components/Breadcrumbs' + +export const ProductSubLanding = () => { + const { + } = useProductSubLandingContext() + const { t } = useTranslation('product_sublanding') + + return ( + + + + + + ) +} diff --git a/pages/[versionId]/[productId]/index.tsx b/pages/[versionId]/[productId]/index.tsx index 2ba64d13b6..b2cc38f2df 100644 --- a/pages/[versionId]/[productId]/index.tsx +++ b/pages/[versionId]/[productId]/index.tsx @@ -10,8 +10,14 @@ import { ProductLandingContextT, ProductLandingContext, } from 'components/context/ProductLandingContext' +import { + getProductSubLandingContextFromRequest, + ProductSubLandingContextT, + ProductSubLandingContext, +} from 'components/context/ProductSubLandingContext' import { ProductLanding } from 'components/landing/ProductLanding' +import { ProductSubLanding } from 'components/landing/ProductSubLanding' import { TocLanding } from 'components/landing/TocLanding' import { getTocLandingContextFromRequest, @@ -22,9 +28,10 @@ import { type Props = { mainContext: MainContextT productLandingContext: ProductLandingContextT + productSubLandingContext: ProductSubLandingContextT tocLandingContext: TocLandingContextT } -const GlobalPage = ({ mainContext, productLandingContext, tocLandingContext }: Props) => { +const GlobalPage = ({ mainContext, productLandingContext, productSubLandingContext, tocLandingContext }: Props) => { const { currentLayoutName, page, relativePath } = mainContext let content @@ -35,7 +42,11 @@ const GlobalPage = ({ mainContext, productLandingContext, tocLandingContext }: P ) } else if (currentLayoutName === 'product-sublanding') { - content =

todo: product sub-landing

+ content = ( + + + + ) } else if (relativePath?.endsWith('index.md')) { content = ( @@ -64,6 +75,7 @@ export const getServerSideProps: GetServerSideProps = async (context) => props: { mainContext: getMainContextFromRequest(req), productLandingContext: getProductLandingContextFromRequest(req), + productSubLandingContext: getProductSubLandingContextFromRequest(req), tocLandingContext: getTocLandingContextFromRequest(req), }, } From c8c6a2d6c7aaf7f3b20adba9699731e58e11899e Mon Sep 17 00:00:00 2001 From: Grace Park Date: Mon, 7 Jun 2021 17:04:20 -0700 Subject: [PATCH 02/15] set up hero header --- components/Breadcrumbs.tsx | 2 +- .../context/ProductSubLandingContext.tsx | 10 +++++++++- components/landing/ProductSubLanding.tsx | 8 +++++--- components/landing/SubLandingHero.tsx | 19 +++++++++++++++++++ components/landing/SubLandingSection.tsx | 17 +++++++++++++++++ 5 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 components/landing/SubLandingHero.tsx create mode 100644 components/landing/SubLandingSection.tsx diff --git a/components/Breadcrumbs.tsx b/components/Breadcrumbs.tsx index 2393efe687..7e9e2427b4 100644 --- a/components/Breadcrumbs.tsx +++ b/components/Breadcrumbs.tsx @@ -14,7 +14,7 @@ export const Breadcrumbs = (props: Props) => { const router = useRouter() const pathWithLocale = `/${router.locale}${router.asPath.split('?')[0]}` // remove query string const { breadcrumbs } = useMainContext() - + console.log(pathWithLocale) return (