@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,191 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: badge
|
|
3
|
+
name: Badge
|
|
4
|
+
description: >-
|
|
5
|
+
A short text label giving the status or level of the thing next to it, such as
|
|
6
|
+
an item's status or a fund's risk level. 20px high, 12px text, pill-shaped, one
|
|
7
|
+
size only.
|
|
8
|
+
metadata:
|
|
9
|
+
status: {status: stable}
|
|
10
|
+
since: 1.0.0
|
|
11
|
+
tags: [display, status]
|
|
12
|
+
|
|
13
|
+
sections:
|
|
14
|
+
- kind: guidelines
|
|
15
|
+
for: all
|
|
16
|
+
framing: when-to-use
|
|
17
|
+
items:
|
|
18
|
+
- level: should
|
|
19
|
+
statement: >-
|
|
20
|
+
Use for an item's status, e.g. succeeded / pending / failed.
|
|
21
|
+
- level: should
|
|
22
|
+
statement: >-
|
|
23
|
+
Use for a fund's risk level.
|
|
24
|
+
- level: may
|
|
25
|
+
statement: >-
|
|
26
|
+
Make it a link with `render={<a href="…" />}` when the label has a
|
|
27
|
+
destination page, e.g. "แนะนำ" (recommended) linking to the fund page.
|
|
28
|
+
example:
|
|
29
|
+
ref:
|
|
30
|
+
href: ./Badge.stories.tsx#AsLink
|
|
31
|
+
rel: demo
|
|
32
|
+
- level: must-not
|
|
33
|
+
statement: >-
|
|
34
|
+
Never use it as a button for an action (save, send, cancel). A badge isn't a
|
|
35
|
+
button and has no hover style; use <dsds:button>.
|
|
36
|
+
alternatives:
|
|
37
|
+
- to: button
|
|
38
|
+
checkedBy: manual
|
|
39
|
+
- level: must-not
|
|
40
|
+
statement: >-
|
|
41
|
+
Never put long text or sentences in it. The badge has a fixed height and the
|
|
42
|
+
text doesn't wrap, so it overflows the badge.
|
|
43
|
+
checkedBy: manual
|
|
44
|
+
- level: should-not
|
|
45
|
+
statement: >-
|
|
46
|
+
Don't use it for a message users must act on; use <dsds:alert>.
|
|
47
|
+
alternatives:
|
|
48
|
+
- to: alert
|
|
49
|
+
|
|
50
|
+
- kind: guidelines
|
|
51
|
+
for: all
|
|
52
|
+
items:
|
|
53
|
+
- id: risk-mapping
|
|
54
|
+
level: must
|
|
55
|
+
statement: >-
|
|
56
|
+
Low risk = `success`, medium = `warning`, high = `destructive`. Use this set
|
|
57
|
+
everywhere a fund's risk is shown, with the full text ("ความเสี่ยงต่ำ" low
|
|
58
|
+
risk).
|
|
59
|
+
example:
|
|
60
|
+
ref:
|
|
61
|
+
href: ./Badge.stories.tsx#RiskLevels
|
|
62
|
+
rel: demo
|
|
63
|
+
checkedBy: manual
|
|
64
|
+
- id: status-mapping
|
|
65
|
+
level: must
|
|
66
|
+
statement: >-
|
|
67
|
+
Item status: succeeded = `success`, pending = `warning`, failed =
|
|
68
|
+
`destructive`. General labels (e.g. "แนะนำ" recommended) use `outline`.
|
|
69
|
+
checkedBy: manual
|
|
70
|
+
- id: short-label
|
|
71
|
+
level: should
|
|
72
|
+
statement: >-
|
|
73
|
+
1–2 words. Icons in a badge are 12px, placed before the text.
|
|
74
|
+
checkedBy: manual
|
|
75
|
+
- id: tinted-is-quieter
|
|
76
|
+
level: should
|
|
77
|
+
statement: >-
|
|
78
|
+
Status badges (`success` / `warning` / `destructive`) use a 10% tint (20% in
|
|
79
|
+
dark mode), so they're quieter than `default` with its solid fill. Don't use
|
|
80
|
+
`default` for status: it competes with primary buttons of the same colour.
|
|
81
|
+
checkedBy: manual
|
|
82
|
+
- id: no-classname-colour
|
|
83
|
+
level: should-not
|
|
84
|
+
statement: >-
|
|
85
|
+
Don't create new badge colours with `className` (e.g. a blue badge); ask for
|
|
86
|
+
a new variant that passes `tokens:check` instead.
|
|
87
|
+
refs:
|
|
88
|
+
- to: shared-composition#classname-one-off
|
|
89
|
+
rel: relates-to
|
|
90
|
+
|
|
91
|
+
- kind: guidelines
|
|
92
|
+
for: all
|
|
93
|
+
title: Accessibility
|
|
94
|
+
tags: [accessibility]
|
|
95
|
+
items:
|
|
96
|
+
- id: text-not-colour
|
|
97
|
+
level: must
|
|
98
|
+
statement: >-
|
|
99
|
+
The meaning must be in the badge's text ("ความเสี่ยงสูง" high risk), not a
|
|
100
|
+
bare red badge.
|
|
101
|
+
evidence:
|
|
102
|
+
- href: https://www.w3.org/WAI/WCAG22/Understanding/use-of-color.html
|
|
103
|
+
role: WCAG 2.2 SC 1.4.1 (A)
|
|
104
|
+
checkedBy: manual
|
|
105
|
+
- id: badge-contrast
|
|
106
|
+
level: must
|
|
107
|
+
statement: >-
|
|
108
|
+
Every variant passes 4.5:1. The pairs closest to the limit are `destructive`
|
|
109
|
+
in a Card in dark mode (4.91:1) and `default` in light mode (4.93:1). Placing
|
|
110
|
+
a badge on any background other than the page or a card needs an extra check.
|
|
111
|
+
checks:
|
|
112
|
+
- href: ../../../scripts/tokens.mjs
|
|
113
|
+
role: test
|
|
114
|
+
note: The "Badge …" pairs in CONTRAST_PAIRS
|
|
115
|
+
checkedBy: automated
|
|
116
|
+
- id: link-focus
|
|
117
|
+
level: must
|
|
118
|
+
statement: >-
|
|
119
|
+
A badge that's a link is focusable, shows the `--focus-ring` ring, and gets
|
|
120
|
+
an underline on hover. A badge that isn't a link isn't in the Tab order.
|
|
121
|
+
refs:
|
|
122
|
+
- to: shared-a11y#focus-ring
|
|
123
|
+
rel: relates-to
|
|
124
|
+
checks:
|
|
125
|
+
- href: ./Badge.stories.tsx#AsLink
|
|
126
|
+
role: test
|
|
127
|
+
note: The play function checks it renders as an <a> with an href
|
|
128
|
+
checkedBy: assisted
|
|
129
|
+
|
|
130
|
+
- kind: section
|
|
131
|
+
for: all
|
|
132
|
+
title: Open decisions
|
|
133
|
+
freeform:
|
|
134
|
+
- title: TODO
|
|
135
|
+
body: >-
|
|
136
|
+
No defined use yet for `default` and `secondary`, whether badges may show
|
|
137
|
+
counts (e.g. number of notifications), or when a badge should have
|
|
138
|
+
`aria-invalid`.
|
|
139
|
+
|
|
140
|
+
sourceFiles:
|
|
141
|
+
- platform: react
|
|
142
|
+
file: ./Badge.tsx
|
|
143
|
+
|
|
144
|
+
imports:
|
|
145
|
+
- platform: react
|
|
146
|
+
code: >-
|
|
147
|
+
import { Badge } from "@designil/labdsnov"
|
|
148
|
+
package: "@designil/labdsnov"
|
|
149
|
+
|
|
150
|
+
traits:
|
|
151
|
+
- traitType: variant
|
|
152
|
+
kind: enum
|
|
153
|
+
id: variant
|
|
154
|
+
description: >-
|
|
155
|
+
What the label means.
|
|
156
|
+
values:
|
|
157
|
+
- id: default
|
|
158
|
+
description: >-
|
|
159
|
+
Solid primary (orange) fill, light text. No defined use yet.
|
|
160
|
+
- id: secondary
|
|
161
|
+
description: >-
|
|
162
|
+
Light grey fill, dark text. No defined use yet.
|
|
163
|
+
- id: outline
|
|
164
|
+
description: >-
|
|
165
|
+
General labels such as "แนะนำ" (recommended). Transparent with a border.
|
|
166
|
+
- id: destructive
|
|
167
|
+
description: >-
|
|
168
|
+
Failed, high risk. Faint red fill, red text.
|
|
169
|
+
- id: success
|
|
170
|
+
description: >-
|
|
171
|
+
Succeeded, low risk. Faint green fill, green text.
|
|
172
|
+
- id: warning
|
|
173
|
+
description: >-
|
|
174
|
+
Pending, medium risk. Faint amber fill, amber text.
|
|
175
|
+
- traitType: variant
|
|
176
|
+
kind: boolean
|
|
177
|
+
id: link
|
|
178
|
+
description: >-
|
|
179
|
+
The badge is a link (`render={<a />}`): underlined on hover and focusable.
|
|
180
|
+
|
|
181
|
+
alternatives:
|
|
182
|
+
- to: button
|
|
183
|
+
- to: alert
|
|
184
|
+
|
|
185
|
+
refs:
|
|
186
|
+
- href: ./Badge.md
|
|
187
|
+
rel: relates-to
|
|
188
|
+
role: Usage doc in Thai
|
|
189
|
+
- href: ./Badge.stories.tsx
|
|
190
|
+
rel: demo
|
|
191
|
+
role: CSF stories
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: breadcrumb
|
|
3
|
+
name: Breadcrumb
|
|
4
|
+
description: >-
|
|
5
|
+
A row of links showing where the current page sits, with a way back to earlier
|
|
6
|
+
pages. 14px muted text; the current page in normal colour; separated by a ›
|
|
7
|
+
chevron.
|
|
8
|
+
metadata:
|
|
9
|
+
status: {status: stable}
|
|
10
|
+
since: 1.0.0
|
|
11
|
+
tags: [navigation]
|
|
12
|
+
|
|
13
|
+
sections:
|
|
14
|
+
- kind: guidelines
|
|
15
|
+
for: all
|
|
16
|
+
framing: when-to-use
|
|
17
|
+
items:
|
|
18
|
+
- level: should
|
|
19
|
+
statement: >-
|
|
20
|
+
Use on pages more than 2 levels deep, e.g. บัญชีของฉัน › ใบแจ้งยอด › ปี 2569
|
|
21
|
+
(My account › Statements › Year 2569).
|
|
22
|
+
- level: should-not
|
|
23
|
+
statement: >-
|
|
24
|
+
Don't add it to top-level pages (just "หน้าแรก" home doesn't help).
|
|
25
|
+
- level: must-not
|
|
26
|
+
statement: >-
|
|
27
|
+
Never use it as the site's main menu; use <dsds:navigation-menu>.
|
|
28
|
+
alternatives:
|
|
29
|
+
- to: navigation-menu
|
|
30
|
+
checkedBy: manual
|
|
31
|
+
- level: must-not
|
|
32
|
+
statement: >-
|
|
33
|
+
Never use it to show ordered steps (there's no stepper component yet).
|
|
34
|
+
Breadcrumb shows position in the page structure, not progress.
|
|
35
|
+
checkedBy: manual
|
|
36
|
+
|
|
37
|
+
- kind: guidelines
|
|
38
|
+
for: all
|
|
39
|
+
items:
|
|
40
|
+
- id: last-is-page
|
|
41
|
+
level: must
|
|
42
|
+
statement: >-
|
|
43
|
+
The last item is a `BreadcrumbPage` (text, not a link) matching the page's
|
|
44
|
+
`h1`.
|
|
45
|
+
checks:
|
|
46
|
+
- href: ./Breadcrumb.stories.tsx#Playground
|
|
47
|
+
role: test
|
|
48
|
+
note: The play function checks there are 3 links and the current page has aria-current="page"
|
|
49
|
+
checkedBy: automated
|
|
50
|
+
- id: next-link-render
|
|
51
|
+
level: must
|
|
52
|
+
statement: >-
|
|
53
|
+
Next.js links use `<BreadcrumbLink render={<Link href="…" />}>`; plain links
|
|
54
|
+
use `href` directly. Never wrap a `Link` around `BreadcrumbLink`.
|
|
55
|
+
example:
|
|
56
|
+
ref:
|
|
57
|
+
href: ./Breadcrumb.stories.tsx#CustomLink
|
|
58
|
+
rel: demo
|
|
59
|
+
checkedBy: manual
|
|
60
|
+
- id: separator-between
|
|
61
|
+
level: must
|
|
62
|
+
statement: >-
|
|
63
|
+
`BreadcrumbSeparator` sits between `BreadcrumbItem`s as a sibling: not inside
|
|
64
|
+
an item, and not after the last item.
|
|
65
|
+
checkedBy: manual
|
|
66
|
+
- id: collapse-middle
|
|
67
|
+
level: should
|
|
68
|
+
statement: >-
|
|
69
|
+
Paths deeper than 4 levels hide the middle items behind `BreadcrumbEllipsis`,
|
|
70
|
+
keeping the first item and the last two.
|
|
71
|
+
example:
|
|
72
|
+
ref:
|
|
73
|
+
href: ./Breadcrumb.stories.tsx#Collapsed
|
|
74
|
+
rel: demo
|
|
75
|
+
checkedBy: manual
|
|
76
|
+
- id: short-names
|
|
77
|
+
level: should
|
|
78
|
+
statement: >-
|
|
79
|
+
Each item's name matches the page name but is short, 1–3 words. Items wrap to
|
|
80
|
+
a new line on narrow screens.
|
|
81
|
+
checkedBy: manual
|
|
82
|
+
|
|
83
|
+
- kind: guidelines
|
|
84
|
+
for: all
|
|
85
|
+
title: Accessibility
|
|
86
|
+
tags: [accessibility]
|
|
87
|
+
items:
|
|
88
|
+
- id: nav-landmark
|
|
89
|
+
level: must
|
|
90
|
+
statement: >-
|
|
91
|
+
`Breadcrumb` is a `<nav aria-label="เส้นทางนำทาง">` (breadcrumb trail) and the
|
|
92
|
+
current page has `aria-current="page"`. Don't change the `aria-label` to
|
|
93
|
+
English.
|
|
94
|
+
evidence:
|
|
95
|
+
- href: https://www.w3.org/WAI/ARIA/apg/patterns/breadcrumb/
|
|
96
|
+
role: WAI-ARIA APG Breadcrumb pattern
|
|
97
|
+
checks:
|
|
98
|
+
- href: ./Breadcrumb.stories.tsx#Playground
|
|
99
|
+
role: test
|
|
100
|
+
checkedBy: automated
|
|
101
|
+
- id: separator-hidden
|
|
102
|
+
level: must
|
|
103
|
+
statement: >-
|
|
104
|
+
Separators and the "…" are hidden from screen readers. A custom separator
|
|
105
|
+
(e.g. "/") goes in as children of `BreadcrumbSeparator` so it stays hidden.
|
|
106
|
+
checkedBy: manual
|
|
107
|
+
|
|
108
|
+
- kind: definitions
|
|
109
|
+
for: all
|
|
110
|
+
context: anatomy
|
|
111
|
+
items:
|
|
112
|
+
- term: Breadcrumb
|
|
113
|
+
definition: >-
|
|
114
|
+
A `<nav>` named "เส้นทางนำทาง" (breadcrumb trail).
|
|
115
|
+
- term: BreadcrumbList
|
|
116
|
+
definition: >-
|
|
117
|
+
An `<ol>`; wraps on narrow screens.
|
|
118
|
+
- term: BreadcrumbItem
|
|
119
|
+
definition: >-
|
|
120
|
+
An `<li>`, one item.
|
|
121
|
+
- term: BreadcrumbLink
|
|
122
|
+
definition: >-
|
|
123
|
+
A link (`href` or `render`); darkens on hover, has a focus ring.
|
|
124
|
+
- term: BreadcrumbPage
|
|
125
|
+
definition: >-
|
|
126
|
+
The current page, `aria-current="page"`.
|
|
127
|
+
- term: BreadcrumbSeparator
|
|
128
|
+
definition: >-
|
|
129
|
+
A › chevron; pass children to use another symbol.
|
|
130
|
+
- term: BreadcrumbEllipsis
|
|
131
|
+
definition: >-
|
|
132
|
+
A "…" standing in for hidden middle items.
|
|
133
|
+
|
|
134
|
+
- kind: section
|
|
135
|
+
for: all
|
|
136
|
+
title: Open decisions
|
|
137
|
+
freeform:
|
|
138
|
+
- title: TODO
|
|
139
|
+
body: >-
|
|
140
|
+
There's no example yet of revealing the items hidden behind
|
|
141
|
+
`BreadcrumbEllipsis` (e.g. with DropdownMenu), and no stepper component.
|
|
142
|
+
|
|
143
|
+
sourceFiles:
|
|
144
|
+
- platform: react
|
|
145
|
+
file: ./Breadcrumb.tsx
|
|
146
|
+
|
|
147
|
+
imports:
|
|
148
|
+
- platform: react
|
|
149
|
+
code: >-
|
|
150
|
+
import { Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator } from "@designil/labdsnov"
|
|
151
|
+
package: "@designil/labdsnov"
|
|
152
|
+
|
|
153
|
+
alternatives:
|
|
154
|
+
- to: navigation-menu
|
|
155
|
+
|
|
156
|
+
refs:
|
|
157
|
+
- href: ./Breadcrumb.md
|
|
158
|
+
rel: relates-to
|
|
159
|
+
role: Usage doc in Thai
|
|
160
|
+
- href: ./Breadcrumb.stories.tsx
|
|
161
|
+
rel: demo
|
|
162
|
+
role: CSF stories
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: button
|
|
3
|
+
name: Button
|
|
4
|
+
description: >-
|
|
5
|
+
A button that triggers an action on the current page, such as submitting a form,
|
|
6
|
+
saving or opening a dialog. Pill-shaped, 14px medium text. Wraps Base UI's
|
|
7
|
+
`Button`.
|
|
8
|
+
metadata:
|
|
9
|
+
status: {status: stable}
|
|
10
|
+
since: 1.0.0
|
|
11
|
+
tags: [action, form]
|
|
12
|
+
|
|
13
|
+
sections:
|
|
14
|
+
- kind: guidelines
|
|
15
|
+
for: all
|
|
16
|
+
framing: when-to-use
|
|
17
|
+
items:
|
|
18
|
+
- level: should
|
|
19
|
+
statement: >-
|
|
20
|
+
Use for actions that happen on the current page, such as "บันทึก" (save),
|
|
21
|
+
"เพิ่มเงินสมทบ" (add contribution) or "ลบ" (delete), including form submit
|
|
22
|
+
buttons and buttons that open a dialog or menu.
|
|
23
|
+
- level: should
|
|
24
|
+
statement: >-
|
|
25
|
+
Use `size="icon"` with `variant="ghost"` for icon-only toolbar buttons, such
|
|
26
|
+
as "ตั้งค่า" (settings).
|
|
27
|
+
- level: must-not
|
|
28
|
+
statement: >-
|
|
29
|
+
Never use Button to go to another page. Use an `<a>` or `Link` with
|
|
30
|
+
`className={buttonVariants({ … })}` instead (story `AsLink`).
|
|
31
|
+
refs:
|
|
32
|
+
- to: shared-composition#link-looks-like-button
|
|
33
|
+
rel: same-as
|
|
34
|
+
- level: must-not
|
|
35
|
+
statement: Never use Button as a status label that can't be pressed; use <dsds:badge>.
|
|
36
|
+
alternatives:
|
|
37
|
+
- to: badge
|
|
38
|
+
checkedBy: manual
|
|
39
|
+
- level: must-not
|
|
40
|
+
statement: >-
|
|
41
|
+
Never use a group of buttons as on/off options; use <dsds:toggle> or
|
|
42
|
+
<dsds:toggle-group>, which carry `aria-pressed`.
|
|
43
|
+
alternatives:
|
|
44
|
+
- to: toggle
|
|
45
|
+
- to: toggle-group
|
|
46
|
+
checkedBy: manual
|
|
47
|
+
|
|
48
|
+
- kind: guidelines
|
|
49
|
+
for: all
|
|
50
|
+
items:
|
|
51
|
+
- id: one-primary
|
|
52
|
+
level: must
|
|
53
|
+
statement: >-
|
|
54
|
+
An area (a card, a dialog, a form's button row) has at most one `default`
|
|
55
|
+
button. Other buttons use `outline`, `secondary` or `ghost`.
|
|
56
|
+
checkedBy: manual
|
|
57
|
+
- id: submit-type
|
|
58
|
+
level: must
|
|
59
|
+
statement: >-
|
|
60
|
+
A form's submit button needs `type="submit"`. The default is
|
|
61
|
+
`type="button"`, which doesn't submit the form.
|
|
62
|
+
checkedBy: manual
|
|
63
|
+
- id: destructive-for-irreversible
|
|
64
|
+
level: must
|
|
65
|
+
statement: >-
|
|
66
|
+
Use `destructive` only for actions that delete or can't be undone, and have
|
|
67
|
+
it open an <dsds:alert-dialog> to confirm first rather than deleting at once.
|
|
68
|
+
uses:
|
|
69
|
+
- to: alert-dialog
|
|
70
|
+
checkedBy: manual
|
|
71
|
+
- id: cancel-is-outline
|
|
72
|
+
level: should
|
|
73
|
+
statement: >-
|
|
74
|
+
The button paired with the primary one, such as "ยกเลิก" (cancel), uses
|
|
75
|
+
`outline` (matching `AlertDialogCancel` and the cancel button in Dialog).
|
|
76
|
+
checkedBy: manual
|
|
77
|
+
- id: default-size
|
|
78
|
+
level: should
|
|
79
|
+
statement: >-
|
|
80
|
+
Use the default `size` (36px) when unsure. Icon buttons use the `icon*` size
|
|
81
|
+
that matches the text buttons next to them (`icon` with `default`,
|
|
82
|
+
`icon-sm` with `sm`).
|
|
83
|
+
checkedBy: manual
|
|
84
|
+
- id: full-width-auth
|
|
85
|
+
level: should
|
|
86
|
+
statement: >-
|
|
87
|
+
Login/register submit buttons use `fullWidth`, not `className="w-full"`.
|
|
88
|
+
checkedBy: manual
|
|
89
|
+
- id: icon-placement
|
|
90
|
+
level: should
|
|
91
|
+
statement: >-
|
|
92
|
+
An icon in a button with text gets `data-icon="inline-start"` or
|
|
93
|
+
`"inline-end"` so the padding on that side tightens to fit. Icons are 16px
|
|
94
|
+
(12px at `xs` and `icon-xs`).
|
|
95
|
+
example:
|
|
96
|
+
ref:
|
|
97
|
+
href: ./Button.stories.tsx#WithIcons
|
|
98
|
+
rel: demo
|
|
99
|
+
checkedBy: manual
|
|
100
|
+
- id: disabled-explain
|
|
101
|
+
level: should
|
|
102
|
+
statement: >-
|
|
103
|
+
If users need to know why they can't press a button, use `disabled` with
|
|
104
|
+
`focusableWhenDisabled` so it stays focusable and can carry an explanation
|
|
105
|
+
(e.g. a <dsds:tooltip>). A plain `disabled` button leaves the Tab order.
|
|
106
|
+
checks:
|
|
107
|
+
- href: ./Button.stories.tsx#FocusableWhenDisabled
|
|
108
|
+
role: test
|
|
109
|
+
note: The play function checks it's focusable, has aria-disabled, and Enter doesn't call onClick
|
|
110
|
+
checkedBy: automated
|
|
111
|
+
- id: secondary-vs-outline
|
|
112
|
+
level: may
|
|
113
|
+
statement: >-
|
|
114
|
+
Secondary actions may use either `outline` or `secondary` (no rule yet, see
|
|
115
|
+
Open decisions).
|
|
116
|
+
- id: no-classname-variant
|
|
117
|
+
level: should-not
|
|
118
|
+
statement: >-
|
|
119
|
+
Don't build a new button look with `className` repeated in several places;
|
|
120
|
+
ask for a new variant instead.
|
|
121
|
+
refs:
|
|
122
|
+
- to: shared-composition#classname-one-off
|
|
123
|
+
rel: same-as
|
|
124
|
+
|
|
125
|
+
- kind: guidelines
|
|
126
|
+
for: all
|
|
127
|
+
title: Content
|
|
128
|
+
tags: [content]
|
|
129
|
+
items:
|
|
130
|
+
- refs:
|
|
131
|
+
- to: shared-content#actions-are-verbs
|
|
132
|
+
rel: same-as
|
|
133
|
+
- refs:
|
|
134
|
+
- to: shared-content#thai-copy
|
|
135
|
+
rel: same-as
|
|
136
|
+
|
|
137
|
+
- kind: guidelines
|
|
138
|
+
for: all
|
|
139
|
+
title: Accessibility
|
|
140
|
+
tags: [accessibility]
|
|
141
|
+
items:
|
|
142
|
+
- id: icon-only-aria-label
|
|
143
|
+
level: must
|
|
144
|
+
statement: >-
|
|
145
|
+
An icon-only button (`size="icon*"`) needs a Thai `aria-label`.
|
|
146
|
+
refines:
|
|
147
|
+
- to: shared-a11y#icon-only-label
|
|
148
|
+
checkedBy: assisted
|
|
149
|
+
- id: contrast-verified
|
|
150
|
+
level: must
|
|
151
|
+
statement: >-
|
|
152
|
+
Every variant's text passes 4.5:1, normal and on hover. The pairs closest to
|
|
153
|
+
the limit are `destructive` on hover (4.70:1 light, 4.74:1 dark) and
|
|
154
|
+
`default` (4.93:1 light). Never lighten `--button-destructive-hover-bg` or
|
|
155
|
+
change `--primary` without running `pnpm tokens:check`.
|
|
156
|
+
evidence:
|
|
157
|
+
- href: https://www.w3.org/WAI/WCAG22/Understanding/contrast-minimum.html
|
|
158
|
+
role: WCAG 2.2 SC 1.4.3 (AA)
|
|
159
|
+
checks:
|
|
160
|
+
- href: ../../../scripts/tokens.mjs
|
|
161
|
+
role: test
|
|
162
|
+
note: All 10 "Button …" pairs in CONTRAST_PAIRS
|
|
163
|
+
checkedBy: automated
|
|
164
|
+
- id: keyboard-focus
|
|
165
|
+
level: must
|
|
166
|
+
statement: >-
|
|
167
|
+
Keyboard focus shows the `--focus-ring` ring on every variant, including
|
|
168
|
+
`destructive` and `link`.
|
|
169
|
+
refs:
|
|
170
|
+
- to: shared-a11y#focus-ring
|
|
171
|
+
rel: relates-to
|
|
172
|
+
checks:
|
|
173
|
+
- href: ./Button.stories.tsx#KeyboardFocus
|
|
174
|
+
role: test
|
|
175
|
+
note: The play function checks that Tab focuses the button (not the ring colour)
|
|
176
|
+
checkedBy: assisted
|
|
177
|
+
- id: xs-target-size
|
|
178
|
+
level: should-not
|
|
179
|
+
statement: >-
|
|
180
|
+
Don't use `xs` / `icon-xs` (24px) as a primary control on mobile, and don't
|
|
181
|
+
place them flush together without spacing: they're exactly the 24px minimum.
|
|
182
|
+
refines:
|
|
183
|
+
- to: shared-a11y#target-size
|
|
184
|
+
evidence:
|
|
185
|
+
- href: https://www.w3.org/WAI/WCAG22/Understanding/target-size-minimum.html
|
|
186
|
+
role: WCAG 2.2 SC 2.5.8 (AA)
|
|
187
|
+
checkedBy: manual
|
|
188
|
+
- refs:
|
|
189
|
+
- to: shared-a11y#no-focus-ring-override
|
|
190
|
+
rel: same-as
|
|
191
|
+
|
|
192
|
+
- kind: guidelines
|
|
193
|
+
for: agent
|
|
194
|
+
items:
|
|
195
|
+
- id: render-not-aschild
|
|
196
|
+
level: must
|
|
197
|
+
statement: >-
|
|
198
|
+
A button that opens a Dialog, Popover, DropdownMenu, etc. is written
|
|
199
|
+
`<DialogTrigger render={<Button variant="outline" />}>`, not a Button nested
|
|
200
|
+
inside the trigger, and never with `asChild`.
|
|
201
|
+
refines:
|
|
202
|
+
- to: shared-composition#render-prop
|
|
203
|
+
checkedBy: assisted
|
|
204
|
+
- id: data-attributes
|
|
205
|
+
level: may
|
|
206
|
+
statement: >-
|
|
207
|
+
App selectors may read `data-variant` and `data-size` from the button (the
|
|
208
|
+
`Clicked` story checks they're always present, even when the prop isn't
|
|
209
|
+
passed).
|
|
210
|
+
checks:
|
|
211
|
+
- href: ./Button.stories.tsx#Clicked
|
|
212
|
+
role: test
|
|
213
|
+
checkedBy: automated
|
|
214
|
+
|
|
215
|
+
- kind: definitions
|
|
216
|
+
for: all
|
|
217
|
+
title: States
|
|
218
|
+
context: labdsnov.states
|
|
219
|
+
items:
|
|
220
|
+
- term: Hover
|
|
221
|
+
definition: >-
|
|
222
|
+
The background darkens or appears; `link` gets an underline. Check by hand
|
|
223
|
+
(can't be forced in a story).
|
|
224
|
+
- term: Pressed (:active)
|
|
225
|
+
definition: >-
|
|
226
|
+
The button moves down 1px.
|
|
227
|
+
- term: Keyboard focus
|
|
228
|
+
definition: >-
|
|
229
|
+
Solid 2px border and ring in `--focus-ring` on every variant.
|
|
230
|
+
- term: Disabled
|
|
231
|
+
definition: >-
|
|
232
|
+
50% opacity and `pointer-events: none`; can't be pressed or focused (except
|
|
233
|
+
with `focusableWhenDisabled`).
|
|
234
|
+
- term: aria-invalid
|
|
235
|
+
definition: >-
|
|
236
|
+
Red border and ring, for a button that is a choice in a form that isn't
|
|
237
|
+
valid yet.
|
|
238
|
+
- term: aria-expanded
|
|
239
|
+
definition: >-
|
|
240
|
+
While its menu or popover is open, `outline` and `ghost` keep their hover
|
|
241
|
+
background so the open state shows.
|
|
242
|
+
|
|
243
|
+
- kind: section
|
|
244
|
+
for: all
|
|
245
|
+
title: Open decisions
|
|
246
|
+
freeform:
|
|
247
|
+
- title: TODO
|
|
248
|
+
body: >-
|
|
249
|
+
There's no rule yet for whether secondary actions use `outline` or
|
|
250
|
+
`secondary`, and no defined use for the `xs`, `sm` and `lg` sizes. Don't
|
|
251
|
+
guess: ask the team.
|
|
252
|
+
|
|
253
|
+
sourceFiles:
|
|
254
|
+
- platform: react
|
|
255
|
+
file: ./Button.tsx
|
|
256
|
+
|
|
257
|
+
imports:
|
|
258
|
+
- platform: react
|
|
259
|
+
code: import { Button, buttonVariants } from "@designil/labdsnov"
|
|
260
|
+
package: "@designil/labdsnov"
|
|
261
|
+
|
|
262
|
+
traits:
|
|
263
|
+
- traitType: variant
|
|
264
|
+
kind: enum
|
|
265
|
+
id: variant
|
|
266
|
+
description: How prominent the button is.
|
|
267
|
+
values:
|
|
268
|
+
- id: default
|
|
269
|
+
description: The area's primary action (one per area). Primary (orange) fill, light text.
|
|
270
|
+
- id: outline
|
|
271
|
+
description: The alternative to the primary button, such as "ยกเลิก" (cancel). Page-coloured fill with a border.
|
|
272
|
+
- id: secondary
|
|
273
|
+
description: A secondary action. Light grey fill.
|
|
274
|
+
- id: ghost
|
|
275
|
+
description: Toolbar and icon buttons. Transparent, with a background on hover.
|
|
276
|
+
- id: destructive
|
|
277
|
+
description: Actions that delete or can't be undone. Faint red fill (10% light, 20% dark), red text.
|
|
278
|
+
- id: link
|
|
279
|
+
description: An in-page action that looks like a text link. Primary-coloured text, underlined on hover.
|
|
280
|
+
- traitType: variant
|
|
281
|
+
kind: enum
|
|
282
|
+
id: size
|
|
283
|
+
description: Height and padding. Every size is pill-shaped.
|
|
284
|
+
values:
|
|
285
|
+
- id: default
|
|
286
|
+
description: 36px, the usual button.
|
|
287
|
+
- id: xs
|
|
288
|
+
description: 24px, 12px text and 12px icons.
|
|
289
|
+
- id: sm
|
|
290
|
+
description: 32px.
|
|
291
|
+
- id: lg
|
|
292
|
+
description: 40px.
|
|
293
|
+
- id: icon
|
|
294
|
+
description: 36×36px icon-only, pairs with `default`.
|
|
295
|
+
- id: icon-xs
|
|
296
|
+
description: 24×24px icon-only, pairs with `xs`.
|
|
297
|
+
- id: icon-sm
|
|
298
|
+
description: 32×32px icon-only, e.g. the "ปิด" (close) button in Dialog.
|
|
299
|
+
- id: icon-lg
|
|
300
|
+
description: 40×40px icon-only, pairs with `lg`.
|
|
301
|
+
- traitType: variant
|
|
302
|
+
kind: boolean
|
|
303
|
+
id: fullWidth
|
|
304
|
+
description: Stretches to the container's width, e.g. login/register buttons.
|
|
305
|
+
- traitType: state
|
|
306
|
+
kind: boolean
|
|
307
|
+
id: disabled
|
|
308
|
+
description: Disabled, 50% opacity, can't be pressed or focused.
|
|
309
|
+
- traitType: state
|
|
310
|
+
kind: boolean
|
|
311
|
+
id: focusableWhenDisabled
|
|
312
|
+
description: Disabled but still in the Tab order, with `aria-disabled="true"`, so it can explain why it can't be pressed.
|
|
313
|
+
|
|
314
|
+
combos:
|
|
315
|
+
- subject: focusableWhenDisabled
|
|
316
|
+
level: must
|
|
317
|
+
items: [disabled]
|
|
318
|
+
note: Has no effect without `disabled`.
|
|
319
|
+
- subject: variant.link
|
|
320
|
+
level: should-not
|
|
321
|
+
items: [fullWidth]
|
|
322
|
+
note: A button that looks like an inline link shouldn't span the full width; use `default` or `outline`.
|
|
323
|
+
|
|
324
|
+
uses:
|
|
325
|
+
- to: shared-composition
|
|
326
|
+
alternatives:
|
|
327
|
+
- to: toggle
|
|
328
|
+
- to: badge
|
|
329
|
+
|
|
330
|
+
refs:
|
|
331
|
+
- href: ./Button.md
|
|
332
|
+
rel: relates-to
|
|
333
|
+
role: Usage doc in Thai (props, all tokens)
|
|
334
|
+
- href: ./Button.stories.tsx
|
|
335
|
+
rel: demo
|
|
336
|
+
role: CSF stories
|
|
337
|
+
- href: https://www.figma.com/design/QsKWb3A53lIh4QBDnAkGHh/labdsnov?node-id=8-674
|
|
338
|
+
rel: design
|
|
339
|
+
role: Button in Figma
|
|
340
|
+
- href: https://www.figma.com/design/QsKWb3A53lIh4QBDnAkGHh/labdsnov?node-id=8-915
|
|
341
|
+
rel: design
|
|
342
|
+
role: Icon Button in Figma
|
|
343
|
+
- href: ../../../figma/Button.figma.ts
|
|
344
|
+
rel: source
|
|
345
|
+
role: Code Connect template
|
|
346
|
+
|
|
347
|
+
$extensions:
|
|
348
|
+
com.figma:
|
|
349
|
+
nodeId: "8:674"
|
|
350
|
+
iconButtonNodeId: "8:915"
|