@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.
- package/README.md +18 -1
- package/dist/components/Accordion/Accordion.module.css.js +10 -10
- package/dist/components/Alert/Alert.module.css.js +10 -10
- package/dist/components/AlertDialog/AlertDialog.module.css.js +16 -16
- package/dist/components/Avatar/Avatar.module.css.js +18 -18
- package/dist/components/Badge/Badge.module.css.js +6 -6
- package/dist/components/Breadcrumb/Breadcrumb.module.css.js +14 -14
- package/dist/components/Button/Button.module.css.js +26 -26
- package/dist/components/ButtonGroup/ButtonGroup.module.css.js +2 -2
- package/dist/components/Calendar/Calendar.module.css.js +33 -33
- package/dist/components/Card/Card.module.css.js +20 -20
- package/dist/components/Chart/Chart.module.css.js +32 -32
- package/dist/components/Checkbox/Checkbox.module.css.js +10 -10
- package/dist/components/Collapsible/Collapsible.module.css.js +1 -1
- package/dist/components/Combobox/Combobox.module.css.js +32 -32
- package/dist/components/DatePicker/DatePicker.module.css.js +4 -4
- package/dist/components/Dialog/Dialog.module.css.js +13 -13
- package/dist/components/Drawer/Drawer.module.css.js +18 -18
- package/dist/components/DropdownMenu/DropdownMenu.module.css.js +24 -24
- package/dist/components/Empty/Empty.module.css.js +11 -11
- package/dist/components/Field/Field.module.css.js +25 -25
- package/dist/components/FundCard/FundCard.module.css.js +14 -14
- package/dist/components/HoverCard/HoverCard.module.css.js +5 -5
- package/dist/components/Input/Input.module.css.js +2 -2
- package/dist/components/InputGroup/InputGroup.module.css.js +16 -16
- package/dist/components/InputOTP/InputOTP.module.css.js +16 -16
- package/dist/components/Kbd/Kbd.module.css.js +1 -1
- package/dist/components/Label/Label.module.css.js +6 -6
- package/dist/components/NavigationMenu/NavigationMenu.module.css.js +24 -24
- package/dist/components/Pagination/Pagination.module.css.js +10 -10
- package/dist/components/Popover/Popover.module.css.js +10 -10
- package/dist/components/Progress/Progress.module.css.js +12 -12
- package/dist/components/RadioGroup/RadioGroup.module.css.js +8 -8
- package/dist/components/ScrollArea/ScrollArea.module.css.js +5 -5
- package/dist/components/Select/Select.module.css.js +34 -34
- package/dist/components/Separator/Separator.module.css.js +1 -1
- package/dist/components/Skeleton/Skeleton.module.css.js +1 -1
- package/dist/components/Slider/Slider.module.css.js +12 -12
- package/dist/components/Spinner/Spinner.module.css.js +1 -1
- package/dist/components/Switch/Switch.module.css.js +6 -6
- package/dist/components/Table/Table.module.css.js +8 -8
- package/dist/components/Tabs/Tabs.module.css.js +8 -8
- package/dist/components/Textarea/Textarea.module.css.js +1 -1
- package/dist/components/Toaster/Toaster.module.css.js +8 -8
- package/dist/components/Toggle/Toggle.module.css.js +8 -8
- package/dist/components/ToggleGroup/ToggleGroup.module.css.js +3 -3
- package/dist/components/Tooltip/Tooltip.module.css.js +5 -5
- package/dist/styles.css +1 -1
- package/docs/Colors.md +96 -43
- package/docs/Contributing.md +14 -7
- package/package.json +21 -13
- package/src/components/Accordion/Accordion.dsds.yaml +195 -0
- package/src/components/Alert/Alert.dsds.yaml +206 -0
- package/src/components/AlertDialog/AlertDialog.dsds.yaml +243 -0
- package/src/components/Avatar/Avatar.dsds.yaml +172 -0
- package/src/components/Badge/Badge.dsds.yaml +191 -0
- package/src/components/Breadcrumb/Breadcrumb.dsds.yaml +162 -0
- package/src/components/Button/Button.dsds.yaml +350 -0
- package/src/components/ButtonGroup/ButtonGroup.dsds.yaml +193 -0
- package/src/components/Calendar/Calendar.dsds.yaml +236 -0
- package/src/components/Card/Card.dsds.yaml +199 -0
- package/src/components/Chart/Chart.dsds.yaml +216 -0
- package/src/components/Checkbox/Checkbox.dsds.yaml +215 -0
- package/src/components/Collapsible/Collapsible.dsds.yaml +146 -0
- package/src/components/Combobox/Combobox.dsds.yaml +241 -0
- package/src/components/DatePicker/DatePicker.dsds.yaml +179 -0
- package/src/components/Dialog/Dialog.dsds.yaml +300 -0
- package/src/components/Drawer/Drawer.dsds.yaml +207 -0
- package/src/components/DropdownMenu/DropdownMenu.dsds.yaml +265 -0
- package/src/components/Empty/Empty.dsds.yaml +171 -0
- package/src/components/Field/Field.dsds.yaml +285 -0
- package/src/components/FundCard/FundCard.dsds.yaml +195 -0
- package/src/components/FundCard/FundCard.md +2 -2
- package/src/components/HoverCard/HoverCard.dsds.yaml +157 -0
- package/src/components/Input/Input.dsds.yaml +235 -0
- package/src/components/InputGroup/InputGroup.dsds.yaml +234 -0
- package/src/components/InputOTP/InputOTP.dsds.yaml +184 -0
- package/src/components/Kbd/Kbd.dsds.yaml +119 -0
- package/src/components/Label/Label.dsds.yaml +141 -0
- package/src/components/NavigationMenu/NavigationMenu.dsds.yaml +196 -0
- package/src/components/Pagination/Pagination.dsds.yaml +172 -0
- package/src/components/Popover/Popover.dsds.yaml +168 -0
- package/src/components/Progress/Progress.dsds.yaml +169 -0
- package/src/components/RadioGroup/RadioGroup.dsds.yaml +215 -0
- package/src/components/ScrollArea/ScrollArea.dsds.yaml +153 -0
- package/src/components/Select/Select.dsds.yaml +239 -0
- package/src/components/Separator/Separator.dsds.yaml +121 -0
- package/src/components/Skeleton/Skeleton.dsds.yaml +124 -0
- package/src/components/Slider/Slider.dsds.yaml +194 -0
- package/src/components/Spinner/Spinner.dsds.yaml +126 -0
- package/src/components/Switch/Switch.dsds.yaml +198 -0
- package/src/components/Table/Table.dsds.yaml +195 -0
- package/src/components/Tabs/Tabs.dsds.yaml +239 -0
- package/src/components/Textarea/Textarea.dsds.yaml +167 -0
- package/src/components/Toaster/Toaster.dsds.yaml +226 -0
- package/src/components/Toggle/Toggle.dsds.yaml +224 -0
- package/src/components/ToggleGroup/ToggleGroup.dsds.yaml +230 -0
- package/src/components/Tooltip/Tooltip.dsds.yaml +202 -0
- package/src/index.dsds.yaml +467 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: tabs
|
|
3
|
+
name: Tabs
|
|
4
|
+
description: >-
|
|
5
|
+
Switches between several parts of the same subject in one area, showing one at a
|
|
6
|
+
time. Horizontal tab list 36px tall, 14px medium text. Wraps Base UI `Tabs`.
|
|
7
|
+
metadata:
|
|
8
|
+
status: {status: stable}
|
|
9
|
+
since: 1.0.0
|
|
10
|
+
tags: [navigation, disclosure]
|
|
11
|
+
|
|
12
|
+
sections:
|
|
13
|
+
- kind: guidelines
|
|
14
|
+
for: all
|
|
15
|
+
framing: when-to-use
|
|
16
|
+
items:
|
|
17
|
+
- level: should
|
|
18
|
+
statement: >-
|
|
19
|
+
Use to split one subject into parts of equal level that the user reads one at a
|
|
20
|
+
time, e.g. a member account: ภาพรวม / ธุรกรรม / เอกสาร (overview / transactions
|
|
21
|
+
/ documents).
|
|
22
|
+
- level: must-not
|
|
23
|
+
statement: >-
|
|
24
|
+
Never use for steps done in order (multi-step forms). There is no stepper
|
|
25
|
+
component yet.
|
|
26
|
+
checkedBy: manual
|
|
27
|
+
- level: must-not
|
|
28
|
+
statement: >-
|
|
29
|
+
Never use to go to other pages where each tab has its own URL. Use links or
|
|
30
|
+
<dsds:navigation-menu>.
|
|
31
|
+
alternatives:
|
|
32
|
+
- to: navigation-menu
|
|
33
|
+
checkedBy: manual
|
|
34
|
+
- level: must-not
|
|
35
|
+
statement: >-
|
|
36
|
+
Never use to pick a form value (e.g. an investment plan). Use
|
|
37
|
+
<dsds:radio-group> or <dsds:select>.
|
|
38
|
+
alternatives:
|
|
39
|
+
- to: radio-group
|
|
40
|
+
- to: select
|
|
41
|
+
checkedBy: manual
|
|
42
|
+
- level: should-not
|
|
43
|
+
statement: >-
|
|
44
|
+
Don't use when the user must compare two parts side by side. Show all parts on
|
|
45
|
+
the page.
|
|
46
|
+
- level: should-not
|
|
47
|
+
statement: >-
|
|
48
|
+
Don't use to switch a small display option of one data set (monthly/yearly).
|
|
49
|
+
Use <dsds:toggle-group>.
|
|
50
|
+
alternatives:
|
|
51
|
+
- to: toggle-group
|
|
52
|
+
|
|
53
|
+
- kind: guidelines
|
|
54
|
+
for: all
|
|
55
|
+
items:
|
|
56
|
+
- id: default-value-required
|
|
57
|
+
level: must
|
|
58
|
+
statement: >-
|
|
59
|
+
Always set `defaultValue` (or `value`). The default is `0`, which doesn't match
|
|
60
|
+
string `value`s, so no tab would be open.
|
|
61
|
+
checks:
|
|
62
|
+
- href: ./Tabs.stories.tsx#Playground
|
|
63
|
+
role: test
|
|
64
|
+
note: play function checks the "ภาพรวม" tab is selected and the tabpanel has content
|
|
65
|
+
checkedBy: automated
|
|
66
|
+
- id: values-match
|
|
67
|
+
level: must
|
|
68
|
+
statement: >-
|
|
69
|
+
Each `TabsTrigger` `value` matches the `value` of its `TabsContent`. Every tab
|
|
70
|
+
has its own content.
|
|
71
|
+
checkedBy: manual
|
|
72
|
+
- id: short-labels
|
|
73
|
+
level: must
|
|
74
|
+
statement: >-
|
|
75
|
+
Tab names are 1–2 words and don't wrap. The tab list doesn't scroll or wrap, so
|
|
76
|
+
cut the number of tabs when they don't fit.
|
|
77
|
+
checkedBy: manual
|
|
78
|
+
- id: keep-mounted-forms
|
|
79
|
+
level: should
|
|
80
|
+
statement: >-
|
|
81
|
+
Tabs containing forms need `keepMounted` on `TabsContent`, or entered values are
|
|
82
|
+
lost when switching (unselected tab content is unmounted).
|
|
83
|
+
checkedBy: manual
|
|
84
|
+
- id: url-state
|
|
85
|
+
level: should
|
|
86
|
+
statement: >-
|
|
87
|
+
Tabs the user may share or go back to (e.g. transactions) keep their value in the
|
|
88
|
+
URL via `value` / `onValueChange` in a Client Component.
|
|
89
|
+
checkedBy: manual
|
|
90
|
+
- id: icons-consistent
|
|
91
|
+
level: may
|
|
92
|
+
statement: >-
|
|
93
|
+
Icons are allowed (`data-icon="inline-start"`), but on every tab or none.
|
|
94
|
+
example:
|
|
95
|
+
ref:
|
|
96
|
+
href: ./Tabs.stories.tsx#WithIcons
|
|
97
|
+
rel: demo
|
|
98
|
+
|
|
99
|
+
- kind: guidelines
|
|
100
|
+
for: all
|
|
101
|
+
title: Accessibility
|
|
102
|
+
tags: [accessibility]
|
|
103
|
+
items:
|
|
104
|
+
- id: list-label
|
|
105
|
+
level: must
|
|
106
|
+
statement: >-
|
|
107
|
+
`TabsList` has an `aria-label` (e.g. "ข้อมูลบัญชี" (account information)) when
|
|
108
|
+
no heading says what the tabs are.
|
|
109
|
+
checkedBy: manual
|
|
110
|
+
- id: manual-activation
|
|
111
|
+
level: must
|
|
112
|
+
statement: >-
|
|
113
|
+
Arrows move focus and Enter/Space selects (`activateOnFocus` defaults to
|
|
114
|
+
`false`). Set `activateOnFocus` only when tab content loads fast and has no form.
|
|
115
|
+
evidence:
|
|
116
|
+
- href: https://www.w3.org/WAI/ARIA/apg/patterns/tabs/
|
|
117
|
+
role: WAI-ARIA APG Tabs pattern
|
|
118
|
+
checks:
|
|
119
|
+
- href: ./Tabs.stories.tsx#KeyboardNavigation
|
|
120
|
+
role: test
|
|
121
|
+
checkedBy: automated
|
|
122
|
+
- id: disabled-tab
|
|
123
|
+
level: must
|
|
124
|
+
statement: >-
|
|
125
|
+
A `disabled` tab has `aria-disabled="true"` and can't be selected by keyboard.
|
|
126
|
+
checks:
|
|
127
|
+
- href: ./Tabs.stories.tsx#DisabledTab
|
|
128
|
+
role: test
|
|
129
|
+
checkedBy: automated
|
|
130
|
+
- id: tabs-contrast
|
|
131
|
+
level: must
|
|
132
|
+
statement: >-
|
|
133
|
+
Unselected tabs 5.41:1 / 6.14:1 (`default`) and 5.97:1 / 8.43:1 (`line`); the
|
|
134
|
+
`line` underline 19.59:1 / 18.93:1 (light / dark).
|
|
135
|
+
checks:
|
|
136
|
+
- href: ../../../scripts/tokens.mjs
|
|
137
|
+
role: test
|
|
138
|
+
note: CONTRAST_PAIRS "แท็บ…" and "เส้นใต้แท็บ line"
|
|
139
|
+
checkedBy: automated
|
|
140
|
+
|
|
141
|
+
- kind: definitions
|
|
142
|
+
for: all
|
|
143
|
+
context: anatomy
|
|
144
|
+
items:
|
|
145
|
+
- term: Tabs
|
|
146
|
+
definition: >-
|
|
147
|
+
Root. Takes `defaultValue`, `value` / `onValueChange`, `orientation`.
|
|
148
|
+
- term: TabsList
|
|
149
|
+
definition: >-
|
|
150
|
+
The tab list. Takes `variant`, `aria-label`, `activateOnFocus`, `loopFocus`
|
|
151
|
+
(default `true`).
|
|
152
|
+
- term: TabsTrigger
|
|
153
|
+
definition: >-
|
|
154
|
+
A tab button. Takes `value` (required), `disabled`.
|
|
155
|
+
- term: TabsContent
|
|
156
|
+
definition: >-
|
|
157
|
+
Tab content. Takes `value` (required), `keepMounted`.
|
|
158
|
+
|
|
159
|
+
- kind: definitions
|
|
160
|
+
for: all
|
|
161
|
+
context: keyboard
|
|
162
|
+
items:
|
|
163
|
+
- term: Tab
|
|
164
|
+
definition: >-
|
|
165
|
+
Focuses the selected tab, then moves into the content.
|
|
166
|
+
- term: Left / Right arrows (vertical - Up / Down)
|
|
167
|
+
definition: >-
|
|
168
|
+
Move focus between tabs, looping when `loopFocus`.
|
|
169
|
+
- term: Home / End
|
|
170
|
+
definition: >-
|
|
171
|
+
First / last tab.
|
|
172
|
+
- term: Enter / Space
|
|
173
|
+
definition: >-
|
|
174
|
+
Select the focused tab.
|
|
175
|
+
|
|
176
|
+
- kind: section
|
|
177
|
+
for: all
|
|
178
|
+
title: Open decisions
|
|
179
|
+
freeform:
|
|
180
|
+
- title: TODO
|
|
181
|
+
body: >-
|
|
182
|
+
No criteria yet for choosing `default` vs `line`, no maximum number of tabs on
|
|
183
|
+
mobile, no plan for overflowing tabs, and tab content takes focus but shows no
|
|
184
|
+
focus indicator (WCAG 2.4.7).
|
|
185
|
+
|
|
186
|
+
sourceFiles:
|
|
187
|
+
- platform: react
|
|
188
|
+
file: ./Tabs.tsx
|
|
189
|
+
|
|
190
|
+
imports:
|
|
191
|
+
- platform: react
|
|
192
|
+
code: >-
|
|
193
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@designil/labdsnov"
|
|
194
|
+
package: "@designil/labdsnov"
|
|
195
|
+
|
|
196
|
+
traits:
|
|
197
|
+
- traitType: variant
|
|
198
|
+
kind: enum
|
|
199
|
+
id: listVariant
|
|
200
|
+
name: TabsList variant
|
|
201
|
+
description: >-
|
|
202
|
+
The `variant` prop of `TabsList`.
|
|
203
|
+
values:
|
|
204
|
+
- id: default
|
|
205
|
+
description: >-
|
|
206
|
+
Tabs sit in a grey pill; the selected tab is a raised background-colour pill.
|
|
207
|
+
- id: line
|
|
208
|
+
description: >-
|
|
209
|
+
No background; the selected tab is underlined (vertical: a line on the right).
|
|
210
|
+
- traitType: variant
|
|
211
|
+
kind: enum
|
|
212
|
+
id: orientation
|
|
213
|
+
description: >-
|
|
214
|
+
Direction of the tab list.
|
|
215
|
+
values:
|
|
216
|
+
- id: horizontal
|
|
217
|
+
description: >-
|
|
218
|
+
List on top (default).
|
|
219
|
+
- id: vertical
|
|
220
|
+
description: >-
|
|
221
|
+
Tabs stacked vertically to the left of the content.
|
|
222
|
+
- traitType: state
|
|
223
|
+
kind: boolean
|
|
224
|
+
id: disabled
|
|
225
|
+
description: >-
|
|
226
|
+
A tab that can't be selected, 50% opacity.
|
|
227
|
+
|
|
228
|
+
alternatives:
|
|
229
|
+
- to: navigation-menu
|
|
230
|
+
- to: toggle-group
|
|
231
|
+
- to: accordion
|
|
232
|
+
|
|
233
|
+
refs:
|
|
234
|
+
- href: ./Tabs.md
|
|
235
|
+
rel: relates-to
|
|
236
|
+
role: Thai usage doc
|
|
237
|
+
- href: ./Tabs.stories.tsx
|
|
238
|
+
rel: demo
|
|
239
|
+
role: CSF stories
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: textarea
|
|
3
|
+
name: Textarea
|
|
4
|
+
description: >-
|
|
5
|
+
A multi-line text field that grows with what the user types (at least 64px
|
|
6
|
+
tall). Looks like the `filled` Input.
|
|
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 text that may run past one line, such as a message to staff or
|
|
20
|
+
the reason for a withdrawal.
|
|
21
|
+
- level: must-not
|
|
22
|
+
statement: >-
|
|
23
|
+
Don't use for short single-line data (name, email, numbers). Use
|
|
24
|
+
<dsds:input>.
|
|
25
|
+
alternatives:
|
|
26
|
+
- to: input
|
|
27
|
+
checkedBy: manual
|
|
28
|
+
- level: must-not
|
|
29
|
+
statement: >-
|
|
30
|
+
Don't promise formatting (bold, lists). There is no rich text editor yet.
|
|
31
|
+
checkedBy: manual
|
|
32
|
+
|
|
33
|
+
- kind: guidelines
|
|
34
|
+
for: all
|
|
35
|
+
items:
|
|
36
|
+
- id: labelled
|
|
37
|
+
level: must
|
|
38
|
+
statement: >-
|
|
39
|
+
Bind it to a <dsds:label> with `id` / `htmlFor`. The placeholder is an
|
|
40
|
+
example of what to write ("พิมพ์ข้อความถึงเจ้าหน้าที่", "type a message
|
|
41
|
+
to staff"), not the label.
|
|
42
|
+
uses:
|
|
43
|
+
- to: label
|
|
44
|
+
checkedBy: manual
|
|
45
|
+
- id: min-length-message
|
|
46
|
+
level: must
|
|
47
|
+
statement: >-
|
|
48
|
+
If there is a minimum length, say so in `FieldDescription` before the
|
|
49
|
+
user types, and make the error message give the number
|
|
50
|
+
("กรุณาระบุเหตุผลอย่างน้อย 20 ตัวอักษร", "give a reason of at least 20
|
|
51
|
+
characters").
|
|
52
|
+
uses:
|
|
53
|
+
- to: field
|
|
54
|
+
checkedBy: manual
|
|
55
|
+
- id: counter-with-group
|
|
56
|
+
level: should
|
|
57
|
+
statement: >-
|
|
58
|
+
For a character counter with `maxLength`, use `InputGroupTextarea` with
|
|
59
|
+
`InputGroupAddon align="block-end"` from <dsds:input-group>. Textarea has
|
|
60
|
+
no built-in counter.
|
|
61
|
+
alternatives:
|
|
62
|
+
- to: input-group
|
|
63
|
+
example:
|
|
64
|
+
ref:
|
|
65
|
+
href: ../InputGroup/InputGroup.stories.tsx#TextareaWithFooter
|
|
66
|
+
rel: demo
|
|
67
|
+
checkedBy: manual
|
|
68
|
+
- id: auto-grow
|
|
69
|
+
level: may
|
|
70
|
+
statement: >-
|
|
71
|
+
The field grows with its text in browsers that support it. How `rows`
|
|
72
|
+
interacts with that growth hasn't been checked.
|
|
73
|
+
|
|
74
|
+
- kind: guidelines
|
|
75
|
+
for: all
|
|
76
|
+
title: Accessibility
|
|
77
|
+
tags: [accessibility]
|
|
78
|
+
items:
|
|
79
|
+
- id: invalid-described
|
|
80
|
+
level: must
|
|
81
|
+
statement: >-
|
|
82
|
+
A wrong value sets `aria-invalid` and `aria-describedby` pointing at the
|
|
83
|
+
error message.
|
|
84
|
+
refines:
|
|
85
|
+
- to: shared-a11y#invalid-has-message
|
|
86
|
+
checks:
|
|
87
|
+
- href: ./Textarea.stories.tsx#Invalid
|
|
88
|
+
role: test
|
|
89
|
+
note: play function checks toBeInvalid and toHaveAccessibleDescription
|
|
90
|
+
checkedBy: automated
|
|
91
|
+
- id: field-contrast
|
|
92
|
+
level: must
|
|
93
|
+
statement: >-
|
|
94
|
+
It shares the field tokens with Input. The edge (`--field-border`) is
|
|
95
|
+
3.93:1 light / 4.05:1 dark on the page background, and the placeholder
|
|
96
|
+
5.40:1 / 7.17:1.
|
|
97
|
+
checks:
|
|
98
|
+
- href: ../../../scripts/tokens.mjs
|
|
99
|
+
role: test
|
|
100
|
+
note: CONTRAST_PAIRS for field edges and placeholder
|
|
101
|
+
checkedBy: automated
|
|
102
|
+
- refs:
|
|
103
|
+
- to: shared-a11y#invalid-keeps-focus
|
|
104
|
+
rel: same-as
|
|
105
|
+
|
|
106
|
+
- kind: guidelines
|
|
107
|
+
for: agent
|
|
108
|
+
items:
|
|
109
|
+
- refs:
|
|
110
|
+
- to: shared-testing#fire-change-for-typing
|
|
111
|
+
rel: same-as
|
|
112
|
+
|
|
113
|
+
- kind: section
|
|
114
|
+
for: all
|
|
115
|
+
title: Open decisions
|
|
116
|
+
freeform:
|
|
117
|
+
- title: TODO
|
|
118
|
+
body: >-
|
|
119
|
+
No rich text editor yet, no built-in character counter, and the effect
|
|
120
|
+
of `rows` alongside auto-grow hasn't been checked.
|
|
121
|
+
|
|
122
|
+
sourceFiles:
|
|
123
|
+
- platform: react
|
|
124
|
+
file: ./Textarea.tsx
|
|
125
|
+
|
|
126
|
+
imports:
|
|
127
|
+
- platform: react
|
|
128
|
+
code: >-
|
|
129
|
+
import { Textarea } from "@designil/labdsnov"
|
|
130
|
+
package: "@designil/labdsnov"
|
|
131
|
+
|
|
132
|
+
traits:
|
|
133
|
+
- traitType: state
|
|
134
|
+
kind: boolean
|
|
135
|
+
id: disabled
|
|
136
|
+
description: >-
|
|
137
|
+
Disabled, dimmed to 50%.
|
|
138
|
+
- traitType: state
|
|
139
|
+
kind: boolean
|
|
140
|
+
id: aria-invalid
|
|
141
|
+
name: Invalid
|
|
142
|
+
description: >-
|
|
143
|
+
The value is wrong. Red edge and faint red ring.
|
|
144
|
+
|
|
145
|
+
uses:
|
|
146
|
+
- to: label
|
|
147
|
+
alternatives:
|
|
148
|
+
- to: input
|
|
149
|
+
- to: input-group
|
|
150
|
+
|
|
151
|
+
refs:
|
|
152
|
+
- href: ./Textarea.md
|
|
153
|
+
rel: relates-to
|
|
154
|
+
role: usage doc (Thai)
|
|
155
|
+
- href: ./Textarea.stories.tsx
|
|
156
|
+
rel: demo
|
|
157
|
+
role: CSF stories
|
|
158
|
+
- href: https://www.figma.com/design/QsKWb3A53lIh4QBDnAkGHh/labdsnov?node-id=10-63
|
|
159
|
+
rel: design
|
|
160
|
+
role: Textarea in Figma
|
|
161
|
+
- href: ../../../figma/Textarea.figma.ts
|
|
162
|
+
rel: source
|
|
163
|
+
role: Code Connect template
|
|
164
|
+
|
|
165
|
+
$extensions:
|
|
166
|
+
com.figma:
|
|
167
|
+
nodeId: "10:63"
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: toaster
|
|
3
|
+
name: Toaster
|
|
4
|
+
description: >-
|
|
5
|
+
Short messages that float up in a screen corner, report the result of an
|
|
6
|
+
action, then go away by themselves (`toast()`). Built on `sonner`, but it reads
|
|
7
|
+
dark mode from the `dark` class on `<html>` instead of using `next-themes` as
|
|
8
|
+
shadcn does.
|
|
9
|
+
metadata:
|
|
10
|
+
status: {status: stable}
|
|
11
|
+
since: 1.0.0
|
|
12
|
+
tags: [feedback]
|
|
13
|
+
|
|
14
|
+
sections:
|
|
15
|
+
- kind: guidelines
|
|
16
|
+
for: all
|
|
17
|
+
framing: when-to-use
|
|
18
|
+
items:
|
|
19
|
+
- level: should
|
|
20
|
+
statement: >-
|
|
21
|
+
Use to confirm the result of something the user just did, such as saved
|
|
22
|
+
or request sent.
|
|
23
|
+
- level: should
|
|
24
|
+
statement: >-
|
|
25
|
+
For an action that can be undone: do it at once, then show a toast with
|
|
26
|
+
an "เลิกทำ" (undo) button instead of asking first in a Dialog.
|
|
27
|
+
- level: must-not
|
|
28
|
+
statement: >-
|
|
29
|
+
Don't use for information that has to stay visible until it's fixed, or
|
|
30
|
+
that the user must not miss. A toast disappears. Use <dsds:alert>.
|
|
31
|
+
alternatives:
|
|
32
|
+
- to: alert
|
|
33
|
+
checkedBy: manual
|
|
34
|
+
- level: must-not
|
|
35
|
+
statement: >-
|
|
36
|
+
Don't use for an error on a form field. Use `FieldError` from
|
|
37
|
+
<dsds:field>.
|
|
38
|
+
alternatives:
|
|
39
|
+
- to: field
|
|
40
|
+
checkedBy: manual
|
|
41
|
+
- level: must-not
|
|
42
|
+
statement: >-
|
|
43
|
+
Don't use when the user has to decide something. Use <dsds:dialog> or
|
|
44
|
+
<dsds:alert-dialog>.
|
|
45
|
+
alternatives:
|
|
46
|
+
- to: dialog
|
|
47
|
+
- to: alert-dialog
|
|
48
|
+
checkedBy: manual
|
|
49
|
+
|
|
50
|
+
- kind: guidelines
|
|
51
|
+
for: all
|
|
52
|
+
items:
|
|
53
|
+
- id: mount-once
|
|
54
|
+
level: must
|
|
55
|
+
statement: >-
|
|
56
|
+
Mount `<Toaster />` once for the whole app in the root layout, and call
|
|
57
|
+
`toast()` from `"use client"` files. More than one Toaster shows each
|
|
58
|
+
toast more than once.
|
|
59
|
+
refs:
|
|
60
|
+
- to: labdsnov#mount-providers-once
|
|
61
|
+
rel: relates-to
|
|
62
|
+
checkedBy: manual
|
|
63
|
+
- id: type-matches-result
|
|
64
|
+
level: must
|
|
65
|
+
statement: >-
|
|
66
|
+
Pick the type from the result: `toast.success` succeeded, `toast.error`
|
|
67
|
+
failed, `toast.warning` succeeded with a caveat, `toast.info`
|
|
68
|
+
information, plain `toast()` otherwise (such as deleted + undo). For work
|
|
69
|
+
still running, use `toast.promise(promise, { loading, success, error })`.
|
|
70
|
+
checkedBy: manual
|
|
71
|
+
- id: past-tense-title
|
|
72
|
+
level: should
|
|
73
|
+
statement: >-
|
|
74
|
+
The title states the result briefly ("เปลี่ยนแผนการลงทุนแล้ว",
|
|
75
|
+
"investment plan changed") and `description` gives the consequence
|
|
76
|
+
("มีผลกับเงินสมทบงวดถัดไป", "applies from the next contribution").
|
|
77
|
+
example:
|
|
78
|
+
ref:
|
|
79
|
+
href: ./Toaster.stories.tsx#ShowToast
|
|
80
|
+
rel: demo
|
|
81
|
+
checkedBy: manual
|
|
82
|
+
- id: error-says-next
|
|
83
|
+
level: should
|
|
84
|
+
statement: >-
|
|
85
|
+
A `toast.error` says what to do next ("ไม่สามารถบันทึกได้
|
|
86
|
+
กรุณาลองอีกครั้ง", "couldn't save, please try again"). Errors that need
|
|
87
|
+
the user to fix data go in an Alert or FieldError instead.
|
|
88
|
+
checkedBy: manual
|
|
89
|
+
- id: one-action
|
|
90
|
+
level: should
|
|
91
|
+
statement: >-
|
|
92
|
+
`action` holds one button with a short label ("เลิกทำ"). A toast with an
|
|
93
|
+
undo button should get a longer `duration` so there's time to press it.
|
|
94
|
+
checkedBy: manual
|
|
95
|
+
- id: no-rich-colors
|
|
96
|
+
level: should-not
|
|
97
|
+
statement: >-
|
|
98
|
+
Don't turn on `richColors`. It uses sonner's own colours, not the
|
|
99
|
+
system's tokens, so `tokens:check` never sees them.
|
|
100
|
+
refs:
|
|
101
|
+
- to: shared-a11y#app-colours-same-bar
|
|
102
|
+
rel: relates-to
|
|
103
|
+
|
|
104
|
+
- kind: guidelines
|
|
105
|
+
for: all
|
|
106
|
+
title: Accessibility
|
|
107
|
+
tags: [accessibility]
|
|
108
|
+
items:
|
|
109
|
+
- id: announced
|
|
110
|
+
level: must
|
|
111
|
+
statement: >-
|
|
112
|
+
Toasts are announced to screen readers by sonner's live region, so the
|
|
113
|
+
text must make sense without seeing the icon.
|
|
114
|
+
evidence:
|
|
115
|
+
- href: https://www.w3.org/WAI/WCAG22/Understanding/status-messages.html
|
|
116
|
+
role: WCAG 2.2 SC 4.1.3 (AA)
|
|
117
|
+
checks:
|
|
118
|
+
- href: ./Toaster.stories.tsx#ShowToast
|
|
119
|
+
role: test
|
|
120
|
+
note: play function opens a toast and checks its title and description
|
|
121
|
+
checkedBy: assisted
|
|
122
|
+
- id: enough-time
|
|
123
|
+
level: must
|
|
124
|
+
statement: >-
|
|
125
|
+
A toast with a button stays long enough to reach by keyboard, and the
|
|
126
|
+
same action must also be possible elsewhere (such as restoring from the
|
|
127
|
+
list page), because the toast goes away by itself.
|
|
128
|
+
evidence:
|
|
129
|
+
- href: https://www.w3.org/WAI/WCAG22/Understanding/timing-adjustable.html
|
|
130
|
+
role: WCAG 2.2 SC 2.2.1 (A)
|
|
131
|
+
checkedBy: manual
|
|
132
|
+
|
|
133
|
+
- kind: guidelines
|
|
134
|
+
for: agent
|
|
135
|
+
items:
|
|
136
|
+
- refs:
|
|
137
|
+
- to: shared-testing#assert-by-state
|
|
138
|
+
rel: same-as
|
|
139
|
+
- refs:
|
|
140
|
+
- to: shared-testing#query-portal-with-screen
|
|
141
|
+
rel: same-as
|
|
142
|
+
|
|
143
|
+
- kind: definitions
|
|
144
|
+
for: all
|
|
145
|
+
context: anatomy
|
|
146
|
+
items:
|
|
147
|
+
- term: Toaster
|
|
148
|
+
definition: >-
|
|
149
|
+
The container, mounted once. Takes `position` (default `bottom-right`),
|
|
150
|
+
`richColors`, `closeButton`, `theme` (follows `.dark` by default).
|
|
151
|
+
- term: toast()
|
|
152
|
+
definition: >-
|
|
153
|
+
The function that shows a toast. Options used most: `description`,
|
|
154
|
+
`action: { label, onClick }`, `duration` (ms).
|
|
155
|
+
|
|
156
|
+
- kind: section
|
|
157
|
+
for: all
|
|
158
|
+
title: Open decisions
|
|
159
|
+
freeform:
|
|
160
|
+
- title: TODO
|
|
161
|
+
body: >-
|
|
162
|
+
The app's `position` isn't decided yet, and every type's icon uses the
|
|
163
|
+
text colour. Whether to use `--success` / `--warning` / `--destructive`
|
|
164
|
+
for them isn't decided.
|
|
165
|
+
|
|
166
|
+
sourceFiles:
|
|
167
|
+
- platform: react
|
|
168
|
+
file: ./Toaster.tsx
|
|
169
|
+
|
|
170
|
+
imports:
|
|
171
|
+
- platform: react
|
|
172
|
+
code: >-
|
|
173
|
+
import { Toaster, toast } from "@designil/labdsnov"
|
|
174
|
+
package: "@designil/labdsnov"
|
|
175
|
+
|
|
176
|
+
traits:
|
|
177
|
+
- traitType: variant
|
|
178
|
+
kind: enum
|
|
179
|
+
id: type
|
|
180
|
+
name: toast type
|
|
181
|
+
description: >-
|
|
182
|
+
Which function is called. It sets the icon.
|
|
183
|
+
values:
|
|
184
|
+
- id: default
|
|
185
|
+
description: >-
|
|
186
|
+
`toast()`, no icon.
|
|
187
|
+
- id: success
|
|
188
|
+
description: >-
|
|
189
|
+
`toast.success()`, a tick in a circle.
|
|
190
|
+
- id: info
|
|
191
|
+
description: >-
|
|
192
|
+
`toast.info()`, an i in a circle.
|
|
193
|
+
- id: warning
|
|
194
|
+
description: >-
|
|
195
|
+
`toast.warning()`, a warning triangle.
|
|
196
|
+
- id: error
|
|
197
|
+
description: >-
|
|
198
|
+
`toast.error()`, a cross in a circle.
|
|
199
|
+
- id: promise
|
|
200
|
+
description: >-
|
|
201
|
+
`toast.promise()`, a spinner while waiting, then the result's icon.
|
|
202
|
+
- traitType: variant
|
|
203
|
+
kind: boolean
|
|
204
|
+
id: closeButton
|
|
205
|
+
description: >-
|
|
206
|
+
Shows a close button on each toast (set on `Toaster`).
|
|
207
|
+
- traitType: variant
|
|
208
|
+
kind: boolean
|
|
209
|
+
id: richColors
|
|
210
|
+
description: >-
|
|
211
|
+
Background colour by type from sonner, not from the system's tokens.
|
|
212
|
+
|
|
213
|
+
alternatives:
|
|
214
|
+
- to: alert
|
|
215
|
+
- to: alert-dialog
|
|
216
|
+
|
|
217
|
+
refs:
|
|
218
|
+
- href: ./Toaster.md
|
|
219
|
+
rel: relates-to
|
|
220
|
+
role: usage doc (Thai)
|
|
221
|
+
- href: ./Toaster.stories.tsx
|
|
222
|
+
rel: demo
|
|
223
|
+
role: CSF stories
|
|
224
|
+
- href: https://sonner.emilkowal.ski
|
|
225
|
+
rel: relates-to
|
|
226
|
+
role: sonner docs
|