@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,300 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: dialog
|
|
3
|
+
name: Dialog
|
|
4
|
+
description: >-
|
|
5
|
+
A modal window centred on screen, where users make a decision or fill in a short form
|
|
6
|
+
before returning to their task. It has a dark blurred backdrop and a "ปิด" (close)
|
|
7
|
+
button at the top right. Wraps Base UI's `Dialog`.
|
|
8
|
+
metadata:
|
|
9
|
+
status: {status: stable}
|
|
10
|
+
since: 1.0.0
|
|
11
|
+
tags: [overlay]
|
|
12
|
+
|
|
13
|
+
sections:
|
|
14
|
+
- kind: guidelines
|
|
15
|
+
for: all
|
|
16
|
+
framing: when-to-use
|
|
17
|
+
description: >-
|
|
18
|
+
Use sparingly. Carbon, Atlassian and Polaris treat modals as a last resort because
|
|
19
|
+
they interrupt users.
|
|
20
|
+
items:
|
|
21
|
+
- level: should
|
|
22
|
+
statement: >-
|
|
23
|
+
Use to confirm an important decision the user started, e.g. changing investment
|
|
24
|
+
plan.
|
|
25
|
+
- level: should
|
|
26
|
+
statement: >-
|
|
27
|
+
Use for a short form of 1–3 fields that shouldn't leave the page, e.g. editing
|
|
28
|
+
account details.
|
|
29
|
+
- level: must-not
|
|
30
|
+
statement: >-
|
|
31
|
+
Don't use to confirm an irreversible action. Use <dsds:alert-dialog>, which is
|
|
32
|
+
announced as `alertdialog` and doesn't close on an outside click.
|
|
33
|
+
alternatives:
|
|
34
|
+
- to: alert-dialog
|
|
35
|
+
checkedBy: manual
|
|
36
|
+
- level: must-not
|
|
37
|
+
statement: >-
|
|
38
|
+
Don't open a dialog from a dialog. Merge them into one, or move to a new page.
|
|
39
|
+
checkedBy: manual
|
|
40
|
+
- level: must-not
|
|
41
|
+
statement: >-
|
|
42
|
+
Don't use for messages that need no answer ("บันทึกแล้ว", saved). Use a `toast`
|
|
43
|
+
(<dsds:toaster>).
|
|
44
|
+
alternatives:
|
|
45
|
+
- to: toaster
|
|
46
|
+
checkedBy: manual
|
|
47
|
+
- level: should-not
|
|
48
|
+
statement: >-
|
|
49
|
+
Don't use for long content, large tables, multi-step forms or frequent tasks. Do
|
|
50
|
+
them on the page or a new page.
|
|
51
|
+
- level: should-not
|
|
52
|
+
statement: >-
|
|
53
|
+
Don't use for small options next to a button. Use <dsds:popover> or
|
|
54
|
+
<dsds:dropdown-menu>.
|
|
55
|
+
alternatives:
|
|
56
|
+
- to: popover
|
|
57
|
+
- to: dropdown-menu
|
|
58
|
+
- level: should-not
|
|
59
|
+
statement: >-
|
|
60
|
+
Don't use as a panel sliding from the screen edge on mobile. Use <dsds:drawer>.
|
|
61
|
+
alternatives:
|
|
62
|
+
- to: drawer
|
|
63
|
+
|
|
64
|
+
- kind: guidelines
|
|
65
|
+
for: all
|
|
66
|
+
items:
|
|
67
|
+
- id: title-required
|
|
68
|
+
level: must
|
|
69
|
+
statement: >-
|
|
70
|
+
Always include `DialogTitle`. It's the dialog's name, read out by screen readers
|
|
71
|
+
when it opens.
|
|
72
|
+
checks:
|
|
73
|
+
- href: ./Dialog.stories.tsx#OpenAndClose
|
|
74
|
+
role: test
|
|
75
|
+
note: play function checks toHaveAccessibleName and toHaveAccessibleDescription
|
|
76
|
+
checkedBy: automated
|
|
77
|
+
- id: title-matches-trigger
|
|
78
|
+
level: must
|
|
79
|
+
statement: >-
|
|
80
|
+
The title uses the same words as the button that opened it (button
|
|
81
|
+
"แก้ไขข้อมูลบัญชี" → title "แก้ไขข้อมูลบัญชี", edit account details). A
|
|
82
|
+
confirmation is phrased as a question ("เปลี่ยนแผนการลงทุน?", change investment
|
|
83
|
+
plan?).
|
|
84
|
+
checkedBy: manual
|
|
85
|
+
- id: cancel-then-primary
|
|
86
|
+
level: must
|
|
87
|
+
statement: >-
|
|
88
|
+
In `DialogFooter` put the cancel button first and the primary button last. The
|
|
89
|
+
footer is a right-aligned row on wide screens and stacks vertically on narrow ones
|
|
90
|
+
with the last button on top, so the primary ends up rightmost or topmost.
|
|
91
|
+
checkedBy: manual
|
|
92
|
+
- id: max-three-buttons
|
|
93
|
+
level: must
|
|
94
|
+
statement: >-
|
|
95
|
+
At most 3 footer buttons, only one of them primary, each a specific verb.
|
|
96
|
+
refs:
|
|
97
|
+
- to: shared-content#actions-are-verbs
|
|
98
|
+
rel: relates-to
|
|
99
|
+
checkedBy: manual
|
|
100
|
+
- id: description-consequence
|
|
101
|
+
level: should
|
|
102
|
+
statement: >-
|
|
103
|
+
`DialogDescription` states the consequence ("การเปลี่ยนแผนจะมีผลกับเงินสมทบงวดถัดไป",
|
|
104
|
+
the change applies from the next contribution), not what the buttons do.
|
|
105
|
+
checkedBy: manual
|
|
106
|
+
- id: controlled-to-close-after-save
|
|
107
|
+
level: should
|
|
108
|
+
statement: >-
|
|
109
|
+
A form that should close after a successful save controls `open` / `onOpenChange`
|
|
110
|
+
in a Client Component. Don't make the save button a `DialogClose` (it closes before
|
|
111
|
+
the result is known).
|
|
112
|
+
example:
|
|
113
|
+
ref:
|
|
114
|
+
href: ./Dialog.stories.tsx#EditAccountForm
|
|
115
|
+
rel: demo
|
|
116
|
+
checkedBy: manual
|
|
117
|
+
- id: size-choice
|
|
118
|
+
level: should
|
|
119
|
+
statement: >-
|
|
120
|
+
`sm` (384px) for short forms and confirmations, `default` (448px) for general
|
|
121
|
+
decisions (`lg` / `xl` have no examples yet). Below 640px every size is full width
|
|
122
|
+
with 16px side margins.
|
|
123
|
+
checkedBy: manual
|
|
124
|
+
- id: close-button-default
|
|
125
|
+
level: should
|
|
126
|
+
statement: >-
|
|
127
|
+
Keep the top-right "ปิด" (close) button. Hide it (`showCloseButton={false}`) only
|
|
128
|
+
when the footer already has a "ยกเลิก" (cancel) button. An information-only dialog
|
|
129
|
+
uses `DialogFooter showCloseButton`.
|
|
130
|
+
checks:
|
|
131
|
+
- href: ./Dialog.stories.tsx#WithoutCloseButton
|
|
132
|
+
role: test
|
|
133
|
+
checkedBy: automated
|
|
134
|
+
- id: trigger-render
|
|
135
|
+
level: must
|
|
136
|
+
statement: >-
|
|
137
|
+
Write the opening button and footer buttons as `DialogTrigger` / `DialogClose`
|
|
138
|
+
`render={<Button … />}`.
|
|
139
|
+
refs:
|
|
140
|
+
- to: shared-composition#render-prop
|
|
141
|
+
rel: relates-to
|
|
142
|
+
checkedBy: assisted
|
|
143
|
+
- id: no-tall-content
|
|
144
|
+
level: must-not
|
|
145
|
+
statement: >-
|
|
146
|
+
Don't put content taller than the screen in a dialog. Dialog has no max height and
|
|
147
|
+
no scrolling content area; move it to a new page until this is decided.
|
|
148
|
+
checkedBy: manual
|
|
149
|
+
|
|
150
|
+
- kind: guidelines
|
|
151
|
+
for: all
|
|
152
|
+
title: Accessibility
|
|
153
|
+
tags: [accessibility]
|
|
154
|
+
items:
|
|
155
|
+
- id: focus-management
|
|
156
|
+
level: must
|
|
157
|
+
statement: >-
|
|
158
|
+
On open, focus moves to the first focusable field (change it with `initialFocus`),
|
|
159
|
+
stays trapped in the dialog, and returns to the opening button on close
|
|
160
|
+
(`finalFocus`). Don't drop the focus trap with `modal={false}` on a dialog with a
|
|
161
|
+
form.
|
|
162
|
+
evidence:
|
|
163
|
+
- href: https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/
|
|
164
|
+
role: WAI-ARIA APG Dialog (Modal) pattern
|
|
165
|
+
checks:
|
|
166
|
+
- href: ./Dialog.stories.tsx#EditAccountForm
|
|
167
|
+
role: test
|
|
168
|
+
note: play function checks the "ชื่อ-นามสกุล" (full name) field gets focus on open
|
|
169
|
+
checkedBy: automated
|
|
170
|
+
- id: escape-closes
|
|
171
|
+
level: must
|
|
172
|
+
statement: >-
|
|
173
|
+
Escape always closes the dialog.
|
|
174
|
+
checks:
|
|
175
|
+
- href: ./Dialog.stories.tsx#EscapeCloses
|
|
176
|
+
role: test
|
|
177
|
+
checkedBy: automated
|
|
178
|
+
- id: close-label-thai
|
|
179
|
+
level: must
|
|
180
|
+
statement: >-
|
|
181
|
+
The top-right icon button is already named "ปิด" (close). Don't replace it with
|
|
182
|
+
your own icon button without an `aria-label`.
|
|
183
|
+
refines:
|
|
184
|
+
- to: shared-a11y#icon-only-label
|
|
185
|
+
checkedBy: assisted
|
|
186
|
+
|
|
187
|
+
- kind: guidelines
|
|
188
|
+
for: agent
|
|
189
|
+
items:
|
|
190
|
+
- refs:
|
|
191
|
+
- to: shared-testing#assert-by-state
|
|
192
|
+
rel: same-as
|
|
193
|
+
- refs:
|
|
194
|
+
- to: shared-testing#query-portal-with-screen
|
|
195
|
+
rel: same-as
|
|
196
|
+
- refs:
|
|
197
|
+
- to: shared-testing#modal-stories-not-autodocs
|
|
198
|
+
rel: same-as
|
|
199
|
+
|
|
200
|
+
- kind: definitions
|
|
201
|
+
for: all
|
|
202
|
+
context: anatomy
|
|
203
|
+
items:
|
|
204
|
+
- term: Dialog
|
|
205
|
+
definition: >-
|
|
206
|
+
Root; takes `open` / `onOpenChange`, `defaultOpen`, `modal`,
|
|
207
|
+
`disablePointerDismissal`
|
|
208
|
+
- term: DialogTrigger
|
|
209
|
+
definition: >-
|
|
210
|
+
The opening button (`render={<Button />}`)
|
|
211
|
+
- term: DialogContent
|
|
212
|
+
definition: >-
|
|
213
|
+
The centred box (portal + overlay built in); takes `size`, `showCloseButton`,
|
|
214
|
+
`initialFocus`, `finalFocus`
|
|
215
|
+
- term: DialogHeader
|
|
216
|
+
definition: >-
|
|
217
|
+
DialogTitle (required) + DialogDescription (recommended)
|
|
218
|
+
- term: DialogFooter
|
|
219
|
+
definition: >-
|
|
220
|
+
Buttons; takes `showCloseButton` (an outline "ปิด" button at the end of the row)
|
|
221
|
+
- term: DialogClose
|
|
222
|
+
definition: >-
|
|
223
|
+
A button that closes the dialog when pressed
|
|
224
|
+
|
|
225
|
+
- kind: definitions
|
|
226
|
+
for: all
|
|
227
|
+
context: keyboard
|
|
228
|
+
items:
|
|
229
|
+
- term: Tab / Shift+Tab
|
|
230
|
+
definition: >-
|
|
231
|
+
Cycle within the dialog
|
|
232
|
+
- term: Escape
|
|
233
|
+
definition: >-
|
|
234
|
+
Close and return focus to the opening button
|
|
235
|
+
|
|
236
|
+
- kind: section
|
|
237
|
+
for: all
|
|
238
|
+
title: Open decisions
|
|
239
|
+
freeform:
|
|
240
|
+
- title: TODO
|
|
241
|
+
body: >-
|
|
242
|
+
Not yet decided: scrollable long content; whether an outside click should close a
|
|
243
|
+
dialog that has action buttons (Carbon says no, Base UI closes it); switching to
|
|
244
|
+
Drawer on mobile automatically. The `ConfirmDelete` example hasn't been moved to
|
|
245
|
+
AlertDialog yet.
|
|
246
|
+
|
|
247
|
+
sourceFiles:
|
|
248
|
+
- platform: react
|
|
249
|
+
file: ./Dialog.tsx
|
|
250
|
+
|
|
251
|
+
imports:
|
|
252
|
+
- platform: react
|
|
253
|
+
code: >-
|
|
254
|
+
import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "@designil/labdsnov"
|
|
255
|
+
package: "@designil/labdsnov"
|
|
256
|
+
|
|
257
|
+
traits:
|
|
258
|
+
- traitType: variant
|
|
259
|
+
kind: enum
|
|
260
|
+
id: size
|
|
261
|
+
description: >-
|
|
262
|
+
Max width of `DialogContent` on screens 640px and wider
|
|
263
|
+
values:
|
|
264
|
+
- id: sm
|
|
265
|
+
description: >-
|
|
266
|
+
384px, delete confirmations and short forms
|
|
267
|
+
- id: default
|
|
268
|
+
description: >-
|
|
269
|
+
448px, general decisions
|
|
270
|
+
- id: lg
|
|
271
|
+
description: >-
|
|
272
|
+
512px, no usage example yet
|
|
273
|
+
- id: xl
|
|
274
|
+
description: >-
|
|
275
|
+
672px, no usage example yet
|
|
276
|
+
- traitType: variant
|
|
277
|
+
kind: boolean
|
|
278
|
+
id: showCloseButton
|
|
279
|
+
description: >-
|
|
280
|
+
The top-right "ปิด" (close) icon button (default `true`)
|
|
281
|
+
- traitType: state
|
|
282
|
+
kind: boolean
|
|
283
|
+
id: open
|
|
284
|
+
description: >-
|
|
285
|
+
The dialog is open (`data-open`); the page behind can't scroll or be clicked
|
|
286
|
+
|
|
287
|
+
uses:
|
|
288
|
+
- to: button
|
|
289
|
+
alternatives:
|
|
290
|
+
- to: alert-dialog
|
|
291
|
+
- to: drawer
|
|
292
|
+
- to: popover
|
|
293
|
+
|
|
294
|
+
refs:
|
|
295
|
+
- href: ./Dialog.md
|
|
296
|
+
rel: relates-to
|
|
297
|
+
role: Thai usage doc (including Content rules and Open questions)
|
|
298
|
+
- href: ./Dialog.stories.tsx
|
|
299
|
+
rel: demo
|
|
300
|
+
role: CSF stories
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: drawer
|
|
3
|
+
name: Drawer
|
|
4
|
+
description: >-
|
|
5
|
+
A panel that slides in from a screen edge (usually the bottom) and can be swiped
|
|
6
|
+
closed. Suited to mobile. Sits 8px from the screen edge with a 26px corner radius.
|
|
7
|
+
Wraps Base UI's `Drawer`.
|
|
8
|
+
metadata:
|
|
9
|
+
status: {status: stable}
|
|
10
|
+
since: 1.0.0
|
|
11
|
+
tags: [overlay]
|
|
12
|
+
|
|
13
|
+
sections:
|
|
14
|
+
- kind: guidelines
|
|
15
|
+
for: all
|
|
16
|
+
framing: when-to-use
|
|
17
|
+
items:
|
|
18
|
+
- level: should
|
|
19
|
+
statement: >-
|
|
20
|
+
Use for short tasks on mobile, such as a short form, a choice or filters.
|
|
21
|
+
- level: should
|
|
22
|
+
statement: >-
|
|
23
|
+
Use `swipeDirection="right"` for a side panel, such as table filters.
|
|
24
|
+
example:
|
|
25
|
+
ref:
|
|
26
|
+
href: ./Drawer.stories.tsx#FromRight
|
|
27
|
+
rel: demo
|
|
28
|
+
- level: must-not
|
|
29
|
+
statement: >-
|
|
30
|
+
Don't use it to confirm an irreversible action: it's too easy to swipe away.
|
|
31
|
+
Use <dsds:alert-dialog>.
|
|
32
|
+
alternatives:
|
|
33
|
+
- to: alert-dialog
|
|
34
|
+
checkedBy: manual
|
|
35
|
+
- level: should-not
|
|
36
|
+
statement: >-
|
|
37
|
+
Don't use it on wide screens where a centred box fits better. Use <dsds:dialog>.
|
|
38
|
+
alternatives:
|
|
39
|
+
- to: dialog
|
|
40
|
+
- level: should-not
|
|
41
|
+
statement: >-
|
|
42
|
+
Don't use it as a command menu. Use <dsds:dropdown-menu>.
|
|
43
|
+
alternatives:
|
|
44
|
+
- to: dropdown-menu
|
|
45
|
+
|
|
46
|
+
- kind: guidelines
|
|
47
|
+
for: all
|
|
48
|
+
items:
|
|
49
|
+
- id: title-required
|
|
50
|
+
level: must
|
|
51
|
+
statement: >-
|
|
52
|
+
Always include `DrawerTitle`: it's the panel's name for screen readers. Add a
|
|
53
|
+
`DrawerDescription` that states the outcome or condition, e.g.
|
|
54
|
+
"เงินจะเข้าบัญชีภายใน 3 วันทำการ" (funds arrive within 3 business days).
|
|
55
|
+
checks:
|
|
56
|
+
- href: ./Drawer.stories.tsx#OpenAndClose
|
|
57
|
+
role: test
|
|
58
|
+
note: play function checks toHaveAccessibleDescription
|
|
59
|
+
checkedBy: automated
|
|
60
|
+
- id: footer-primary-first
|
|
61
|
+
level: must
|
|
62
|
+
statement: >-
|
|
63
|
+
`DrawerFooter` stacks buttons downward. The primary button goes on top, nearest
|
|
64
|
+
the thumb ("ยืนยัน", confirm), followed by
|
|
65
|
+
`DrawerClose render={<Button variant="outline" />}` ("ยกเลิก", cancel). This is
|
|
66
|
+
the reverse of Dialog, where cancel comes first.
|
|
67
|
+
checkedBy: manual
|
|
68
|
+
- id: swipe-handle-bottom
|
|
69
|
+
level: should
|
|
70
|
+
statement: >-
|
|
71
|
+
Bottom panels set `showSwipeHandle` so it's clear they can be swiped closed.
|
|
72
|
+
Side panels don't need one.
|
|
73
|
+
checkedBy: manual
|
|
74
|
+
- id: short-content
|
|
75
|
+
level: should
|
|
76
|
+
statement: >-
|
|
77
|
+
Keep content within the maximum height (screen height minus 96px). Move anything
|
|
78
|
+
longer to its own page.
|
|
79
|
+
checkedBy: manual
|
|
80
|
+
- id: trigger-render
|
|
81
|
+
level: must
|
|
82
|
+
statement: >-
|
|
83
|
+
Write the opening button as `<DrawerTrigger render={<Button variant="outline" />}>`.
|
|
84
|
+
refs:
|
|
85
|
+
- to: shared-composition#render-prop
|
|
86
|
+
rel: relates-to
|
|
87
|
+
checkedBy: assisted
|
|
88
|
+
|
|
89
|
+
- kind: guidelines
|
|
90
|
+
for: all
|
|
91
|
+
title: Accessibility
|
|
92
|
+
tags: [accessibility]
|
|
93
|
+
items:
|
|
94
|
+
- id: not-swipe-only
|
|
95
|
+
level: must
|
|
96
|
+
statement: >-
|
|
97
|
+
It must close without swiping: include a `DrawerClose` button in the footer, and
|
|
98
|
+
Escape closes it.
|
|
99
|
+
evidence:
|
|
100
|
+
- href: https://www.w3.org/WAI/WCAG22/Understanding/dragging-movements.html
|
|
101
|
+
role: WCAG 2.2 SC 2.5.7 (AA)
|
|
102
|
+
checks:
|
|
103
|
+
- href: ./Drawer.stories.tsx#OpenAndClose
|
|
104
|
+
role: test
|
|
105
|
+
note: play function closes with the "ยกเลิก" button, then checks aria-expanded="false"
|
|
106
|
+
checkedBy: automated
|
|
107
|
+
- id: modal-focus
|
|
108
|
+
level: must
|
|
109
|
+
statement: >-
|
|
110
|
+
`modal` (default `true`) adds a dark backdrop, traps focus in the panel and
|
|
111
|
+
blocks the page behind. Don't set `modal={false}` on a panel that holds a form.
|
|
112
|
+
checkedBy: manual
|
|
113
|
+
|
|
114
|
+
- kind: definitions
|
|
115
|
+
for: all
|
|
116
|
+
context: anatomy
|
|
117
|
+
items:
|
|
118
|
+
- term: Drawer
|
|
119
|
+
definition: >-
|
|
120
|
+
Root. Takes `swipeDirection`, `showSwipeHandle`, `open` / `onOpenChange`, `modal`,
|
|
121
|
+
`snapPoints`.
|
|
122
|
+
- term: DrawerTrigger
|
|
123
|
+
definition: >-
|
|
124
|
+
The opening button.
|
|
125
|
+
- term: DrawerContent
|
|
126
|
+
definition: >-
|
|
127
|
+
The panel. From the bottom/top it's full width and as tall as its content; from
|
|
128
|
+
a side it's 75% wide on mobile and 384px from 640px screens.
|
|
129
|
+
- term: DrawerHeader
|
|
130
|
+
definition: >-
|
|
131
|
+
Title + Description. Centred on mobile, left-aligned from 768px screens.
|
|
132
|
+
- term: DrawerFooter
|
|
133
|
+
definition: >-
|
|
134
|
+
Buttons, stacked downward.
|
|
135
|
+
- term: DrawerClose
|
|
136
|
+
definition: >-
|
|
137
|
+
Close button (`render={<Button />}`).
|
|
138
|
+
|
|
139
|
+
- kind: section
|
|
140
|
+
for: all
|
|
141
|
+
title: Open decisions
|
|
142
|
+
freeform:
|
|
143
|
+
- title: TODO
|
|
144
|
+
body: >-
|
|
145
|
+
Not yet decided whether to switch automatically between Dialog (wide screens) and
|
|
146
|
+
Drawer (mobile). There's no `snapPoints` example yet.
|
|
147
|
+
|
|
148
|
+
sourceFiles:
|
|
149
|
+
- platform: react
|
|
150
|
+
file: ./Drawer.tsx
|
|
151
|
+
|
|
152
|
+
imports:
|
|
153
|
+
- platform: react
|
|
154
|
+
code: >-
|
|
155
|
+
import { Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger } from "@designil/labdsnov"
|
|
156
|
+
package: "@designil/labdsnov"
|
|
157
|
+
|
|
158
|
+
traits:
|
|
159
|
+
- traitType: variant
|
|
160
|
+
kind: enum
|
|
161
|
+
id: swipeDirection
|
|
162
|
+
description: >-
|
|
163
|
+
The direction to swipe to close, and the edge the panel slides in from.
|
|
164
|
+
values:
|
|
165
|
+
- id: down
|
|
166
|
+
description: >-
|
|
167
|
+
From the bottom (default).
|
|
168
|
+
- id: up
|
|
169
|
+
description: >-
|
|
170
|
+
From the top.
|
|
171
|
+
- id: left
|
|
172
|
+
description: >-
|
|
173
|
+
From the left.
|
|
174
|
+
- id: right
|
|
175
|
+
description: >-
|
|
176
|
+
From the right, e.g. table filters.
|
|
177
|
+
- traitType: variant
|
|
178
|
+
kind: boolean
|
|
179
|
+
id: showSwipeHandle
|
|
180
|
+
description: >-
|
|
181
|
+
A grab bar for swiping.
|
|
182
|
+
- traitType: state
|
|
183
|
+
kind: boolean
|
|
184
|
+
id: open
|
|
185
|
+
description: >-
|
|
186
|
+
The panel is open.
|
|
187
|
+
|
|
188
|
+
combos:
|
|
189
|
+
- subject: showSwipeHandle
|
|
190
|
+
level: should-not
|
|
191
|
+
items: [swipeDirection.left, swipeDirection.right]
|
|
192
|
+
note: >-
|
|
193
|
+
The grab bar is designed for bottom/top panels.
|
|
194
|
+
|
|
195
|
+
uses:
|
|
196
|
+
- to: button
|
|
197
|
+
alternatives:
|
|
198
|
+
- to: dialog
|
|
199
|
+
- to: alert-dialog
|
|
200
|
+
|
|
201
|
+
refs:
|
|
202
|
+
- href: ./Drawer.md
|
|
203
|
+
rel: relates-to
|
|
204
|
+
role: Thai usage doc
|
|
205
|
+
- href: ./Drawer.stories.tsx
|
|
206
|
+
rel: demo
|
|
207
|
+
role: CSF stories
|