@lunit/design-system 1.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Alert/index.js +1 -1
- package/dist/cjs/components/Alert/index.js.map +1 -1
- package/dist/cjs/components/Button/index.js +1 -1
- package/dist/cjs/components/Button/index.js.map +1 -1
- package/dist/cjs/components/Checkbox/index.js +1 -1
- package/dist/cjs/components/Checkbox/index.js.map +1 -1
- package/dist/cjs/components/Dialog/index.js +2 -0
- package/dist/cjs/components/Dialog/index.js.map +1 -0
- package/dist/cjs/components/Radio/index.js +1 -1
- package/dist/cjs/components/Radio/index.js.map +1 -1
- package/dist/cjs/components/ToggleButton/index.js +1 -1
- package/dist/cjs/components/ToggleButton/index.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/components/Button/Button.styled.js +1 -1
- package/dist/components/Button/Button.styled.js.map +1 -1
- package/dist/components/Checkbox/Checkbox.js +9 -19
- package/dist/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/Dialog/Dialog.js +57 -0
- package/dist/components/Dialog/Dialog.js.map +1 -0
- package/dist/components/Dialog/Dialog.styled.js +146 -0
- package/dist/components/Dialog/Dialog.styled.js.map +1 -0
- package/dist/components/Dialog/components/DialogAction.js +18 -0
- package/dist/components/Dialog/components/DialogAction.js.map +1 -0
- package/dist/components/Dialog/index.js +2 -0
- package/dist/components/Dialog/index.js.map +1 -0
- package/dist/components/Radio/Radio.js +7 -21
- package/dist/components/Radio/Radio.js.map +1 -1
- package/dist/components/ToggleButton/ToggleButton.styled.js +1 -1
- package/dist/components/ToggleButton/ToggleButton.styled.js.map +1 -1
- package/dist/foundation/Elevation/index.js +1 -1
- package/dist/foundation/Elevation/index.js.map +1 -1
- package/dist/foundation/Typography/index.js +0 -6
- package/dist/foundation/Typography/index.js.map +1 -1
- package/dist/foundation/Typography/tokens.js +1 -1
- package/dist/foundation/colors/base/grey.js +3 -1
- package/dist/foundation/colors/base/grey.js.map +1 -1
- package/dist/foundation/colors/index.js +5 -6
- package/dist/foundation/colors/index.js.map +1 -1
- package/dist/foundation/colors/token/component.js +31 -115
- package/dist/foundation/colors/token/component.js.map +1 -1
- package/dist/foundation/colors/token/core.js +43 -75
- package/dist/foundation/colors/token/core.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/components/Alert/Alert.utils.d.ts +3 -3
- package/dist/types/components/Button/Button.styled.d.ts +8 -8
- package/dist/types/components/Chip/Chip.styled.d.ts +12 -12
- package/dist/types/components/Dialog/Dialog.d.ts +50 -0
- package/dist/types/components/Dialog/Dialog.styled.d.ts +12 -0
- package/dist/types/components/Dialog/components/DialogAction.d.ts +8 -0
- package/dist/types/components/Dialog/index.d.ts +2 -0
- package/dist/types/components/Toast/Toast.utils.d.ts +1 -1
- package/dist/types/components/ToggleButton/ToggleButton.styled.d.ts +2 -2
- package/dist/types/foundation/Elevation/index.d.ts +1 -1
- package/dist/types/foundation/Typography/index.d.ts +1 -7
- package/dist/types/foundation/Typography/tokens.d.ts +1 -1
- package/dist/types/foundation/colors/base/grey.d.ts +2 -0
- package/dist/types/foundation/colors/index.d.ts +5 -6
- package/dist/types/foundation/colors/token/types.d.ts +0 -2
- package/dist/types/foundation/colors/types.d.ts +78 -76
- package/dist/types/foundation/index.d.ts +5 -0
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/Button/Button.styled.ts +1 -1
- package/src/components/Checkbox/Checkbox.tsx +39 -22
- package/src/components/Dialog/Dialog.styled.ts +172 -0
- package/src/components/Dialog/Dialog.tsx +189 -0
- package/src/components/Dialog/components/DialogAction.tsx +36 -0
- package/src/components/Dialog/index.ts +14 -0
- package/src/components/Radio/Radio.tsx +37 -25
- package/src/components/ToggleButton/ToggleButton.styled.ts +1 -1
- package/src/foundation/Elevation/index.ts +1 -1
- package/src/foundation/Typography/index.ts +0 -6
- package/src/foundation/Typography/tokens.ts +1 -1
- package/src/foundation/colors/base/grey.ts +3 -1
- package/src/foundation/colors/index.ts +5 -6
- package/src/foundation/colors/token/component.ts +26 -110
- package/src/foundation/colors/token/core.ts +39 -71
- package/src/foundation/colors/token/types.ts +0 -2
- package/src/foundation/colors/types.ts +78 -75
- package/src/index.ts +1 -1
- package/src/stories/GettingStarted.mdx +88 -0
- package/src/stories/components/Button/BasicButton.stories.tsx +80 -52
- package/src/stories/components/Button/ButtonDocs.mdx +187 -0
- package/src/stories/components/Button/Color.stories.tsx +132 -0
- package/src/stories/components/Button/IconButton.stories.tsx +41 -35
- package/src/stories/components/Button/Kind.stories.tsx +13 -52
- package/src/stories/components/{SelectControl/Checkbox.stories.tsx → CheckBox/BasicCheckbox.stories.tsx} +84 -105
- package/src/stories/components/CheckBox/CheckboxDocs.mdx +85 -0
- package/src/stories/components/Chip/Chip.stories.tsx +65 -0
- package/src/stories/components/Chip/ChipDocs.mdx +132 -0
- package/src/stories/components/Dialog/Dialog.stories.tsx +320 -0
- package/src/stories/components/Dialog/DialogDocs.mdx +181 -0
- package/src/stories/components/TextField/BasicTextField.stories.tsx +214 -0
- package/src/stories/components/TextField/TextFieldDocs.mdx +140 -0
- package/src/stories/components/TextField/TextFieldSize.stories.tsx +26 -3
- package/src/stories/components/ToggleButton/Basic.stories.tsx +312 -0
- package/src/stories/components/ToggleButton/ToggleButtonDocs.mdx +180 -0
- package/src/stories/components/ToggleButton/ToggleButtonKind.stories.tsx +65 -0
- package/src/stories/components/ToggleButton/WithIcon.stories.tsx +138 -0
- package/src/stories/foundation/Typography/Typography.mdx +31 -46
- package/src/stories/foundation/Typography/Typography.stories.tsx +30 -1
- package/src/stories/foundation/colors/ColorSystem.tsx +86 -0
- package/src/stories/foundation/colors/Docs.mdx +225 -0
- package/src/stories/foundation/colors/TokenPaletteTable.tsx +1 -5
- package/src/components/Modal/Modal.tsx +0 -8
- package/src/components/Modal/index.ts +0 -1
- package/src/stories/components/Modal/Modal.stories.tsx +0 -15
- package/src/stories/foundation/Typography/TypographyExamples.stories.tsx +0 -44
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
TableRow,
|
|
7
7
|
TableBody,
|
|
8
8
|
TableCell,
|
|
9
|
+
Box,
|
|
9
10
|
} from "@mui/material";
|
|
10
11
|
import Bell from "@lunit/design-system-icons/Bell";
|
|
11
12
|
import ToggleButton from "@/components/ToggleButton";
|
|
@@ -163,6 +164,9 @@ const BasicToggleButtonTemplate: StoryFn<typeof ToggleButton> = (arg) => {
|
|
|
163
164
|
export const BasicToggleButton = {
|
|
164
165
|
render: BasicToggleButtonTemplate,
|
|
165
166
|
name: "Basic ToggleButton",
|
|
167
|
+
parameters: {
|
|
168
|
+
chromatic: { disableSnapshot: true },
|
|
169
|
+
},
|
|
166
170
|
};
|
|
167
171
|
|
|
168
172
|
const SizeTemplate: StoryFn<typeof ToggleButton> = (args) => {
|
|
@@ -280,6 +284,203 @@ export const Size = {
|
|
|
280
284
|
},
|
|
281
285
|
};
|
|
282
286
|
|
|
287
|
+
const SizeDocsTemplate: StoryFn<typeof ToggleButton> = (args) => {
|
|
288
|
+
const [values, setValues] = React.useState({
|
|
289
|
+
small: "",
|
|
290
|
+
medium: "",
|
|
291
|
+
large: "",
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
const handleChange = (value: string | null, size: SizeValues) => {
|
|
295
|
+
if (!size) return;
|
|
296
|
+
|
|
297
|
+
setValues({
|
|
298
|
+
...values,
|
|
299
|
+
[size]: value,
|
|
300
|
+
});
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
return (
|
|
304
|
+
<Box
|
|
305
|
+
sx={{
|
|
306
|
+
display: "flex",
|
|
307
|
+
flexDirection: "column",
|
|
308
|
+
gap: 4,
|
|
309
|
+
"& button": {
|
|
310
|
+
marginRight: 2,
|
|
311
|
+
},
|
|
312
|
+
}}
|
|
313
|
+
>
|
|
314
|
+
<ToggleButtonGroup
|
|
315
|
+
sx={{
|
|
316
|
+
display: "flex",
|
|
317
|
+
alignItems: "center",
|
|
318
|
+
}}
|
|
319
|
+
value={values.small}
|
|
320
|
+
onChange={(_, value) => handleChange(value, "small")}
|
|
321
|
+
>
|
|
322
|
+
<ToggleButton {...args} value="small" size="small">
|
|
323
|
+
Small
|
|
324
|
+
</ToggleButton>
|
|
325
|
+
<ToggleButton {...args} value="medium" size="medium">
|
|
326
|
+
Medium
|
|
327
|
+
</ToggleButton>
|
|
328
|
+
<ToggleButton {...args} value="large" size="large">
|
|
329
|
+
Large
|
|
330
|
+
</ToggleButton>
|
|
331
|
+
</ToggleButtonGroup>
|
|
332
|
+
<ToggleButtonGroup
|
|
333
|
+
sx={{
|
|
334
|
+
display: "flex",
|
|
335
|
+
alignItems: "center",
|
|
336
|
+
}}
|
|
337
|
+
value={values.medium}
|
|
338
|
+
onChange={(_, value) => handleChange(value, "medium")}
|
|
339
|
+
>
|
|
340
|
+
<ToggleButton
|
|
341
|
+
{...args}
|
|
342
|
+
value="small"
|
|
343
|
+
kind="outlined"
|
|
344
|
+
color="primary"
|
|
345
|
+
size="small"
|
|
346
|
+
>
|
|
347
|
+
Small
|
|
348
|
+
</ToggleButton>
|
|
349
|
+
<ToggleButton
|
|
350
|
+
{...args}
|
|
351
|
+
value="medium"
|
|
352
|
+
kind="outlined"
|
|
353
|
+
color="primary"
|
|
354
|
+
size="medium"
|
|
355
|
+
>
|
|
356
|
+
Medium
|
|
357
|
+
</ToggleButton>
|
|
358
|
+
<ToggleButton
|
|
359
|
+
{...args}
|
|
360
|
+
value="large"
|
|
361
|
+
kind="outlined"
|
|
362
|
+
color="primary"
|
|
363
|
+
size="large"
|
|
364
|
+
>
|
|
365
|
+
Large
|
|
366
|
+
</ToggleButton>
|
|
367
|
+
</ToggleButtonGroup>
|
|
368
|
+
<ToggleButtonGroup
|
|
369
|
+
sx={{
|
|
370
|
+
display: "flex",
|
|
371
|
+
alignItems: "center",
|
|
372
|
+
}}
|
|
373
|
+
value={values.large}
|
|
374
|
+
onChange={(_, value) => handleChange(value, "large")}
|
|
375
|
+
>
|
|
376
|
+
<ToggleButton {...args} value="small" kind="ghost" size="small">
|
|
377
|
+
Small
|
|
378
|
+
</ToggleButton>
|
|
379
|
+
<ToggleButton {...args} value="medium" kind="ghost" size="medium">
|
|
380
|
+
Medium
|
|
381
|
+
</ToggleButton>
|
|
382
|
+
<ToggleButton {...args} value="large" kind="ghost" size="large">
|
|
383
|
+
Large
|
|
384
|
+
</ToggleButton>
|
|
385
|
+
</ToggleButtonGroup>
|
|
386
|
+
</Box>
|
|
387
|
+
);
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
export const SizeDocs = {
|
|
391
|
+
render: SizeDocsTemplate,
|
|
392
|
+
argTypes: {
|
|
393
|
+
size: {
|
|
394
|
+
control: false,
|
|
395
|
+
},
|
|
396
|
+
},
|
|
397
|
+
parameters: {
|
|
398
|
+
chromatic: { disableSnapshot: true },
|
|
399
|
+
},
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
const ColorTemplate: StoryFn<typeof ToggleButton> = (args) => {
|
|
403
|
+
const [contained, setContained] = useState("");
|
|
404
|
+
const [outlined, setOutlined] = useState("");
|
|
405
|
+
const [ghost, setGhost] = useState("");
|
|
406
|
+
|
|
407
|
+
return (
|
|
408
|
+
<Box sx={{ display: "flex", flexDirection: "column" }}>
|
|
409
|
+
<ToggleButtonGroup
|
|
410
|
+
sx={{
|
|
411
|
+
"& button": {
|
|
412
|
+
marginRight: 2,
|
|
413
|
+
},
|
|
414
|
+
}}
|
|
415
|
+
value={contained}
|
|
416
|
+
onChange={(_, value) => setContained(value)}
|
|
417
|
+
>
|
|
418
|
+
<ToggleButton {...args} value="first" kind="contained" color="primary">
|
|
419
|
+
Primary
|
|
420
|
+
</ToggleButton>
|
|
421
|
+
<ToggleButton
|
|
422
|
+
{...args}
|
|
423
|
+
value="second"
|
|
424
|
+
kind="contained"
|
|
425
|
+
color="secondary"
|
|
426
|
+
selectedColor="secondary"
|
|
427
|
+
>
|
|
428
|
+
Secondary
|
|
429
|
+
</ToggleButton>
|
|
430
|
+
</ToggleButtonGroup>
|
|
431
|
+
<ToggleButtonGroup
|
|
432
|
+
sx={{
|
|
433
|
+
marginTop: 4,
|
|
434
|
+
"& button": {
|
|
435
|
+
marginRight: 2,
|
|
436
|
+
},
|
|
437
|
+
}}
|
|
438
|
+
value={outlined}
|
|
439
|
+
onChange={(_, value) => setOutlined(value)}
|
|
440
|
+
>
|
|
441
|
+
<ToggleButton {...args} value="first" kind="outlined" color="primary">
|
|
442
|
+
Primary
|
|
443
|
+
</ToggleButton>
|
|
444
|
+
</ToggleButtonGroup>
|
|
445
|
+
<ToggleButtonGroup
|
|
446
|
+
sx={{
|
|
447
|
+
marginTop: 4,
|
|
448
|
+
"& button": {
|
|
449
|
+
marginRight: 2,
|
|
450
|
+
},
|
|
451
|
+
}}
|
|
452
|
+
value={ghost}
|
|
453
|
+
onChange={(_, value) => setGhost(value)}
|
|
454
|
+
>
|
|
455
|
+
<ToggleButton {...args} value="first" kind="ghost" color="primary">
|
|
456
|
+
Primary
|
|
457
|
+
</ToggleButton>
|
|
458
|
+
<ToggleButton
|
|
459
|
+
{...args}
|
|
460
|
+
value="second"
|
|
461
|
+
kind="ghost"
|
|
462
|
+
color="secondary"
|
|
463
|
+
selectedColor="secondary"
|
|
464
|
+
>
|
|
465
|
+
Secondary
|
|
466
|
+
</ToggleButton>
|
|
467
|
+
</ToggleButtonGroup>
|
|
468
|
+
</Box>
|
|
469
|
+
);
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
export const Color = {
|
|
473
|
+
render: ColorTemplate,
|
|
474
|
+
argTypes: {
|
|
475
|
+
size: {
|
|
476
|
+
control: false,
|
|
477
|
+
},
|
|
478
|
+
},
|
|
479
|
+
parameters: {
|
|
480
|
+
chromatic: { disableSnapshot: true },
|
|
481
|
+
},
|
|
482
|
+
};
|
|
483
|
+
|
|
283
484
|
const SelectedColorTemplate: StoryFn<typeof ToggleButton> = (arg) => {
|
|
284
485
|
const [selected1, setSelected1] = useState(true);
|
|
285
486
|
const [selected2, setSelected2] = useState(true);
|
|
@@ -344,3 +545,114 @@ export const SelectedColor = {
|
|
|
344
545
|
selected: true,
|
|
345
546
|
},
|
|
346
547
|
};
|
|
548
|
+
|
|
549
|
+
const SelectedColorDocsTemplate: StoryFn<typeof ToggleButton> = (args) => {
|
|
550
|
+
const { kind, selectedColor, color, ...restProps } = args;
|
|
551
|
+
return (
|
|
552
|
+
<Box
|
|
553
|
+
sx={{
|
|
554
|
+
"& button": {
|
|
555
|
+
marginRight: 2,
|
|
556
|
+
},
|
|
557
|
+
}}
|
|
558
|
+
>
|
|
559
|
+
<ToggleButton {...restProps} value="first" selectedColor="primary">
|
|
560
|
+
Primary
|
|
561
|
+
</ToggleButton>
|
|
562
|
+
<ToggleButton {...restProps} value="second" selectedColor="secondary">
|
|
563
|
+
Secondary
|
|
564
|
+
</ToggleButton>
|
|
565
|
+
</Box>
|
|
566
|
+
);
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
export const SelectedColorDocs = {
|
|
570
|
+
render: SelectedColorDocsTemplate,
|
|
571
|
+
argTypes: {
|
|
572
|
+
selectedColor: {
|
|
573
|
+
control: false,
|
|
574
|
+
},
|
|
575
|
+
},
|
|
576
|
+
args: {
|
|
577
|
+
selected: true,
|
|
578
|
+
},
|
|
579
|
+
parameters: {
|
|
580
|
+
chromatic: { disableSnapshot: true },
|
|
581
|
+
},
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
const SelectedDocsTemplate: StoryFn<typeof ToggleButton> = (args) => {
|
|
585
|
+
const { kind, selectedColor, color, selected, ...restProps } = args;
|
|
586
|
+
return (
|
|
587
|
+
<Box
|
|
588
|
+
sx={{
|
|
589
|
+
"& button": {
|
|
590
|
+
marginRight: 2,
|
|
591
|
+
},
|
|
592
|
+
}}
|
|
593
|
+
>
|
|
594
|
+
<ToggleButton {...restProps} value="first">
|
|
595
|
+
Not Selected
|
|
596
|
+
</ToggleButton>
|
|
597
|
+
<ToggleButton {...restProps} value="second" selected={true}>
|
|
598
|
+
Selected
|
|
599
|
+
</ToggleButton>
|
|
600
|
+
</Box>
|
|
601
|
+
);
|
|
602
|
+
};
|
|
603
|
+
|
|
604
|
+
export const SelectedDocs = {
|
|
605
|
+
render: SelectedDocsTemplate,
|
|
606
|
+
argTypes: {
|
|
607
|
+
selectedColor: {
|
|
608
|
+
control: false,
|
|
609
|
+
},
|
|
610
|
+
},
|
|
611
|
+
parameters: {
|
|
612
|
+
chromatic: { disableSnapshot: true },
|
|
613
|
+
include: ["color", "size", "disabled", "selected", "kind"],
|
|
614
|
+
},
|
|
615
|
+
};
|
|
616
|
+
|
|
617
|
+
const DisabledTemplate: StoryFn<typeof ToggleButton> = (args) => {
|
|
618
|
+
return (
|
|
619
|
+
<Box
|
|
620
|
+
sx={{
|
|
621
|
+
"& button": {
|
|
622
|
+
marginRight: 2,
|
|
623
|
+
},
|
|
624
|
+
}}
|
|
625
|
+
>
|
|
626
|
+
<ToggleButton {...args} value="first" disabled>
|
|
627
|
+
Text
|
|
628
|
+
</ToggleButton>
|
|
629
|
+
<ToggleButton
|
|
630
|
+
{...args}
|
|
631
|
+
kind="outlined"
|
|
632
|
+
color="primary"
|
|
633
|
+
value="second"
|
|
634
|
+
disabled
|
|
635
|
+
>
|
|
636
|
+
Text
|
|
637
|
+
</ToggleButton>
|
|
638
|
+
<ToggleButton {...args} kind="ghost" value="second" disabled>
|
|
639
|
+
Text
|
|
640
|
+
</ToggleButton>
|
|
641
|
+
</Box>
|
|
642
|
+
);
|
|
643
|
+
};
|
|
644
|
+
|
|
645
|
+
export const DisabledDocs = {
|
|
646
|
+
render: DisabledTemplate,
|
|
647
|
+
argTypes: {
|
|
648
|
+
selectedColor: {
|
|
649
|
+
control: false,
|
|
650
|
+
},
|
|
651
|
+
},
|
|
652
|
+
args: {
|
|
653
|
+
selected: false,
|
|
654
|
+
},
|
|
655
|
+
parameters: {
|
|
656
|
+
chromatic: { disableSnapshot: true },
|
|
657
|
+
},
|
|
658
|
+
};
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { Canvas, Stories, Controls, Meta, Story } from "@storybook/blocks";
|
|
2
|
+
import Box from "@mui/material/Box";
|
|
3
|
+
import Bell from "@lunit/design-system-icons/Bell";
|
|
4
|
+
|
|
5
|
+
import ToggleButton from "@/components/ToggleButton";
|
|
6
|
+
import * as ToggleButtonStories from "./Basic.stories";
|
|
7
|
+
import * as ToggleButtonKindStories from "./ToggleButtonKind.stories";
|
|
8
|
+
import * as ToggleButtonIconStories from "./WithIcon.stories";
|
|
9
|
+
|
|
10
|
+
<Meta name="Toggle Button Docs" of={ToggleButtonStories} />
|
|
11
|
+
|
|
12
|
+
# ToggleButton
|
|
13
|
+
|
|
14
|
+
A Toggle Button can be used to group related options.
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
### Basic ToggleButton
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import { ToggleButton } from "@lunit/design-system";
|
|
22
|
+
// or
|
|
23
|
+
import ToggleButton from "@lunit/design-system/ToggleButton";
|
|
24
|
+
|
|
25
|
+
<ToggleButton value="value">ToggleButton</ToggleButton>;
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Demo
|
|
29
|
+
|
|
30
|
+
<Canvas of={ToggleButtonStories.BasicToggleButton} sourceState="none" />
|
|
31
|
+
|
|
32
|
+
<Controls />
|
|
33
|
+
|
|
34
|
+
### Value
|
|
35
|
+
|
|
36
|
+
The value to associate with the button when selected in a ToggleButtonGroup.<br />
|
|
37
|
+
Value prop is `requried`.
|
|
38
|
+
|
|
39
|
+
<Canvas of={ToggleButtonStories.BasicToggleButton} sourceState="none" />
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
<ToggleButton value="value">Text</ToggleButton>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Kind
|
|
46
|
+
|
|
47
|
+
The ToggleButton has 3 kinds of variants: `contained`, `outlined` and `outlined`. <br />
|
|
48
|
+
Default kind is `contained`.
|
|
49
|
+
|
|
50
|
+
<Canvas
|
|
51
|
+
of={ToggleButtonKindStories.KindDocs}
|
|
52
|
+
meta={ToggleButtonKindStories}
|
|
53
|
+
sourceState="none"
|
|
54
|
+
/>
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
<ToggleButton value="first" kind="contained">Text</ToggleButton>
|
|
58
|
+
<ToggleButton value="secound" kind="outlined">Text</ToggleButton>
|
|
59
|
+
<ToggleButton value="thrid" kind="ghost">Text</ToggleButton>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Color
|
|
63
|
+
|
|
64
|
+
The ToggleButton has two colors: `primary` and `secondary`.<br />
|
|
65
|
+
Using the `color` prop, you can change the color of the ToggleButton.<br />
|
|
66
|
+
`outlined` kind does not have `secondary` color state.<br />
|
|
67
|
+
Default color is `primary`.
|
|
68
|
+
|
|
69
|
+
<Canvas of={ToggleButtonStories.Color} sourceState="none" />
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
// Contained
|
|
73
|
+
<ToggleButton value="first" kind="contained" color="primary">Primary</ToggleButton>
|
|
74
|
+
<ToggleButton value="second" kind="contained" color="secondary">Secondary</ToggleButton>
|
|
75
|
+
|
|
76
|
+
// Outlined
|
|
77
|
+
<ToggleButton value="first" kind="outlined" color="primary">Primary</ToggleButton>
|
|
78
|
+
|
|
79
|
+
// ghost
|
|
80
|
+
<ToggleButton value="first" kind="ghost" color="primary">Primary</ToggleButton>
|
|
81
|
+
<ToggleButton value="second" kind="ghost" color="secondary">Secondary</ToggleButton>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Selected
|
|
85
|
+
|
|
86
|
+
If true, the ToggleButton is rendered in an active state.<br />
|
|
87
|
+
Default Selected is `false`.
|
|
88
|
+
|
|
89
|
+
<Canvas of={ToggleButtonStories.SelectedDocs} sourceState="none" />
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
<ToggleButton selected={false} value="first">Not Selected</ToggleButton>
|
|
93
|
+
<ToggleButton selected={true} value="second">Selected</ToggleButton>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### SelectedColor
|
|
97
|
+
|
|
98
|
+
The ToggleButton has two selectedColor: `primary` and `secoundary`.<br />
|
|
99
|
+
Using the `color` prop, you can change the color of the ToggleButton.<br />
|
|
100
|
+
Default color is `primary`.
|
|
101
|
+
|
|
102
|
+
<Canvas of={ToggleButtonStories.SelectedColorDocs} sourceState="none" />
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
<ToggleButton value="first" selectedColor="primary" selected="true">Primary</ToggleButton>
|
|
106
|
+
<ToggleButton value="second" selectedColor="secondary" selected="true">Secondary</ToggleButton>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Size
|
|
110
|
+
|
|
111
|
+
The ToggleButton has three sizes: `small`, `medium` and `large`.<br />
|
|
112
|
+
Using the `size` prop, you can change the size of the ToggleButton.<br />
|
|
113
|
+
Default size is `small`.
|
|
114
|
+
|
|
115
|
+
<Canvas of={ToggleButtonStories.SizeDocs} sourceState="none" />
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
// Contained
|
|
119
|
+
<ToggleButton size="small" value="first" kind="contained">small</ToggleButton>
|
|
120
|
+
<ToggleButton size="medium" value="second" kind="contained">medium</ToggleButton>
|
|
121
|
+
<ToggleButton size="large" value="third" kind="contained">large</ToggleButton>
|
|
122
|
+
|
|
123
|
+
// Outlined
|
|
124
|
+
<ToggleButton size="small" value="first" kind="outlined">small</ToggleButton>
|
|
125
|
+
<ToggleButton size="medium" value="second" kind="outlined">medium</ToggleButton>
|
|
126
|
+
<ToggleButton size="large" value="third" kind="outlined">large</ToggleButton>
|
|
127
|
+
|
|
128
|
+
// ghost
|
|
129
|
+
<ToggleButton size="small" value="first" kind="ghost">small</ToggleButton>
|
|
130
|
+
<ToggleButton size="medium" value="second" kind="ghost">medium</ToggleButton>
|
|
131
|
+
<ToggleButton size="large" value="third" kind="ghost">large</ToggleButton>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### With Icon and Text
|
|
135
|
+
|
|
136
|
+
If you want to use an icon and text together, you can use the `icon` prop and `children` prop.
|
|
137
|
+
|
|
138
|
+
<Canvas of={ToggleButtonIconStories.IconDocs} sourceState="none" />
|
|
139
|
+
|
|
140
|
+
```tsx
|
|
141
|
+
<ToggleButton icon={<Bell />} value="first" kind="contained">Contained</ToggleButton>
|
|
142
|
+
<ToggleButton icon={<Bell />} value="secound" kind="outlined">Outlined</ToggleButton>
|
|
143
|
+
<ToggleButton icon={<Bell />} value="thrid" kind="ghost">Ghost</ToggleButton>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### With Icon only
|
|
147
|
+
|
|
148
|
+
If you want to use only an icon, you can use the `icon` prop.
|
|
149
|
+
|
|
150
|
+
<Canvas of={ToggleButtonIconStories.IconOnlyDocs} sourceState="none" />
|
|
151
|
+
|
|
152
|
+
```tsx
|
|
153
|
+
<ToggleButton icon={<Bell />} value="first" kind="contained" />
|
|
154
|
+
<ToggleButton icon={<Bell />} value="secound" kind="outlined" />
|
|
155
|
+
<ToggleButton icon={<Bell />} value="thrid" kind="ghost" />
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Disabled
|
|
159
|
+
|
|
160
|
+
If you want to disable the ToggleButton, you can use the `disabled` prop.<br />
|
|
161
|
+
Default disabled is `false`.
|
|
162
|
+
|
|
163
|
+
<Canvas of={ToggleButtonStories.DisabledDocs} sourceState="none" />
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
<ToggleButton disabled value="first" kind="contained" />
|
|
167
|
+
<ToggleButton disabled value="secound" kind="outlined" />
|
|
168
|
+
<ToggleButton disabled value="thrid" kind="ghost" />
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Reference
|
|
172
|
+
|
|
173
|
+
- [Material-UI ToggleButton](https://mui.com/material-ui/react-toggle-button/)
|
|
174
|
+
- [Material-UI ToggleButton API](https://mui.com/material-ui/api/toggle-button/)
|
|
175
|
+
- [Lunit Design System ToggleButton Figma](https://www.figma.com/file/cvCwvrIV9Xo1iOLcbvD904/old_Components_Lunit-Design?type=design&node-id=284-3&mode=design&t=FaggRMVgOmnJveHg-0)
|
|
176
|
+
|
|
177
|
+
## Support
|
|
178
|
+
|
|
179
|
+
- Github: [Create a new issue](https://github.com/lunit-io/design-system/issues/new)
|
|
180
|
+
- Slack: #tf_design_system
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
2
|
import {
|
|
3
|
+
Box,
|
|
3
4
|
Table,
|
|
4
5
|
TableHead,
|
|
5
6
|
TableRow,
|
|
@@ -236,6 +237,70 @@ export const Kind = {
|
|
|
236
237
|
},
|
|
237
238
|
};
|
|
238
239
|
|
|
240
|
+
const ToggleButtonDocsTemplate: StoryFn<typeof ToggleButton> = ({
|
|
241
|
+
kind,
|
|
242
|
+
color,
|
|
243
|
+
children,
|
|
244
|
+
...restProps
|
|
245
|
+
}) => {
|
|
246
|
+
const [values, setValues] = useState({
|
|
247
|
+
contained: false,
|
|
248
|
+
outlined: false,
|
|
249
|
+
ghost: false,
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
const handleChange = (value: keyof typeof values) => {
|
|
253
|
+
setValues({ ...values, [value]: !values[value] });
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
return (
|
|
257
|
+
<Box
|
|
258
|
+
sx={{
|
|
259
|
+
"& button": {
|
|
260
|
+
marginRight: "7px",
|
|
261
|
+
},
|
|
262
|
+
}}
|
|
263
|
+
>
|
|
264
|
+
<ToggleButton
|
|
265
|
+
color={color}
|
|
266
|
+
{...restProps}
|
|
267
|
+
value="contained"
|
|
268
|
+
onChange={() => handleChange("contained")}
|
|
269
|
+
selected={values.contained}
|
|
270
|
+
>
|
|
271
|
+
{children}
|
|
272
|
+
</ToggleButton>
|
|
273
|
+
<ToggleButton
|
|
274
|
+
kind="outlined"
|
|
275
|
+
color="primary"
|
|
276
|
+
{...restProps}
|
|
277
|
+
value="outlined"
|
|
278
|
+
onChange={() => handleChange("outlined")}
|
|
279
|
+
selected={values.outlined}
|
|
280
|
+
>
|
|
281
|
+
{children}
|
|
282
|
+
</ToggleButton>
|
|
283
|
+
<ToggleButton
|
|
284
|
+
kind="ghost"
|
|
285
|
+
color={color}
|
|
286
|
+
{...restProps}
|
|
287
|
+
value="ghost"
|
|
288
|
+
onChange={() => handleChange("ghost")}
|
|
289
|
+
selected={values.ghost}
|
|
290
|
+
>
|
|
291
|
+
{children}
|
|
292
|
+
</ToggleButton>
|
|
293
|
+
</Box>
|
|
294
|
+
);
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
export const KindDocs = {
|
|
298
|
+
render: ToggleButtonDocsTemplate,
|
|
299
|
+
parameters: {
|
|
300
|
+
chromatic: { disableSnapshot: true },
|
|
301
|
+
},
|
|
302
|
+
};
|
|
303
|
+
|
|
239
304
|
const ContainedTemplate: StoryFn<typeof ToggleButton> = (args) => {
|
|
240
305
|
const [values, setValues] = useState({
|
|
241
306
|
primary: {
|