-
Notifications
You must be signed in to change notification settings - Fork 14
/
Button.stories.tsx
334 lines (329 loc) · 15.5 KB
/
Button.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
import React from "react";
import DxcButton from "./Button";
import DxcFlex from "./../flex/Flex";
import { BackgroundColorProvider } from "../BackgroundColorContext";
import Title from "../../.storybook/components/Title";
import ExampleContainer from "../../.storybook/components/ExampleContainer";
import DarkContainer from "../../.storybook/components/DarkSection";
export default {
title: "Button",
component: DxcButton,
};
const iconSVG = (
<svg width="24px" height="24px" viewBox="0 0 24 24" fill="currentColor">
<path d="M0 0h24v24H0z" fill="none" />
<path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z" />
</svg>
);
const facebookIcon = (
<svg
version="1.1"
id="Capa_1"
x="0px"
y="0px"
width="438.536px"
height="438.536px"
viewBox="0 0 438.536 438.536"
fill="currentColor"
>
<g>
<path
d="M414.41,24.123C398.333,8.042,378.963,0,356.315,0H82.228C59.58,0,40.21,8.042,24.126,24.123
C8.045,40.207,0.003,59.576,0.003,82.225v274.084c0,22.647,8.042,42.018,24.123,58.102c16.084,16.084,35.454,24.126,58.102,24.126
h274.084c22.648,0,42.018-8.042,58.095-24.126c16.084-16.084,24.126-35.454,24.126-58.102V82.225
C438.532,59.576,430.49,40.204,414.41,24.123z M373.155,225.548h-49.963V406.84h-74.802V225.548H210.99V163.02h37.401v-37.402
c0-26.838,6.283-47.107,18.843-60.813c12.559-13.706,33.304-20.555,62.242-20.555h49.963v62.526h-31.401
c-10.663,0-17.467,1.853-20.417,5.568c-2.949,3.711-4.428,10.23-4.428,19.558v31.119h56.534L373.155,225.548z"
/>
</g>
</svg>
);
const smallIcon = (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" height="20" width="20" fill="currentColor">
<path d="m7.646 18.333-.313-2.625q-.208-.125-.458-.27-.25-.146-.458-.271l-2.438 1.021-2.354-4.063 2.083-1.583V9.458L1.625 7.875l2.354-4.063 2.438 1.021q.208-.125.458-.27.25-.146.458-.271l.313-2.625h4.708l.313 2.625q.208.125.458.271.25.145.458.27l2.438-1.021 2.354 4.063-2.063 1.583v1.084l2.063 1.583-2.354 4.063-2.438-1.021q-.208.125-.458.271-.25.145-.458.27l-.313 2.625ZM10 12.979q1.229 0 2.104-.875T12.979 10q0-1.229-.875-2.104T10 7.021q-1.229 0-2.104.875T7.021 10q0 1.229.875 2.104t2.104.875Zm0-1.75q-.5 0-.865-.364-.364-.365-.364-.865t.364-.865q.365-.364.865-.364t.865.364q.364.365.364.865t-.364.865q-.365.364-.865.364ZM10.021 10Zm-.854 6.583h1.666l.25-2.166q.605-.167 1.167-.5.562-.334 1.021-.792l2.021.854.833-1.375-1.771-1.354q.104-.292.146-.604.042-.313.042-.646 0-.292-.042-.594t-.125-.635l1.771-1.375-.834-1.375-2.02.875q-.48-.479-1.032-.802-.552-.323-1.156-.49l-.271-2.187H9.167l-.271 2.187q-.604.167-1.156.49-.552.323-1.011.781l-2.021-.854-.833 1.375 1.75 1.354q-.083.333-.125.646-.042.312-.042.604t.042.594q.042.302.125.635l-1.75 1.375.833 1.375 2.021-.854q.459.458 1.011.781.552.323 1.156.49Z" />
</svg>
);
export const Chromatic = () => (
<>
<Title title="Primary" theme="light" level={2} />
<ExampleContainer>
<Title title="Enabled" theme="light" level={4} />
<DxcButton label="Primary enabled" />
</ExampleContainer>
<ExampleContainer pseudoState="pseudo-hover">
<Title title="Hovered" theme="light" level={4} />
<DxcButton label="Primary hovered" />
</ExampleContainer>
<ExampleContainer pseudoState="pseudo-focus">
<Title title="Focused" theme="light" level={4} />
<DxcButton label="Primary focused" />
</ExampleContainer>
<ExampleContainer pseudoState="pseudo-active">
<Title title="Actived" theme="light" level={4} />
<DxcButton label="Primary actived" />
</ExampleContainer>
<ExampleContainer>
<Title title="Disabled" theme="light" level={4} />
<DxcButton label="Primary disabled" disabled />
</ExampleContainer>
<ExampleContainer>
<Title title="With left icon" theme="light" level={4} />
<DxcButton label="Primary" icon={iconSVG} />
</ExampleContainer>
<ExampleContainer>
<Title title="With right icon" theme="light" level={4} />
<DxcButton label="Primary" icon={iconSVG} iconPosition="after" />
</ExampleContainer>
<ExampleContainer>
<Title title="Only icon" theme="light" level={4} />
<DxcButton icon={iconSVG} />
</ExampleContainer>
<ExampleContainer>
<Title title="Big icon (SVG)" theme="light" level={4} />
<DxcButton icon={facebookIcon} />
</ExampleContainer>
<ExampleContainer>
<Title title="Big icon (image)" theme="light" level={4} />
<DxcButton icon="https://developer.apple.com/design/human-interface-guidelines/foundations/app-icons/images/icon-and-image-large-icon-settings_2x.png" />
</ExampleContainer>
<ExampleContainer>
<Title title="Small icon" theme="light" level={4} />
<DxcButton icon={smallIcon} />
</ExampleContainer>
<Title title="Secondary" theme="light" level={2} />
<ExampleContainer>
<Title title="Enabled" theme="light" level={4} />
<DxcButton mode="secondary" label="Secondary enabled" />
</ExampleContainer>
<ExampleContainer pseudoState="pseudo-hover">
<Title title="Hovered" theme="light" level={4} />
<DxcButton mode="secondary" label="Secondary hovered" />
</ExampleContainer>
<ExampleContainer pseudoState="pseudo-focus">
<Title title="Focused" theme="light" level={4} />
<DxcButton mode="secondary" label="Secondary focused" />
</ExampleContainer>
<ExampleContainer pseudoState="pseudo-active">
<Title title="Actived" theme="light" level={4} />
<DxcButton mode="secondary" label="Secondary actived" />
</ExampleContainer>
<ExampleContainer>
<Title title="Disabled" theme="light" level={4} />
<DxcButton mode="secondary" disabled label="Secondary disabled" />
</ExampleContainer>
<ExampleContainer>
<Title title="With icon" theme="light" level={4} />
<DxcButton mode="secondary" label="Secondary" icon={iconSVG} />
</ExampleContainer>
<ExampleContainer>
<Title title="Only icon (image)" theme="light" level={4} />
<DxcButton mode="secondary" icon="https://developer.apple.com/design/human-interface-guidelines/foundations/app-icons/images/icon-and-image-large-icon-settings_2x.png" />
</ExampleContainer>
<Title title="Text" theme="light" level={2} />
<ExampleContainer>
<Title title="Enabled" theme="light" level={4} />
<DxcButton mode="text" label="Text enabled" />
</ExampleContainer>
<ExampleContainer pseudoState="pseudo-hover">
<Title title="Hovered" theme="light" level={4} />
<DxcButton mode="text" label="Text hovered" />
</ExampleContainer>
<ExampleContainer pseudoState="pseudo-focus">
<Title title="Focused" theme="light" level={4} />
<DxcButton mode="text" label="Text focused" />
</ExampleContainer>
<ExampleContainer pseudoState="pseudo-active">
<Title title="Actived" theme="light" level={4} />
<DxcButton mode="text" label="Text actived" />
</ExampleContainer>
<ExampleContainer>
<Title title="Disabled" theme="light" level={4} />
<DxcButton mode="text" label="Text disabled" disabled />
</ExampleContainer>
<ExampleContainer>
<Title title="With icon" theme="light" level={4} />
<DxcButton label="Text" mode="text" icon={iconSVG} />
</ExampleContainer>
<ExampleContainer>
<Title title="Only icon (image)" theme="light" level={4} />
<DxcButton mode="text" icon="https://developer.apple.com/design/human-interface-guidelines/foundations/app-icons/images/icon-and-image-large-icon-settings_2x.png" />
</ExampleContainer>
<BackgroundColorProvider color="#333333">
<DarkContainer>
<Title title="Primary" theme="dark" level={2} />
<ExampleContainer>
<Title title="Enabled" theme="dark" level={4} />
<DxcButton label="Primary enabled" />
</ExampleContainer>
<ExampleContainer pseudoState="pseudo-hover">
<Title title="Hovered" theme="dark" level={4} />
<DxcButton label="Primary hovered" />
</ExampleContainer>
<ExampleContainer pseudoState="pseudo-focus">
<Title title="Focused" theme="dark" level={4} />
<DxcButton label="Primary focused" />
</ExampleContainer>
<ExampleContainer pseudoState="pseudo-active">
<Title title="Actived" theme="dark" level={4} />
<DxcButton label="Primary actived" />
</ExampleContainer>
<ExampleContainer>
<Title title="Disabled" theme="dark" level={4} />
<DxcButton label="Primary disabled" disabled />
</ExampleContainer>
<ExampleContainer>
<Title title="With icon" theme="dark" level={4} />
<DxcButton label="Primary" icon={iconSVG} />
</ExampleContainer>
<Title title="Secondary" theme="dark" level={2} />
<ExampleContainer>
<Title title="Enabled" theme="dark" level={4} />
<DxcButton mode="secondary" label="Secondary enabled" />
</ExampleContainer>
<ExampleContainer pseudoState="pseudo-hover">
<Title title="Hovered" theme="dark" level={4} />
<DxcButton mode="secondary" label="Secondary hovered" />
</ExampleContainer>
<ExampleContainer pseudoState="pseudo-focus">
<Title title="Focused" theme="dark" level={4} />
<DxcButton mode="secondary" label="Secondary focused" />
</ExampleContainer>
<ExampleContainer pseudoState="pseudo-active">
<Title title="Actived" theme="dark" level={4} />
<DxcButton mode="secondary" label="Secondary actived" />
</ExampleContainer>
<ExampleContainer>
<Title title="Disabled" theme="dark" level={4} />
<DxcButton mode="secondary" disabled label="Secondary disabled" />
</ExampleContainer>
<ExampleContainer>
<Title title="With icon" theme="dark" level={4} />
<DxcButton mode="secondary" label="Primary" icon={iconSVG} />
</ExampleContainer>
<Title title="Text" theme="dark" level={2} />
<ExampleContainer>
<Title title="Enabled" theme="dark" level={4} />
<DxcButton mode="text" label="Text enabled" />
</ExampleContainer>
<ExampleContainer pseudoState="pseudo-hover">
<Title title="Hovered" theme="dark" level={4} />
<DxcButton mode="text" label="Text hovered" />
</ExampleContainer>
<ExampleContainer pseudoState="pseudo-focus">
<Title title="Focused" theme="dark" level={4} />
<DxcButton mode="text" label="Text focused" />
</ExampleContainer>
<ExampleContainer pseudoState="pseudo-active">
<Title title="Actived" theme="dark" level={4} />
<DxcButton mode="text" label="Text actived" />
</ExampleContainer>
<ExampleContainer>
<Title title="Disabled" theme="dark" level={4} />
<DxcButton mode="text" label="Text disabled" disabled />
</ExampleContainer>
<ExampleContainer>
<Title title="With icon" theme="dark" level={4} />
<DxcButton mode="text" label="Primary" icon={iconSVG} />
</ExampleContainer>
</DarkContainer>
</BackgroundColorProvider>
<Title title="Sizes" theme="light" level={2} />
<ExampleContainer>
<Title title="Small size" theme="light" level={4} />
<DxcButton label="Small" size="small" />
</ExampleContainer>
<ExampleContainer>
<Title title="Medium size" theme="light" level={4} />
<DxcButton label="MediumSiz" size="medium" />
</ExampleContainer>
<ExampleContainer>
<Title title="Medium size with ellipsis" theme="light" level={4} />
<DxcButton label="MediumSize" size="medium" />
</ExampleContainer>
<ExampleContainer>
<Title title="Medium size icon after" theme="light" level={4} />
<DxcButton label="Mediu" iconPosition="after" icon={iconSVG} size="medium" />
</ExampleContainer>
<ExampleContainer>
<Title title="Medium size icon before" theme="light" level={4} />
<DxcButton label="Mediu" iconPosition="before" icon={iconSVG} size="medium" />
</ExampleContainer>
<ExampleContainer>
<Title title="Medium size icon after with ellipsis" theme="light" level={4} />
<DxcButton label="Medium" iconPosition="after" icon={iconSVG} size="medium" />
</ExampleContainer>
<ExampleContainer>
<Title title="Medium size icon before with ellipsis" theme="light" level={4} />
<DxcButton label="Medium" iconPosition="before" icon={iconSVG} size="medium" />
</ExampleContainer>
<ExampleContainer>
<Title title="Large size" theme="light" level={4} />
<DxcButton label="LargeSizePrimaryButtonEx" size="large" />
</ExampleContainer>
<ExampleContainer>
<Title title="Large size with ellipsis" theme="light" level={4} />
<DxcButton label="LargeSizePrimaryButtonExa" size="large" />
</ExampleContainer>
<ExampleContainer>
<Title title="Large size icon after" theme="light" level={4} />
<DxcButton label="LargeSizePrimaryButto" iconPosition="after" icon={iconSVG} size="large" />
</ExampleContainer>
<ExampleContainer>
<Title title="Large size icon before" theme="light" level={4} />
<DxcButton label="LargeSizePrimaryButto" iconPosition="before" icon={iconSVG} size="large" />
</ExampleContainer>
<ExampleContainer>
<Title title="Large size icon after with ellipsis" theme="light" level={4} />
<DxcButton label="LargeSizePrimaryButton" iconPosition="after" icon={iconSVG} size="large" />
</ExampleContainer>
<ExampleContainer>
<Title title="Large size icon before with ellipsis" theme="light" level={4} />
<DxcButton label="LargeSizePrimaryButton" iconPosition="before" icon={iconSVG} size="large" />
</ExampleContainer>
<ExampleContainer>
<Title title="FillParent size" theme="light" level={4} />
<DxcButton label="FillParent" size="fillParent" />
</ExampleContainer>
<ExampleContainer>
<Title title="FitContent size" theme="light" level={4} />
<DxcButton label="FitContent" size="fitContent" />
</ExampleContainer>
<Title title="Margins" theme="light" level={2} />
<ExampleContainer>
<Title title="Xxsmall margin" theme="light" level={4} />
<DxcButton label="Xxsmall margin" margin="xxsmall" />
</ExampleContainer>
<ExampleContainer>
<Title title="Xsmall margin" theme="light" level={4} />
<DxcButton label="Xsmall margin" margin="xsmall" />
</ExampleContainer>
<ExampleContainer>
<Title title="Small margin" theme="light" level={4} />
<DxcButton label="Small margin" margin="small" />
</ExampleContainer>
<ExampleContainer>
<Title title="Medium margin" theme="light" level={4} />
<DxcButton label="Medium margin" margin="medium" />
</ExampleContainer>
<ExampleContainer>
<Title title="Large margin" theme="light" level={4} />
<DxcButton label="Large margin" margin="large" />
</ExampleContainer>
<ExampleContainer>
<Title title="Xlarge margin" theme="light" level={4} />
<DxcButton label="Xlarge margin" margin="xlarge" />
</ExampleContainer>
<ExampleContainer>
<Title title="Xxlarge margin" theme="light" level={4} />
<DxcButton label="Xxlarge margin" margin="xxlarge" />
</ExampleContainer>
<Title title="Inside a flex" theme="light" level={2} />
<ExampleContainer>
<DxcFlex direction="column" gap="0.75rem">
<DxcButton label="Button" />
<DxcButton label="Button" />
<DxcButton label="Button" />
</DxcFlex>
</ExampleContainer>
</>
);