@designil/labdsnov 1.0.0 → 1.1.0

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.
Files changed (99) hide show
  1. package/README.md +18 -1
  2. package/dist/components/Accordion/Accordion.module.css.js +10 -10
  3. package/dist/components/Alert/Alert.module.css.js +10 -10
  4. package/dist/components/AlertDialog/AlertDialog.module.css.js +16 -16
  5. package/dist/components/Avatar/Avatar.module.css.js +18 -18
  6. package/dist/components/Badge/Badge.module.css.js +6 -6
  7. package/dist/components/Breadcrumb/Breadcrumb.module.css.js +14 -14
  8. package/dist/components/Button/Button.module.css.js +26 -26
  9. package/dist/components/ButtonGroup/ButtonGroup.module.css.js +2 -2
  10. package/dist/components/Calendar/Calendar.module.css.js +33 -33
  11. package/dist/components/Card/Card.module.css.js +20 -20
  12. package/dist/components/Chart/Chart.module.css.js +32 -32
  13. package/dist/components/Checkbox/Checkbox.module.css.js +10 -10
  14. package/dist/components/Collapsible/Collapsible.module.css.js +1 -1
  15. package/dist/components/Combobox/Combobox.module.css.js +32 -32
  16. package/dist/components/DatePicker/DatePicker.module.css.js +4 -4
  17. package/dist/components/Dialog/Dialog.module.css.js +13 -13
  18. package/dist/components/Drawer/Drawer.module.css.js +18 -18
  19. package/dist/components/DropdownMenu/DropdownMenu.module.css.js +24 -24
  20. package/dist/components/Empty/Empty.module.css.js +11 -11
  21. package/dist/components/Field/Field.module.css.js +25 -25
  22. package/dist/components/FundCard/FundCard.module.css.js +14 -14
  23. package/dist/components/HoverCard/HoverCard.module.css.js +5 -5
  24. package/dist/components/Input/Input.module.css.js +2 -2
  25. package/dist/components/InputGroup/InputGroup.module.css.js +16 -16
  26. package/dist/components/InputOTP/InputOTP.module.css.js +16 -16
  27. package/dist/components/Kbd/Kbd.module.css.js +1 -1
  28. package/dist/components/Label/Label.module.css.js +6 -6
  29. package/dist/components/NavigationMenu/NavigationMenu.module.css.js +24 -24
  30. package/dist/components/Pagination/Pagination.module.css.js +10 -10
  31. package/dist/components/Popover/Popover.module.css.js +10 -10
  32. package/dist/components/Progress/Progress.module.css.js +12 -12
  33. package/dist/components/RadioGroup/RadioGroup.module.css.js +8 -8
  34. package/dist/components/ScrollArea/ScrollArea.module.css.js +5 -5
  35. package/dist/components/Select/Select.module.css.js +34 -34
  36. package/dist/components/Separator/Separator.module.css.js +1 -1
  37. package/dist/components/Skeleton/Skeleton.module.css.js +1 -1
  38. package/dist/components/Slider/Slider.module.css.js +12 -12
  39. package/dist/components/Spinner/Spinner.module.css.js +1 -1
  40. package/dist/components/Switch/Switch.module.css.js +6 -6
  41. package/dist/components/Table/Table.module.css.js +8 -8
  42. package/dist/components/Tabs/Tabs.module.css.js +8 -8
  43. package/dist/components/Textarea/Textarea.module.css.js +1 -1
  44. package/dist/components/Toaster/Toaster.module.css.js +8 -8
  45. package/dist/components/Toggle/Toggle.module.css.js +8 -8
  46. package/dist/components/ToggleGroup/ToggleGroup.module.css.js +3 -3
  47. package/dist/components/Tooltip/Tooltip.module.css.js +5 -5
  48. package/dist/styles.css +1 -1
  49. package/docs/Colors.md +96 -43
  50. package/docs/Contributing.md +14 -7
  51. package/package.json +21 -13
  52. package/src/components/Accordion/Accordion.dsds.yaml +195 -0
  53. package/src/components/Alert/Alert.dsds.yaml +206 -0
  54. package/src/components/AlertDialog/AlertDialog.dsds.yaml +243 -0
  55. package/src/components/Avatar/Avatar.dsds.yaml +172 -0
  56. package/src/components/Badge/Badge.dsds.yaml +191 -0
  57. package/src/components/Breadcrumb/Breadcrumb.dsds.yaml +162 -0
  58. package/src/components/Button/Button.dsds.yaml +350 -0
  59. package/src/components/ButtonGroup/ButtonGroup.dsds.yaml +193 -0
  60. package/src/components/Calendar/Calendar.dsds.yaml +236 -0
  61. package/src/components/Card/Card.dsds.yaml +199 -0
  62. package/src/components/Chart/Chart.dsds.yaml +216 -0
  63. package/src/components/Checkbox/Checkbox.dsds.yaml +215 -0
  64. package/src/components/Collapsible/Collapsible.dsds.yaml +146 -0
  65. package/src/components/Combobox/Combobox.dsds.yaml +241 -0
  66. package/src/components/DatePicker/DatePicker.dsds.yaml +179 -0
  67. package/src/components/Dialog/Dialog.dsds.yaml +300 -0
  68. package/src/components/Drawer/Drawer.dsds.yaml +207 -0
  69. package/src/components/DropdownMenu/DropdownMenu.dsds.yaml +265 -0
  70. package/src/components/Empty/Empty.dsds.yaml +171 -0
  71. package/src/components/Field/Field.dsds.yaml +285 -0
  72. package/src/components/FundCard/FundCard.dsds.yaml +195 -0
  73. package/src/components/FundCard/FundCard.md +2 -2
  74. package/src/components/HoverCard/HoverCard.dsds.yaml +157 -0
  75. package/src/components/Input/Input.dsds.yaml +235 -0
  76. package/src/components/InputGroup/InputGroup.dsds.yaml +234 -0
  77. package/src/components/InputOTP/InputOTP.dsds.yaml +184 -0
  78. package/src/components/Kbd/Kbd.dsds.yaml +119 -0
  79. package/src/components/Label/Label.dsds.yaml +141 -0
  80. package/src/components/NavigationMenu/NavigationMenu.dsds.yaml +196 -0
  81. package/src/components/Pagination/Pagination.dsds.yaml +172 -0
  82. package/src/components/Popover/Popover.dsds.yaml +168 -0
  83. package/src/components/Progress/Progress.dsds.yaml +169 -0
  84. package/src/components/RadioGroup/RadioGroup.dsds.yaml +215 -0
  85. package/src/components/ScrollArea/ScrollArea.dsds.yaml +153 -0
  86. package/src/components/Select/Select.dsds.yaml +239 -0
  87. package/src/components/Separator/Separator.dsds.yaml +121 -0
  88. package/src/components/Skeleton/Skeleton.dsds.yaml +124 -0
  89. package/src/components/Slider/Slider.dsds.yaml +194 -0
  90. package/src/components/Spinner/Spinner.dsds.yaml +126 -0
  91. package/src/components/Switch/Switch.dsds.yaml +198 -0
  92. package/src/components/Table/Table.dsds.yaml +195 -0
  93. package/src/components/Tabs/Tabs.dsds.yaml +239 -0
  94. package/src/components/Textarea/Textarea.dsds.yaml +167 -0
  95. package/src/components/Toaster/Toaster.dsds.yaml +226 -0
  96. package/src/components/Toggle/Toggle.dsds.yaml +224 -0
  97. package/src/components/ToggleGroup/ToggleGroup.dsds.yaml +230 -0
  98. package/src/components/Tooltip/Tooltip.dsds.yaml +202 -0
  99. package/src/index.dsds.yaml +467 -0
