forked from learningequality/kolibri-design-system
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kradiobutton.vue
195 lines (174 loc) · 5.86 KB
/
kradiobutton.vue
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
<template>
<DocsPageTemplate apiDocs>
<DocsPageSection title="Overview" anchor="#overview">
<p>A radio button is used to make a single selection from a group of options. Radio buttons should be used instead of checkboxes if only one option can be selected.</p>
<p><code>KRadioButton</code>'s are always be wrapped in <DocsLibraryLink component="KRadioButtonGroup" />.</p>
</DocsPageSection>
<DocsPageSection title="Usage" anchor="#usage">
<DocsShow>
<KRadioButtonGroup>
<KRadioButton
v-model="exampleValue"
label="Option A"
buttonValue="val-a"
/>
<KRadioButton
v-model="exampleValue"
label="Option B"
buttonValue="val-b"
/>
<KRadioButton
v-model="exampleValue"
label="Option C"
description="This one is special!"
buttonValue="val-c"
/>
<KRadioButton
v-model="exampleValue"
label="Truncated label. Adjusting your browser window size to see this in action."
buttonValue="val-d"
truncateLabel
/>
</KRadioButtonGroup>
<p>
Current value: {{ exampleValue }}
</p>
</DocsShow>
<DocsShowCode language="html">
<KRadioButtonGroup>
<KRadioButton
v-model="exampleValue"
label="Option A"
buttonValue="val-a"
/>
<KRadioButton
v-model="exampleValue"
label="Option B"
butonValue="val-b"
/>
<KRadioButton
v-model="exampleValue"
label="Option C"
description="This one is special!"
buttonValue="val-c"
/>
<KRadioButton
v-model="exampleValue"
label="Truncated label. Adjusting your browser window size to see this in action."
buttonValue="val-d"
truncateLabel
/>
</KRadioButtonGroup>
</DocsShowCode>
<h3>With grid layout</h3>
<p>It is possible to use radio buttons together with grid layout components such as <DocsLibraryLink component="KGrid" /> or <DocsLibraryLink component="KFixedGrid" />. For example: </p>
<DocsShow>
<KRadioButtonGroup>
<KFixedGrid :numCols="2">
<KFixedGridItem :span="1">
<KRadioButton
v-model="exampleValue"
label="Option A"
buttonValue="val-a"
/>
<KRadioButton
v-model="exampleValue"
label="Option B"
buttonValue="val-b"
/>
</KFixedGridItem>
<KFixedGridItem :span="1">
<KRadioButton
v-model="exampleValue"
label="Option C"
description="This one is special!"
buttonValue="val-c"
/>
<KRadioButton
v-model="exampleValue"
label="Truncated label. Adjusting your browser window size to see this in action."
buttonValue="val-d"
truncateLabel
/>
</KFixedGridItem>
</KFixedGrid>
</KRadioButtonGroup>
<p>
Current value: {{ exampleValue }}
</p>
</DocsShow>
<DocsShowCode language="html">
<KRadioButtonGroup>
<KFixedGrid :numCols="2">
<KFixedGridItem :span="1">
<KRadioButton
v-model="exampleValue"
label="Option A"
buttonValue="val-a"
/>
<KRadioButton
v-model="exampleValue"
label="Option B"
buttonValue="val-b"
/>
</KFixedGridItem>
<KFixedGridItem :span="1">
<KRadioButton
v-model="exampleValue"
label="Option C"
description="This one is special!"
buttonValue="val-c"
/>
<KRadioButton
v-model="exampleValue"
label="Truncated label. Adjusting your browser window size to see this in action."
buttonValue="val-d"
truncateLabel
/>
</KFixedGridItem>
</KFixedGrid>
</KRadioButtonGroup>
</DocsShowCode>
</DocsPageSection>
<DocsPageSection title="Layout" anchor="#layout">
<ul>
<li>Align with container margin</li>
<li>Stack vertically in lists</li>
<li>
Avoid nesting radio buttons
</li>
</ul>
</DocsPageSection>
<DocsPageSection title="Label" anchor="#label">
<ul>
<li>Labels should be short and concise</li>
<li>Labels should be positioned above the radio button group</li>
</ul>
</DocsPageSection>
<DocsPageSection title="Guidelines" anchor="#guidelines">
<ul>
<li>Always wrap <code>KRadioButton</code> group in <DocsLibraryLink component="KRadioButtonGroup" /></li>
<li>There must always be exactly one radio button selected within a group</li>
<li>If the user is allowed to not select any of the options, provide a "None" option</li>
<li>By default, the first radio option is selected, but may be configured to have any option preselected</li>
</ul>
</DocsPageSection>
<DocsPageSection title="Related" anchor="#related">
<ul>
<li>
<DocsLibraryLink component="KRadioButtonGroup" /> ensures <code>KRadioButton</code> groups are accessible in all supported browsers.
</li>
</ul>
</DocsPageSection>
</DocsPageTemplate>
</template>
<script>
export default {
data() {
return {
exampleValue: 'val-b',
};
},
};
</script>
<style lang="scss" scoped></style>