Skip to content

Commit 3a9e5ff

Browse files
refactor(Tag): create story for basic style variants
1 parent b5d88aa commit 3a9e5ff

File tree

2 files changed

+40
-29
lines changed

2 files changed

+40
-29
lines changed

src/components/Tag/Tag.stories.tsx

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as React from "react"
2-
import { Meta, StoryObj } from "@storybook/react"
3-
import { Box, HStack, Link, VStack } from "@chakra-ui/react"
2+
import { Args, Meta, StoryObj } from "@storybook/react"
3+
import { Box, HStack, Link, TagProps, VStack } from "@chakra-ui/react"
44
import { TbSquareRoundedNumber8Filled } from "react-icons/tb"
5-
import Tag from "."
5+
import Tag, { EthTagProps } from "."
66
import { MdInfoOutline, MdLanguage } from "react-icons/md"
77

88
type TagType = typeof Tag
@@ -22,33 +22,44 @@ const statusArray = ["normal", "tag", "success", "error", "warning"] as const
2222
// "subtle" is default variant
2323
const variantArray = ["subtle", "solid", "outline"]
2424

25-
export const StyleVariantsAndStatuses: Story = {
26-
args: {
27-
label: "Tag Name",
28-
},
29-
render: (args) => (
30-
<>
31-
<Box textAlign="center" mb={8}>
25+
const StyleVariantList = (args: EthTagProps) => (
26+
<HStack>
27+
{statusArray.map((status) => (
28+
<VStack key={status}>
29+
{variantArray.map((variant) => (
30+
<Tag
31+
key={variant}
32+
href="#"
33+
status={status}
34+
variant={variant}
35+
{...args}
36+
/>
37+
))}
38+
</VStack>
39+
))}
40+
</HStack>
41+
)
42+
43+
export const StyleVariantsBasic: Story = {
44+
render: () => (
45+
<VStack spacing={8}>
46+
<Box textAlign="center">
47+
Click anywhere in the whitespace and then tab to see the button styling
48+
on `:focus-visible`
49+
</Box>
50+
<StyleVariantList label="Tag Name" isCloseable />
51+
</VStack>
52+
),
53+
}
54+
55+
export const StyleVariantsAsLinks: Story = {
56+
render: () => (
57+
<VStack spacing={8}>
58+
<Box textAlign="center">
3259
They are all rendered as links to hover, click, and focus
3360
</Box>
34-
<HStack>
35-
{statusArray.map((status) => (
36-
<VStack key={status}>
37-
{variantArray.map((variant) => (
38-
<Tag
39-
key={variant}
40-
as={Link}
41-
href="#"
42-
status={status}
43-
variant={variant}
44-
isCloseable
45-
{...args}
46-
/>
47-
))}
48-
</VStack>
49-
))}
50-
</HStack>
51-
</>
61+
<StyleVariantList as={Link} label="Tag Name" />
62+
</VStack>
5263
),
5364
}
5465

src/components/Tag/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
TagRightIcon,
1010
} from "@chakra-ui/react"
1111

12-
interface EthTagProps extends TagProps {
12+
export interface EthTagProps extends TagProps {
1313
label: string
1414
isCloseable?: boolean
1515
leftIcon?: any

0 commit comments

Comments
 (0)