@@ -0,0 +1,239 @@
1
+ kind: component
2
+ id: select
3
+ name: Select
4
+ description: >-
5
+ A button that opens a list for picking one value, when there are too many options
6
+ to show them all on the page. Looks like and is as tall as Input `filled`. Wraps
7
+ Base UI `Select`.
8
+ metadata:
9
+ status: {status: stable}
10
+ since: 1.0.0
11
+ tags: [form, selection]
12
+
13
+ sections:
14
+ - kind: guidelines
15
+ for: all
16
+ framing: when-to-use
17
+ items:
18
+ - level: should
19
+ statement: >-
20
+ Use to pick one value from a list of about 6 or more options, e.g. state,
21
+ country, asset.
22
+ - level: should-not
23
+ statement: >-
24
+ Don't use for 2–5 options the user should see at once. Use <dsds:radio-group>.
25
+ alternatives:
26
+ - to: radio-group
27
+ - level: should-not
28
+ statement: >-
29
+ Don't use for very long lists the user needs to search. Use <dsds:combobox>.
30
+ alternatives:
31
+ - to: combobox
32
+ - level: must-not
33
+ statement: >-
34
+ Never use as a command menu (edit / delete). Use <dsds:dropdown-menu>.
35
+ alternatives:
36
+ - to: dropdown-menu
37
+ checkedBy: manual
38
+ - level: must-not
39
+ statement: >-
40
+ Never use three Selects (day / month / year) to pick a date. Use
41
+ <dsds:date-picker>.
42
+ alternatives:
43
+ - to: date-picker
44
+ checkedBy: manual
45
+
46
+ - kind: guidelines
47
+ for: all
48
+ items:
49
+ - id: items-required
50
+ level: must
51
+ statement: >-
52
+ Always pass `items` to `Select` (an object `{ value: label }` or an array of
53
+ `{ value, label }`). Without it the button shows the raw value, e.g. "nsw"
54
+ instead of "นิวเซาท์เวลส์".
55
+ checks:
56
+ - href: ./Select.stories.tsx#Choosing
57
+ role: test
58
+ note: play function checks the button shows "ควีนส์แลนด์" after choosing
59
+ checkedBy: automated
60
+ - id: placeholder-verb
61
+ level: should
62
+ statement: >-
63
+ Start the `SelectValue placeholder` with "เลือก…" (choose…), e.g. "เลือกรัฐ",
64
+ rather than repeating the label word for word.
65
+ checkedBy: manual
66
+ - id: full-width-in-form
67
+ level: should
68
+ statement: >-
69
+ The button is as wide as its content. In forms, put `className="w-full"` on
70
+ `SelectTrigger`.
71
+ checkedBy: manual
72
+ - id: size-matches-row
73
+ level: should
74
+ statement: >-
75
+ Use `SelectTrigger size="sm"` (32px) next to `sm` buttons in toolbars. In forms
76
+ use `default` (36px) so it matches Input height.
77
+ checkedBy: manual
78
+ - id: groups-with-labels
79
+ level: may
80
+ statement: >-
81
+ Group options with `SelectGroup` + `SelectLabel` and `SelectSeparator`, e.g.
82
+ low-risk / high-risk assets.
83
+ example:
84
+ ref:
85
+ href: ./Select.stories.tsx#Groups
86
+ rel: demo
87
+ - id: multiple-untested
88
+ level: should-not
89
+ statement: >-
90
+ Don't use `multiple` until it has an example and its look is checked. Use the
91
+ chips mode of <dsds:combobox> instead.
92
+ alternatives:
93
+ - to: combobox
94
+
95
+ - kind: guidelines
96
+ for: all
97
+ title: Accessibility
98
+ tags: [accessibility]
99
+ items:
100
+ - id: trigger-labelled
101
+ level: must
102
+ statement: >-
103
+ Put an `id` on `SelectTrigger` and tie it to `<Label htmlFor>`, or put
104
+ `aria-label` on the trigger when there is no visible label.
105
+ evidence:
106
+ - href: https://www.w3.org/WAI/WCAG22/Understanding/labels-or-instructions.html
107
+ role: WCAG 2.2 SC 3.3.2 (A)
108
+ uses:
109
+ - to: label
110
+ checkedBy: manual
111
+ - id: invalid-trigger
112
+ level: must
113
+ statement: >-
114
+ For an invalid value, put `aria-invalid` on `SelectTrigger` together with a
115
+ `FieldError`.
116
+ refines:
117
+ - to: shared-a11y#invalid-has-message
118
+ checkedBy: manual
119
+ - id: keyboard-select
120
+ level: must
121
+ statement: >-
122
+ Enter, Space or the arrows open the list; arrows move, Enter chooses, Escape
123
+ closes, and typing a letter jumps to the option starting with it.
124
+ evidence:
125
+ - href: https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/
126
+ role: WAI-ARIA APG Select-Only Combobox
127
+ checkedBy: manual
128
+
129
+ - kind: guidelines
130
+ for: agent
131
+ items:
132
+ - refs:
133
+ - to: shared-testing#assert-by-state
134
+ rel: same-as
135
+ - refs:
136
+ - to: shared-testing#query-portal-with-screen
137
+ rel: same-as
138
+
139
+ - kind: definitions
140
+ for: all
141
+ context: anatomy
142
+ items:
143
+ - term: Select
144
+ definition: >-
145
+ Root. Takes `items`, `defaultValue`, `value` / `onValueChange`, `multiple`,
146
+ `disabled`, `required`, `name`.
147
+ - term: SelectTrigger + SelectValue
148
+ definition: >-
149
+ The button showing the chosen value or the placeholder. `SelectTrigger` takes
150
+ `size` and `aria-invalid`.
151
+ - term: SelectContent
152
+ definition: >-
153
+ The list (portalled). Takes `side`, `align` and `alignItemWithTrigger` (default
154
+ `true`: the list opens over the button so the current option lines up with it).
155
+ - term: SelectItem
156
+ definition: >-
157
+ An option. Takes `value` (required) and `disabled`. The chosen one has a check
158
+ mark on the right.
159
+ - term: SelectGroup / SelectLabel / SelectSeparator
160
+ definition: >-
161
+ Group options.
162
+
163
+ - kind: section
164
+ for: all
165
+ title: Open decisions
166
+ freeform:
167
+ - title: TODO
168
+ body: >-
169
+ `multiple` has no example yet and its look hasn't been checked.
170
+
171
+ sourceFiles:
172
+ - platform: react
173
+ file: ./Select.tsx
174
+
175
+ imports:
176
+ - platform: react
177
+ code: >-
178
+ import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue } from "@designil/labdsnov"
179
+ package: "@designil/labdsnov"
180
+
181
+ traits:
182
+ - traitType: variant
183
+ kind: enum
184
+ id: triggerSize
185
+ name: SelectTrigger size
186
+ description: >-
187
+ The `size` prop of `SelectTrigger`.
188
+ values:
189
+ - id: default
190
+ description: >-
191
+ 36px high, same as Input.
192
+ - id: sm
193
+ description: >-
194
+ 32px high.
195
+ - traitType: state
196
+ kind: boolean
197
+ id: disabled
198
+ description: >-
199
+ Disabled, 50% opacity.
200
+ - traitType: state
201
+ kind: boolean
202
+ id: aria-invalid
203
+ name: Invalid
204
+ description: >-
205
+ On `SelectTrigger`: red border and faint red ring.
206
+ - traitType: state
207
+ kind: boolean
208
+ id: open
209
+ description: >-
210
+ The list is open.
211
+
212
+ uses:
213
+ - to: label
214
+ alternatives:
215
+ - to: radio-group
216
+ - to: combobox
217
+ - to: dropdown-menu
218
+
219
+ refs:
220
+ - href: ./Select.md
221
+ rel: relates-to
222
+ role: Thai usage doc
223
+ - href: ./Select.stories.tsx
224
+ rel: demo
225
+ role: CSF stories
226
+ - href: https://www.figma.com/design/QsKWb3A53lIh4QBDnAkGHh/labdsnov?node-id=10-114
227
+ rel: design
228
+ role: Select in Figma
229
+ - href: https://www.figma.com/design/QsKWb3A53lIh4QBDnAkGHh/labdsnov?node-id=10-131
230
+ rel: design
231
+ role: Select Item in Figma
232
+ - href: ../../../figma/Select.figma.ts
233
+ rel: source
234
+ role: Code Connect template
235
+
236
+ $extensions:
237
+ com.figma:
238
+ nodeId: "10:114"
239
+ itemNodeId: "10:131"
@@ -0,0 +1,121 @@
1
+ kind: component
2
+ id: separator
3
+ name: Separator
4
+ description: >-
5
+ A thin 1px line between groups of content, horizontal or vertical. Uses `--border`
6
+ (a decorative edge, so it doesn't need 3:1). Wraps Base UI `Separator`.
7
+ metadata:
8
+ status: {status: stable}
9
+ since: 1.0.0
10
+ tags: [layout]
11
+
12
+ sections:
13
+ - kind: guidelines
14
+ for: all
15
+ framing: when-to-use
16
+ items:
17
+ - level: should
18
+ statement: >-
19
+ Use to divide content inside a card or menu when spacing alone isn't enough.
20
+ - level: should
21
+ statement: >-
22
+ Use `orientation="vertical"` between short links or data on one row.
23
+ example:
24
+ ref:
25
+ href: ./Separator.stories.tsx#Vertical
26
+ rel: demo
27
+ - level: should-not
28
+ statement: >-
29
+ Don't use to divide major sections of a page. Use headings and spacing.
30
+ - level: must-not
31
+ statement: >-
32
+ Never use inside a form (e.g. "หรือ" (or) between options): use `FieldSeparator`
33
+ from <dsds:field>. Never use inside Select / DropdownMenu lists: use
34
+ `SelectSeparator` / `DropdownMenuSeparator`.
35
+ alternatives:
36
+ - to: field
37
+ - to: select
38
+ - to: dropdown-menu
39
+ checkedBy: manual
40
+
41
+ - kind: guidelines
42
+ for: all
43
+ items:
44
+ - id: vertical-needs-height
45
+ level: must
46
+ statement: >-
47
+ Put a vertical line in a flex row that has a height (`flex h-5 items-center`).
48
+ The line is as tall as the row; if the row has no height, the line disappears.
49
+ checkedBy: manual
50
+ - id: spacing-by-classname
51
+ level: should
52
+ statement: >-
53
+ Set the space around the line with `className` (`my-4` horizontal, the row's
54
+ `gap-4` for vertical).
55
+ checkedBy: manual
56
+ - id: card-border-instead
57
+ level: should
58
+ statement: >-
59
+ For a line under a <dsds:card> header or above its footer, use `border-b` /
60
+ `border-t` on CardHeader / CardFooter instead of a Separator.
61
+ refs:
62
+ - to: card#separators-by-class
63
+ rel: relates-to
64
+ checkedBy: manual
65
+
66
+ - kind: guidelines
67
+ for: all
68
+ title: Accessibility
69
+ tags: [accessibility]
70
+ items:
71
+ - id: role-separator
72
+ level: should
73
+ statement: >-
74
+ The line is announced as a `separator` with `aria-orientation`. Purely decorative
75
+ lines between links on a row may make screen readers say "separator" over and
76
+ over (whether to hide them is undecided, see Open decisions).
77
+ checks:
78
+ - href: ./Separator.stories.tsx#Playground
79
+ role: test
80
+ note: play function checks aria-orientation="horizontal"
81
+ checkedBy: assisted
82
+
83
+ - kind: section
84
+ for: all
85
+ title: Open decisions
86
+ freeform:
87
+ - title: TODO
88
+ body: >-
89
+ Not decided whether decorative separators should be hidden from screen readers.
90
+
91
+ sourceFiles:
92
+ - platform: react
93
+ file: ./Separator.tsx
94
+
95
+ imports:
96
+ - platform: react
97
+ code: >-
98
+ import { Separator } from "@designil/labdsnov"
99
+ package: "@designil/labdsnov"
100
+
101
+ traits:
102
+ - traitType: variant
103
+ kind: enum
104
+ id: orientation
105
+ description: >-
106
+ Direction of the line.
107
+ values:
108
+ - id: horizontal
109
+ description: >-
110
+ 1px thick, full width (default).
111
+ - id: vertical
112
+ description: >-
113
+ 1px wide, as tall as the row.
114
+
115
+ refs:
116
+ - href: ./Separator.md
117
+ rel: relates-to
118
+ role: Thai usage doc
119
+ - href: ./Separator.stories.tsx
120
+ rel: demo
121
+ role: CSF stories
@@ -0,0 +1,124 @@
1
+ kind: component
2
+ id: skeleton
3
+ name: Skeleton
4
+ description: >-
5
+ A softly pulsing grey box standing in for content that is loading, so the page
6
+ layout shows before the data arrives. 18px radius, no text of its own.
7
+ metadata:
8
+ status: {status: stable}
9
+ since: 1.0.0
10
+ tags: [feedback]
11
+
12
+ sections:
13
+ - kind: guidelines
14
+ for: all
15
+ framing: when-to-use
16
+ items:
17
+ - level: should
18
+ statement: >-
19
+ Use while content whose shape is known is loading, e.g. fund cards, a balance,
20
+ a transactions table.
21
+ - level: should-not
22
+ statement: >-
23
+ Don't use for work with known progress (file upload). Use <dsds:progress>.
24
+ alternatives:
25
+ - to: progress
26
+ - level: must-not
27
+ statement: >-
28
+ Never use while waiting for the result of a user action (pressing save).
29
+ Disable the button and add a <dsds:spinner>.
30
+ alternatives:
31
+ - to: spinner
32
+ checkedBy: manual
33
+ - level: should-not
34
+ statement: >-
35
+ Don't show it for very fast loads (under about 300ms): a skeleton that flashes
36
+ for an instant is distracting (the delay isn't defined yet, see Open decisions).
37
+
38
+ - kind: guidelines
39
+ for: all
40
+ items:
41
+ - id: size-required
42
+ level: must
43
+ statement: >-
44
+ Always set the size with `className` (`h-4 w-48`) to match the real content, so
45
+ the page doesn't jump when the data arrives. Skeleton has no size of its own.
46
+ checkedBy: manual
47
+ - id: mirror-layout
48
+ level: should
49
+ statement: >-
50
+ Shape the skeleton like the component that replaces it, e.g. FundCard: a square
51
+ image `rounded-3xl` + 3 lines; Avatar: `rounded-full`.
52
+ example:
53
+ ref:
54
+ href: ./Skeleton.stories.tsx#FundCardLoading
55
+ rel: demo
56
+ uses:
57
+ - to: fund-card
58
+ checkedBy: manual
59
+ - id: then-empty
60
+ level: must
61
+ statement: >-
62
+ When loading finishes with no data, switch to <dsds:empty>; when loading fails,
63
+ switch to a `destructive` <dsds:alert>. Never leave the skeleton showing.
64
+ checkedBy: manual
65
+
66
+ - kind: guidelines
67
+ for: all
68
+ title: Accessibility
69
+ tags: [accessibility]
70
+ items:
71
+ - id: status-wrapper
72
+ level: must
73
+ statement: >-
74
+ Wrap each group of skeletons in `role="status"` with an `aria-label` saying what
75
+ is loading ("กำลังโหลดตัวเลือกการลงทุน" (loading investment options)), because
76
+ Skeleton has no text to read. One wrapper per section, not per box.
77
+ evidence:
78
+ - href: https://www.w3.org/WAI/WCAG22/Understanding/status-messages.html
79
+ role: WCAG 2.2 SC 4.1.3 (AA)
80
+ checks:
81
+ - href: ./Skeleton.stories.tsx#Playground
82
+ role: test
83
+ - href: ./Skeleton.stories.tsx#FundCardLoading
84
+ role: test
85
+ checkedBy: automated
86
+ - id: reduced-motion
87
+ level: should
88
+ statement: >-
89
+ The pulse is a gentle animation. Don't add extra animation (e.g. a moving
90
+ shimmer) that doesn't stop under `prefers-reduced-motion`.
91
+ evidence:
92
+ - href: https://www.w3.org/WAI/WCAG22/Understanding/animation-from-interactions.html
93
+ role: WCAG 2.2 SC 2.3.3 (AAA)
94
+ checkedBy: manual
95
+
96
+ - kind: section
97
+ for: all
98
+ title: Open decisions
99
+ freeform:
100
+ - title: TODO
101
+ body: >-
102
+ No delay before showing a skeleton has been defined yet.
103
+
104
+ sourceFiles:
105
+ - platform: react
106
+ file: ./Skeleton.tsx
107
+
108
+ imports:
109
+ - platform: react
110
+ code: >-
111
+ import { Skeleton } from "@designil/labdsnov"
112
+ package: "@designil/labdsnov"
113
+
114
+ alternatives:
115
+ - to: progress
116
+ - to: spinner
117
+
118
+ refs:
119
+ - href: ./Skeleton.md
120
+ rel: relates-to
121
+ role: Thai usage doc
122
+ - href: ./Skeleton.stories.tsx
123
+ rel: demo
124
+ role: CSF stories
@@ -0,0 +1,194 @@
1
+ kind: component
2
+ id: slider
3
+ name: Slider
4
+ description: >-
5
+ Picks a number (or a range) within set bounds, by dragging or with the arrow keys.
6
+ 8px track, 24×16px thumb. Wraps Base UI `Slider`; numbers are formatted `th-TH`.
7
+ metadata:
8
+ status: {status: stable}
9
+ since: 1.0.0
10
+ tags: [form]
11
+
12
+ sections:
13
+ - kind: guidelines
14
+ for: all
15
+ framing: when-to-use
16
+ items:
17
+ - level: should
18
+ statement: >-
19
+ Use for values that needn't be exact and whose effect the user wants to see
20
+ right away, e.g. a 0–15% extra contribution rate in a calculator.
21
+ - level: should
22
+ statement: >-
23
+ Use two values to pick a range, e.g. age 30–60.
24
+ example:
25
+ ref:
26
+ href: ./Slider.stories.tsx#Range
27
+ rel: demo
28
+ - level: must-not
29
+ statement: >-
30
+ Never use for an amount of money that must be typed exactly. Use
31
+ `Input type="number"` or <dsds:input-group> ("AU$").
32
+ alternatives:
33
+ - to: input
34
+ - to: input-group
35
+ checkedBy: manual
36
+ - level: should-not
37
+ statement: >-
38
+ Don't use for a few named options. Use <dsds:radio-group> or
39
+ <dsds:toggle-group>.
40
+ alternatives:
41
+ - to: radio-group
42
+ - to: toggle-group
43
+ - level: must-not
44
+ statement: >-
45
+ Never use to show progress that can't be changed. Use <dsds:progress>.
46
+ alternatives:
47
+ - to: progress
48
+ checkedBy: manual
49
+
50
+ - kind: guidelines
51
+ for: all
52
+ items:
53
+ - id: show-value
54
+ level: must
55
+ statement: >-
56
+ Always show the chosen value as a number nearby (e.g. in the label
57
+ "อัตราเงินสมทบเพิ่มเติม 5%" (extra contribution rate 5%)). The thumb position
58
+ alone can't be read precisely.
59
+ example:
60
+ ref:
61
+ href: ./Slider.stories.tsx#WithValue
62
+ rel: demo
63
+ checkedBy: manual
64
+ - id: step-meaningful
65
+ level: should
66
+ statement: >-
67
+ Set `step` to a meaningful unit (0.5% for a rate, 1 year for age) and
68
+ `largeStep` (default 10) for Page Up/Down.
69
+ checkedBy: manual
70
+ - id: min-max-labels
71
+ level: should
72
+ statement: >-
73
+ Show the min/max under the track when the bounds aren't clear from context
74
+ (e.g. "0%" and "15%").
75
+ checkedBy: manual
76
+ - id: vertical-height
77
+ level: may
78
+ statement: >-
79
+ `orientation="vertical"` is at least 160px tall.
80
+
81
+ - kind: guidelines
82
+ for: all
83
+ title: Accessibility
84
+ tags: [accessibility]
85
+ items:
86
+ - id: aria-label-fn
87
+ level: must
88
+ statement: >-
89
+ Name every thumb with `getAriaLabel` (`() => "อัตราเงินสมทบเพิ่มเติม"`; for a
90
+ range `(index) => index === 0 ? "อายุต่ำสุด" : "อายุสูงสุด"` (min age / max
91
+ age)), unless `aria-labelledby` points at a visible label.
92
+ evidence:
93
+ - href: https://www.w3.org/WAI/WCAG22/Understanding/name-role-value.html
94
+ role: WCAG 2.2 SC 4.1.2 (A)
95
+ checkedBy: manual
96
+ - id: value-text-unit
97
+ level: must
98
+ statement: >-
99
+ `getAriaValueText` adds the unit in Thai
100
+ (`(formatted) => \`${formatted}% ของเงินเดือน\`` (of salary)); otherwise screen
101
+ readers read only the number.
102
+ checks:
103
+ - href: ./Slider.stories.tsx#Keyboard
104
+ role: test
105
+ note: play function checks aria-valuetext "5% ของเงินเดือน" and arrows/End
106
+ checkedBy: automated
107
+ - id: drag-alternative
108
+ level: must
109
+ statement: >-
110
+ The value can be changed by keyboard (arrows, Page Up/Down, Home/End) and by
111
+ clicking the track without dragging. Never disable clicking the track.
112
+ evidence:
113
+ - href: https://www.w3.org/WAI/WCAG22/Understanding/dragging-movements.html
114
+ role: WCAG 2.2 SC 2.5.7 (AA)
115
+ checkedBy: manual
116
+ - id: slider-contrast
117
+ level: must
118
+ statement: >-
119
+ Selected range on the track 4.74:1 / 5.09:1, track border 3.93:1 / 4.05:1,
120
+ thumb border 5.23:1 / 6.99:1 (light / dark).
121
+ checks:
122
+ - href: ../../../scripts/tokens.mjs
123
+ role: test
124
+ note: CONTRAST_PAIRS "… Slider …"
125
+ checkedBy: automated
126
+
127
+ - kind: definitions
128
+ for: all
129
+ context: keyboard
130
+ items:
131
+ - term: Arrows
132
+ definition: >-
133
+ Move by `step`.
134
+ - term: Page Up / Page Down
135
+ definition: >-
136
+ Move by `largeStep`.
137
+ - term: Home / End
138
+ definition: >-
139
+ Go to the min / max.
140
+
141
+ - kind: section
142
+ for: all
143
+ title: Open decisions
144
+ freeform:
145
+ - title: TODO
146
+ body: >-
147
+ Not decided whether calculators should have a typed input next to the Slider.
148
+
149
+ sourceFiles:
150
+ - platform: react
151
+ file: ./Slider.tsx
152
+
153
+ imports:
154
+ - platform: react
155
+ code: >-
156
+ import { Slider } from "@designil/labdsnov"
157
+ package: "@designil/labdsnov"
158
+
159
+ traits:
160
+ - traitType: variant
161
+ kind: enum
162
+ id: orientation
163
+ description: >-
164
+ Direction of the track.
165
+ values:
166
+ - id: horizontal
167
+ description: >-
168
+ Horizontal, full width (default).
169
+ - id: vertical
170
+ description: >-
171
+ Vertical, at least 160px tall.
172
+ - traitType: variant
173
+ kind: boolean
174
+ id: range
175
+ description: >-
176
+ `value` is an array of two values, giving two thumbs.
177
+ - traitType: state
178
+ kind: boolean
179
+ id: disabled
180
+ description: >-
181
+ Disabled, 50% opacity.
182
+
183
+ alternatives:
184
+ - to: input-group
185
+ - to: radio-group
186
+ - to: progress
187
+
188
+ refs:
189
+ - href: ./Slider.md
190
+ rel: relates-to
191
+ role: Thai usage doc
192
+ - href: ./Slider.stories.tsx
193
+ rel: demo
194
+ role: CSF stories