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 3 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 @@ -16,7 +16,10 @@ import TsconfigPathsPlugin from "tsconfig-paths-webpack-plugin"
*/

const config: StorybookConfig = {
stories: ["../src/components/**/*.stories.{ts,tsx}"],
stories: [
"../src/components/**/*.stories.tsx",
"../src/layouts/layoutStories/*.stories.tsx",
],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
Expand Down
51 changes: 29 additions & 22 deletions src/layouts/RootLayout.tsx → src/layouts/BaseLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ import { toPosixPath } from "@/lib/utils/relativePath"

import { DEFAULT_LOCALE } from "@/lib/constants"

import { lightTheme as oldTheme } from "../theme"

export const RootLayout = ({
export const BaseLayout = ({
children,
contentIsOutdated,
contentNotTranslated,
Expand Down Expand Up @@ -47,26 +45,35 @@ 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 />

<Nav />

<TranslationBanner
shouldShow={shouldShowTranslationBanner}
isPageContentEnglish={contentNotTranslated}
originalPagePath={originalPagePath}
/>

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

{children}

<Footer lastDeployDate={lastDeployDate} />
<Container maxW="1536px">
pettinarip marked this conversation as resolved.
Show resolved Hide resolved
<Nav />

<TranslationBanner
shouldShow={shouldShowTranslationBanner}
isPageContentEnglish={contentNotTranslated}
originalPagePath={originalPagePath}
/>

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

{children}

<Footer lastDeployDate={lastDeployDate} />
</Container>
{/**
* The Feedback Widget is positioned below the container to ensure it is not affecting the
* layout on initial load.
*/}
<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
36 changes: 36 additions & 0 deletions src/layouts/layoutStories/BaseLayout.stories.tsx
pettinarip marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Center } from "@chakra-ui/react"
import type { Meta, StoryObj } from "@storybook/react"

import { BaseLayout as BaseLayoutComponent } from "../BaseLayout"

const meta = {
title: "Templates/BaseLayout",
component: BaseLayoutComponent,
argTypes: {
children: {
table: {
disable: true,
},
},
lastDeployDate: {
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,
lastDeployDate: "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}
lastDeployDate={pageProps.lastDeployDate}
>
{getLayout(<Component {...pageProps} />)}
</RootLayout>
</BaseLayout>
</ChakraProvider>
</>
)
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13110,7 +13110,7 @@ ts-pnp@^1.1.6:
resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.2.0.tgz#a500ad084b0798f1c3071af391e65912c86bca92"
integrity sha512-csd+vJOb/gkzvcCHgTGSChYpy5f1/XKNsmvBGO4JXS+z1v2HobugDz4s1IeFXM3wZB44uczs+eazB5Q/ccdhQw==

tsconfig-paths-webpack-plugin@^4.0.1, tsconfig-paths-webpack-plugin@^4.1.0:
tsconfig-paths-webpack-plugin@4.1.0, tsconfig-paths-webpack-plugin@^4.0.1:
version "4.1.0"
resolved "https://registry.yarnpkg.com/tsconfig-paths-webpack-plugin/-/tsconfig-paths-webpack-plugin-4.1.0.tgz#3c6892c5e7319c146eee1e7302ed9e6f2be4f763"
integrity sha512-xWFISjviPydmtmgeUAuXp4N1fky+VCtfhOkDUFIv5ea7p4wuTomI4QTrXvFBX2S4jZsmyTSrStQl+E+4w+RzxA==
Expand Down
Loading