-
Notifications
You must be signed in to change notification settings - Fork 9
/
Chip.stories.tsx
121 lines (114 loc) · 2.83 KB
/
Chip.stories.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import { useState } from "react";
import { type StoryObj, type Meta } from "@storybook/react";
import Chip from "./Chip";
import Star from "@mui/icons-material/Star";
import Box from "../Box/Box";
export default {
title: "Components/Chip",
component: Chip,
parameters: {
design: {
type: "figma",
url: "https://www.figma.com/file/p7LKna9JMU0JEkcKamzs53/%F0%9F%93%90-Syntax?type=design&node-id=6156%3A25032&mode=design&t=SSblm5y2vyrOKil1-1",
},
},
args: {
selected: false,
text: "text on chip",
size: "sm",
on: "lightBackground",
disabled: false,
"data-testid": "",
dangerouslyForceFocusStyles: false,
},
argTypes: {
on: {
options: ["lightBackground", "darkBackground"],
control: { type: "radio" },
},
selected: {
control: "boolean",
},
text: {
control: "text",
},
size: { options: ["sm", "lg"], control: { type: "radio" } },
},
tags: ["autodocs"],
} as Meta<typeof Chip>;
export const Default: StoryObj<typeof Chip> = {
args: {
text: "text on chip",
selected: false,
},
render: (args) => {
return (
<Box
backgroundColor={args.on === "lightBackground" ? "white" : "black"}
padding={2}
>
<Chip {...args} />
</Box>
);
},
};
const ChipInteractive = () => {
const [isSmSelected, setIsSmSelected] = useState(false);
const [isLgSelected, setIsLgSelected] = useState(false);
const handleSmChange = () => {
setIsSmSelected(!isSmSelected);
};
const handleLgChange = () => {
setIsLgSelected(!isLgSelected);
};
return (
<Box display="flex" gap={2} alignItems="center" flexWrap="wrap">
<Chip
text="interactive sm chip"
size="sm"
onChange={handleSmChange}
selected={isSmSelected}
/>
<Chip
text="interactive lg chip"
size="lg"
onChange={handleLgChange}
selected={isLgSelected}
/>
</Box>
);
};
const ChipIconInteractive = () => {
const [isSmSelected, setIsSmSelected] = useState(false);
const [isLgSelected, setIsLgSelected] = useState(false);
const handleSmChange = () => {
setIsSmSelected(!isSmSelected);
};
const handleLgChange = () => {
setIsLgSelected(!isLgSelected);
};
return (
<Box display="flex" gap={2} alignItems="center" flexWrap="wrap">
<Chip
icon={Star}
text="interactive sm chip"
size="sm"
onChange={handleSmChange}
selected={isSmSelected}
/>
<Chip
icon={Star}
text="interactive lg chip"
size="lg"
onChange={handleLgChange}
selected={isLgSelected}
/>
</Box>
);
};
export const Interactive: StoryObj<typeof Chip> = {
render: () => <ChipInteractive />,
};
export const IconInteractive: StoryObj<typeof Chip> = {
render: () => <ChipIconInteractive />,
};