/
Switch.story.tsx
110 lines (100 loc) · 2.94 KB
/
Switch.story.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
import React from 'react';
import { MantineProvider } from '@mantine/styles';
import { IconBadge } from '@tabler/icons';
import { Group } from '../Group';
import { Switch } from './Switch';
import { Stack } from '../Stack';
export default { title: 'Switch' };
export function CursorPointer() {
return (
<MantineProvider theme={{ cursorType: 'pointer' }}>
<Switch label="Hello" value="1" />
</MantineProvider>
);
}
export function WithLabels() {
return (
<Group m={4}>
<Switch size="lg" onLabel={<span>1</span>} offLabel="0" />
<Switch size="md" onLabel={<span>1</span>} offLabel="0" />
<Switch size="sm" onLabel={<span>1</span>} offLabel="0" />
<Switch size="xs" onLabel={<span>1</span>} offLabel="0" />
</Group>
);
}
export function IconInsideThumb() {
return <Switch size="lg" thumbIcon={<IconBadge color="black" size={12} />} label="Hello" />;
}
export function SwitchGroup() {
return (
<>
<Switch.Group defaultValue={['one', 'three']} m={4} label="Switch Group">
<Switch value="one" size="md" />
<Switch value="two" size="md" />
<Switch value="three" size="md" />
<Switch value="four" size="md" />
</Switch.Group>
</>
);
}
export function Asterisk() {
return (
<div style={{ width: 300, padding: 20 }}>
<Switch.Group label="With required asterisk" withAsterisk>
<Switch value="1" />
</Switch.Group>
<Switch.Group label="Just required" required>
<Switch value="1" />
</Switch.Group>
<Switch.Group label="Required asterisk off" required withAsterisk={false}>
<Switch value="1" />
</Switch.Group>
<Switch.Group label="Required false asterisk on" required={false} withAsterisk>
<Switch value="1" />
</Switch.Group>
</div>
);
}
export function labelPosition() {
return (
<Stack sx={{ width: 300, padding: 20 }}>
<Switch labelPosition="left" label="Hello from left" value="1" />
<Switch labelPosition="right" label="Hello from right" value="1" />
</Stack>
);
}
export function WithDesciprtion() {
return (
<Stack sx={{ width: 300, padding: 20 }}>
<Switch
description="This is left Checkbox, pretty big descriptions, make it more big"
labelPosition="left"
label="Hello from left"
value="1"
/>
<Switch
description="This is right Checkbox, pretty big description"
labelPosition="right"
label="Hello from right"
value="1"
/>
</Stack>
);
}
export function WithError() {
return (
<Stack sx={{ width: 300, padding: 20 }}>
<Switch label="Error without message" value="1" error />
<Switch
error="This is another error"
labelPosition="right"
label="This is invalid Switch"
value="1"
/>
<Switch error="Error on Switch without label" value="1" />
</Stack>
);
}
export function Alignment() {
return <Switch />;
}