-
Notifications
You must be signed in to change notification settings - Fork 9
/
TapArea.stories.tsx
149 lines (140 loc) · 3.48 KB
/
TapArea.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import { type StoryObj, type Meta } from "@storybook/react";
import TapArea from "./TapArea";
import Avatar from "../Avatar/Avatar";
import image from "../../../../apps/storybook/assets/images/jane.webp";
import Box from "../Box/Box";
import Typography from "../Typography/Typography";
export default {
title: "Components/TapArea",
component: TapArea,
args: {
disabled: false,
rounding: "none",
tabIndex: 0,
fullWidth: true,
accessibilityLabel: "",
"data-testid": "",
},
argTypes: {
disabled: {
control: "boolean",
},
onClick: { action: "clicked" },
rounding: {
options: ["none", "sm", "md", "lg", "xl", "full"],
control: { type: "select" },
},
tabIndex: {
control: { type: "number" },
options: [0, -1],
},
},
tags: ["autodocs"],
} as Meta<typeof TapArea>;
export const Default: StoryObj<typeof TapArea> = {
args: {
children: (
<Box display="flex" alignItems="center" gap={4} padding={2}>
<Avatar accessibilityLabel="Jane" src={image} size="md" />
<Typography size={500}>Jane Doe</Typography>
</Box>
),
},
};
export const Disabled: StoryObj<typeof Default> = {
args: { ...Default.args, disabled: true },
};
const roundingLookup = {
sm: "8px",
md: "12px",
lg: "16px",
xl: "32px",
full: "999px",
} as const;
export const Rounding: StoryObj<typeof Box> = {
render: () => (
<>
<Box display="flex" direction="column" gap={4}>
<Typography>Hover to see the rounding effect</Typography>
<Box
display="flex"
gap={4}
flexWrap="wrap"
backgroundColor="gray100"
padding={4}
>
{(["sm", "md", "lg", "xl", "full"] as const).map((rounding) => (
<TapArea
key={rounding}
rounding={rounding}
fullWidth={false}
onClick={() => {
/* empty */
}}
>
<Box display="flex" alignItems="center" gap={2} padding={2}>
<Typography tooltip={`${roundingLookup[rounding]}`}>
rounding="{rounding}"
</Typography>
</Box>
</TapArea>
))}
</Box>
</Box>
</>
),
};
export const Colored: StoryObj<typeof Box> = {
render: () => (
<>
<Box display="flex" direction="column" gap={4}>
<Typography>Hover to see the overlay</Typography>
<TapArea
fullWidth={false}
onClick={() => {
/* empty */
}}
>
<Box
display="flex"
alignItems="center"
gap={2}
padding={2}
backgroundColor="purple300"
>
<Typography>Colored</Typography>
</Box>
</TapArea>
</Box>
</>
),
};
export const NestedLink: StoryObj<typeof Box> = {
render: () => (
<>
<Box display="flex" direction="column" gap={4}>
<TapArea
fullWidth={false}
onClick={() => {
/* empty */
}}
>
<Box
display="flex"
alignItems="center"
gap={2}
padding={2}
backgroundColor="purple200"
>
<Typography>
Link:{" "}
<a href="https://www.cambly.com" target="_blank">
Cambly
</a>
</Typography>
</Box>
</TapArea>
</Box>
</>
),
};