Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(layouts): create story and update style for base layout #12960

Merged
merged 13 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ import type { StorybookConfig } from "@storybook/nextjs"
*/

const config: StorybookConfig = {
stories: ["../src/components/**/*.stories.{ts,tsx}"],
stories: [
"../src/components/**/*.stories.tsx",
"../src/layouts/stories/*.stories.tsx",
],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
Expand Down
2 changes: 1 addition & 1 deletion src/@chakra-ui/foundations/sizes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const container = {
"2xl": "1440px",
"2xl": "1536px",
}

const sizes = {
Expand Down
51 changes: 30 additions & 21 deletions src/layouts/RootLayout.tsx → src/layouts/BaseLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ import { SkipLink } from "@/components/SkipLink"
// import TranslationBannerLegal from "@/components/TranslationBannerLegal"
// import { toPosixPath } from "@/lib/utils/relativePath"
// import { DEFAULT_LOCALE } from "@/lib/constants"
import { lightTheme as oldTheme } from "../theme"

const FeedbackWidget = dynamic(() => import("@/components/FeedbackWidget"), {
ssr: false,
})

export const RootLayout = ({
export const BaseLayout = ({
children,
// contentIsOutdated,
// contentNotTranslated,
Expand Down Expand Up @@ -49,27 +48,37 @@ export const RootLayout = ({
// const originalPagePath = toPosixPath(join(DEFAULT_LOCALE, asPath))

return (
<Container mx="auto" maxW={oldTheme.variables.maxPageWidth}>
<>
{/**
* The Skip Link is positioned above the container to ensure it is not affecting the
* layout on initial load.
*/}
<SkipLink />
<Container maxW="container.2xl" marginInline="auto">
<Nav />

{/* TODO: FIX TRANSLATION BANNER LOGIC FOR https://github.com/ethereum/ethereum-org-website/issues/11305 */}
{/* <TranslationBanner
shouldShow={shouldShowTranslationBanner}
isPageContentEnglish={contentNotTranslated}
originalPagePath={originalPagePath}
/>

<TranslationBannerLegal
shouldShow={shouldShowLegalTranslationBanner}
originalPagePath={originalPagePath}
/> */}

{children}

<Footer lastDeployLocaleTimestamp={lastDeployLocaleTimestamp} />
</Container>
{/**
* The Feedback Widget is positioned below the container to ensure it is not affecting the
* layout on initial load.
*/}

<Nav />

{/* TODO: FIX TRANSLATION BANNER LOGIC FOR https://github.com/ethereum/ethereum-org-website/issues/11305 */}
{/* <TranslationBanner
shouldShow={shouldShowTranslationBanner}
isPageContentEnglish={contentNotTranslated}
originalPagePath={originalPagePath}
/>

<TranslationBannerLegal
shouldShow={shouldShowLegalTranslationBanner}
originalPagePath={originalPagePath}
/> */}

{children}

<Footer lastDeployLocaleTimestamp={lastDeployLocaleTimestamp} />
<FeedbackWidget />
</Container>
</>
)
}
2 changes: 1 addition & 1 deletion src/layouts/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export * from "./BaseLayout"
export * from "./Docs"
export * from "./Roadmap"
export * from "./RootLayout"
export * from "./Staking"
export * from "./Static"
export * from "./Tutorial"
Expand Down
45 changes: 45 additions & 0 deletions src/layouts/stories/BaseLayout.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { Center } from "@chakra-ui/react"
import type { Meta, StoryObj } from "@storybook/react"

import { langViewportModes } from "../../../.storybook/modes"
import { BaseLayout as BaseLayoutComponent } from "../BaseLayout"

const meta = {
title: "Templates/BaseLayout",
component: BaseLayoutComponent,
parameters: {
layout: "fullscreen",
chromatic: {
modes: {
...langViewportModes,
},
},
},
argTypes: {
children: {
table: {
disable: true,
},
},
lastDeployLocaleTimestamp: {
table: {
disable: true,
},
},
},
} satisfies Meta<typeof BaseLayoutComponent>

export default meta

export const BaseLayout: StoryObj<typeof meta> = {
args: {
children: (
<Center h="497px" border="2px dashed" borderColor="primary.base">
Content Here
</Center>
),
contentIsOutdated: false,
contentNotTranslated: false,
lastDeployLocaleTimestamp: "May 14, 2021",
},
}
6 changes: 3 additions & 3 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { AppPropsWithLayout } from "@/lib/types"
import "../styles/global.css"

import { useLocaleDirection } from "@/hooks/useLocaleDirection"
import { RootLayout } from "@/layouts/RootLayout"
import { BaseLayout } from "@/layouts/BaseLayout"
import { mono } from "@/lib/fonts"

const App = ({ Component, pageProps }: AppPropsWithLayout) => {
Expand Down Expand Up @@ -45,13 +45,13 @@ const App = ({ Component, pageProps }: AppPropsWithLayout) => {
`}
</style>
<ChakraProvider theme={theme}>
<RootLayout
<BaseLayout
contentIsOutdated={!!pageProps.frontmatter?.isOutdated}
contentNotTranslated={pageProps.contentNotTranslated}
lastDeployLocaleTimestamp={pageProps.lastDeployLocaleTimestamp}
>
{getLayout(<Component {...pageProps} />)}
</RootLayout>
</BaseLayout>
</ChakraProvider>
</>
)
Expand Down
Loading