Skip to content

Commit 1d1cffc

Browse files
feat(Colors.stories): create story for semantic colors
1 parent 3bb385a commit 1d1cffc

File tree

1 file changed

+62
-2
lines changed

1 file changed

+62
-2
lines changed

src/components/BaseStories/Colors.stories.tsx

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
import type { ReactNode } from "react"
2-
import { Box, HStack, Square, Stack, Text } from "@chakra-ui/react"
1+
import { type ReactNode } from "react"
2+
import capitalize from "lodash/capitalize"
3+
import { Box, Flex, HStack, Square, Stack, Text } from "@chakra-ui/react"
34
import type { Meta, StoryObj } from "@storybook/react"
45

56
import colors from "@/@chakra-ui/foundations/colors"
7+
import semanticTokens from "@/@chakra-ui/semanticTokens"
8+
9+
import Heading from "../Heading"
610

711
const meta = {
812
title: "Design System/Colors",
@@ -77,3 +81,59 @@ const ColorGroupWrapper = ({
7781
</Box>
7882
)
7983
}
84+
85+
export const SemanticScheme: StoryObj = {
86+
parameters: {
87+
chromatic: {
88+
modes: {
89+
darkMode: {
90+
colorMode: "dark",
91+
},
92+
lightMode: {
93+
colorMode: "light",
94+
},
95+
},
96+
},
97+
},
98+
render: () => {
99+
const tokenNames = ["primary", "body", "background"] as const
100+
const deprecatedTokens = {
101+
primary: ["light", "dark", "pressed"],
102+
body: ["inverted"],
103+
background: [],
104+
}
105+
return (
106+
<Flex direction="column" gap="16">
107+
{tokenNames.map((tokenName) => {
108+
const currentDeprecatedTokens = deprecatedTokens[
109+
tokenName
110+
] as string[]
111+
112+
return (
113+
<Flex key={tokenName} direction="column" gap="4">
114+
<Heading>{capitalize(tokenName)}</Heading>
115+
<HStack gap="8">
116+
{Object.keys(semanticTokens["colors"][tokenName])
117+
.filter((key) => !currentDeprecatedTokens.includes(key))
118+
.map((key) => (
119+
<Flex key={key} direction="column" gap="2">
120+
<Square
121+
border={
122+
tokenName === "background" && key === "base"
123+
? "1px solid"
124+
: undefined
125+
}
126+
size="20"
127+
bg={`${tokenName}.${key}`}
128+
></Square>
129+
<Text>{key}</Text>
130+
</Flex>
131+
))}
132+
</HStack>
133+
</Flex>
134+
)
135+
})}
136+
</Flex>
137+
)
138+
},
139+
}

0 commit comments

Comments
 (0)