|
1
|
import type { Meta, StoryObj } from "@storybook/react" |
|
2
|
import * as React from "react" |
|
3
|
|
|
4
|
import { Label } from "@/components/label" |
|
5
|
import { Text } from "@/components/text" |
|
6
|
import { RadioGroup } from "./radio-group" |
|
7
|
|
|
8
|
const meta: Meta<typeof RadioGroup> = { |
|
9
|
title: "Components/RadioGroup", |
|
10
|
component: RadioGroup, |
|
11
|
parameters: { |
|
12
|
layout: "centered", |
|
13
|
}, |
|
14
|
} |
|
15
|
|
|
16
|
export default meta |
|
17
|
|
|
18
|
type Story = StoryObj<typeof RadioGroup> |
|
19
|
|
|
20
|
export const Default: Story = { |
|
21
|
render: () => { |
|
22
|
return ( |
|
23
|
<RadioGroup> |
|
24
|
<RadioGroup.Item value="1" /> |
|
25
|
<RadioGroup.Item value="2" /> |
|
26
|
<RadioGroup.Item value="3" /> |
|
27
|
</RadioGroup> |
|
28
|
) |
|
29
|
}, |
|
30
|
} |
|
31
|
|
|
32
|
export const WithLabel: Story = { |
|
33
|
render: () => { |
|
34
|
return ( |
|
35
|
<RadioGroup> |
|
36
|
<div className="flex items-center gap-x-3"> |
|
37
|
<RadioGroup.Item value="1" id="radio_1" /> |
|
38
|
<Label htmlFor="radio_1" weight="plus"> |
|
39
|
Radio 1 |
|
40
|
</Label> |
|
41
|
</div> |
|
42
|
<div className="flex items-center gap-x-3"> |
|
43
|
<RadioGroup.Item value="2" id="radio_2" /> |
|
44
|
<Label htmlFor="radio_2" weight="plus"> |
|
45
|
Radio 2 |
|
46
|
</Label> |
|
47
|
</div> |
|
48
|
<div className="flex items-center gap-x-3"> |
|
49
|
<RadioGroup.Item value="3" id="radio_3" /> |
|
50
|
<Label htmlFor="radio_3" weight="plus"> |
|
51
|
Radio 3 |
|
52
|
</Label> |
|
53
|
</div> |
|
54
|
</RadioGroup> |
|
55
|
) |
|
56
|
}, |
|
57
|
} |
|
58
|
|
|
59
|
export const WithLabelAndDescription: Story = { |
|
60
|
render: () => { |
|
61
|
return ( |
|
62
|
<RadioGroup> |
|
63
|
<div className="flex items-start gap-x-3"> |
|
64
|
<RadioGroup.Item value="1" id="radio_1" /> |
|
65
|
<div className="flex flex-col gap-y-0.5"> |
|
66
|
<Label htmlFor="radio_1" weight="plus"> |
|
67
|
Radio 1 |
|
68
|
</Label> |
|
69
|
<Text className="text-ui-fg-subtle"> |
|
70
|
The quick brown fox jumps over a lazy dog. |
|
71
|
</Text> |
|
72
|
</div> |
|
73
|
</div> |
|
74
|
<div className="flex items-start gap-x-3"> |
|
75
|
<RadioGroup.Item value="2" id="radio_2" /> |
|
76
|
<div className="flex flex-col gap-y-0.5"> |
|
77
|
<Label htmlFor="radio_2" weight="plus"> |
|
78
|
Radio 2 |
|
79
|
</Label> |
|
80
|
<Text className="text-ui-fg-subtle"> |
|
81
|
The quick brown fox jumps over a lazy dog. |
|
82
|
</Text> |
|
83
|
</div> |
|
84
|
</div> |
|
85
|
<div className="flex items-start gap-x-3"> |
|
86
|
<RadioGroup.Item value="3" id="radio_3" /> |
|
87
|
<div className="flex flex-col gap-y-0.5"> |
|
88
|
<Label htmlFor="radio_3" weight="plus"> |
|
89
|
Radio 3 |
|
90
|
</Label> |
|
91
|
<Text className="text-ui-fg-subtle"> |
|
92
|
The quick brown fox jumps over a lazy dog. |
|
93
|
</Text> |
|
94
|
</div> |
|
95
|
</div> |
|
96
|
</RadioGroup> |
|
97
|
) |
|
98
|
}, |
|
99
|
} |
|
100
|
|
|
101
|
export const Disabled: Story = { |
|
102
|
render: () => { |
|
103
|
return ( |
|
104
|
<RadioGroup> |
|
105
|
<RadioGroup.Item value="1" disabled /> |
|
106
|
<RadioGroup.Item value="2" /> |
|
107
|
<RadioGroup.Item value="3" disabled checked /> |
|
108
|
</RadioGroup> |
|
109
|
) |
|
110
|
}, |
|
111
|
} |
|
112
|
|
|
113
|
export const ChoiceBox: Story = { |
|
114
|
render: () => { |
|
115
|
return ( |
|
116
|
<RadioGroup> |
|
117
|
<RadioGroup.ChoiceBox |
|
118
|
value="1" |
|
119
|
label="One" |
|
120
|
description="The quick brown fox jumps over a lazy dog." |
|
121
|
/> |
|
122
|
<RadioGroup.ChoiceBox |
|
123
|
value="2" |
|
124
|
label="Two" |
|
125
|
description="The quick brown fox jumps over a lazy dog." |
|
126
|
/> |
|
127
|
<RadioGroup.ChoiceBox |
|
128
|
value="3" |
|
129
|
label="Three" |
|
130
|
description="The quick brown fox jumps over a lazy dog." |
|
131
|
disabled |
|
132
|
/> |
|
133
|
</RadioGroup> |
|
134
|
) |
|
135
|
}, |
|
136
|
} |
|
137
|
|
|
138
|
export const ChoiceBoxDisabledSelected: Story = { |
|
139
|
render: () => { |
|
140
|
return ( |
|
141
|
<RadioGroup defaultValue={"3"}> |
|
142
|
<RadioGroup.ChoiceBox |
|
143
|
value="1" |
|
144
|
label="One" |
|
145
|
description="The quick brown fox jumps over a lazy dog." |
|
146
|
/> |
|
147
|
<RadioGroup.ChoiceBox |
|
148
|
value="2" |
|
149
|
label="Two" |
|
150
|
description="The quick brown fox jumps over a lazy dog." |
|
151
|
/> |
|
152
|
<RadioGroup.ChoiceBox |
|
153
|
value="3" |
|
154
|
label="Three" |
|
155
|
description="The quick brown fox jumps over a lazy dog." |
|
156
|
disabled |
|
157
|
/> |
|
158
|
</RadioGroup> |
|
159
|
) |
|
160
|
}, |
|
161
|
} |