Skip to content

Commit

Permalink
refactor(.storybook/modes): add langs
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerAPfledderer committed Apr 19, 2024
1 parent 64476c2 commit 31b56ea
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 9 deletions.
41 changes: 40 additions & 1 deletion .storybook/modes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,45 @@ export const viewportModes = {
},
}

export const langModes = {
en: {
locale: "en",
},
zh: {
locale: "zh",
},
ru: {
locale: "ru",
},
uk: {
locale: "uk",
},
}

type LangViewModeObj = {
[key: string]: { viewport: string; locale: string }
}

export const langViewportModes = Object.entries(
viewportModes
).reduce<LangViewModeObj>((arr, curr) => {
const [viewKey, viewVal] = curr

const currLangViewObj = {} as LangViewModeObj

Object.entries(langModes).forEach(([langKey, langVal]) => {
currLangViewObj[`${langKey}-${viewKey}`] = {
viewport: viewVal.viewport,
locale: langVal.locale,
}
})

return {
...arr,
...currLangViewObj,
}
}, {})

export const allModes = {
...viewportModes,
...langViewportModes,
}
4 changes: 2 additions & 2 deletions src/components/Hero/ContentHero/ContentHero.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useTranslation } from "next-i18next"
import { Meta, StoryObj } from "@storybook/react"

import { viewportModes } from "../../../../.storybook/modes"
import { langViewportModes } from "../../../../.storybook/modes"
import contentHeroImg from "../../../../public/mainnet.png"

import ContentHeroComponent, { ContentHeroProps } from "."
Expand All @@ -15,7 +15,7 @@ const meta = {
layout: "none",
chromatic: {
modes: {
...viewportModes,
...langViewportModes,
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/Hero/HomeHero/HomeHero.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from "react"
import { Meta, StoryObj } from "@storybook/react"

import { viewportModes } from "../../../../.storybook/modes"
import { langViewportModes } from "../../../../.storybook/modes"
import homeHeroImg from "../../../../public/home/hero.png"

import HomeHeroComponent from "."
Expand All @@ -15,7 +15,7 @@ const meta = {
layout: "none",
chromatic: {
modes: {
...viewportModes,
...langViewportModes,
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/Hero/HubHero/HubHero.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useTranslation } from "next-i18next"
import { Box } from "@chakra-ui/react"
import { Meta, StoryObj } from "@storybook/react"

import { viewportModes } from "../../../../.storybook/modes"
import { langViewportModes } from "../../../../.storybook/modes"

import HubHeroComponent from "./"

Expand All @@ -16,7 +16,7 @@ const meta = {
layout: "none",
chromatic: {
modes: {
...viewportModes,
...langViewportModes,
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/Hero/MdxHero/MdxHero.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HStack } from "@chakra-ui/react"
import { Meta, StoryObj } from "@storybook/react"

import { viewportModes } from "../../../../.storybook/modes"
import { langViewportModes } from "../../../../.storybook/modes"

import MdxHeroComponent from "./"

Expand All @@ -13,7 +13,7 @@ const meta = {
layout: "none",
chromatic: {
modes: {
...viewportModes,
...langViewportModes,
},
},
},
Expand Down

0 comments on commit 31b56ea

Please sign in to comment.