@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,224 @@
1
+ kind: component
2
+ id: toggle
3
+ name: Toggle
4
+ description: >-
5
+ A button that stays pressed, showing whether one option is on or off, such as
6
+ showing one series on a chart. Wraps Base UI's `Toggle` and exposes
7
+ `aria-pressed`.
8
+ metadata:
9
+ status: {status: stable}
10
+ since: 1.0.0
11
+ tags: [action, 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 turn a display option on or off with an immediate visible
21
+ effect, such as a chart series or a filter.
22
+ - level: may
23
+ statement: >-
24
+ Use for formatting buttons such as bold.
25
+ - level: must-not
26
+ statement: >-
27
+ Don't use for a setting that is saved permanently (such as turning on
28
+ notifications). Use <dsds:switch>.
29
+ alternatives:
30
+ - to: switch
31
+ checkedBy: manual
32
+ - level: must-not
33
+ statement: >-
34
+ Don't use for confirming something in a form before submitting. Use
35
+ <dsds:checkbox>.
36
+ alternatives:
37
+ - to: checkbox
38
+ checkedBy: manual
39
+ - level: must-not
40
+ statement: >-
41
+ Don't use for a one-off action. Use <dsds:button>.
42
+ alternatives:
43
+ - to: button
44
+ checkedBy: manual
45
+ - level: should-not
46
+ statement: >-
47
+ Don't place several Toggles side by side to pick one of several options.
48
+ Use <dsds:toggle-group>.
49
+ alternatives:
50
+ - to: toggle-group
51
+
52
+ - kind: guidelines
53
+ for: all
54
+ items:
55
+ - id: label-names-thing
56
+ level: must
57
+ statement: >-
58
+ The label names what is turned on or off ("แสดงเงินสมทบจากนายจ้าง",
59
+ "show employer contributions"), never the state ("เปิดอยู่", "on"). The
60
+ pressed look and `aria-pressed` show the state, and the label doesn't
61
+ change.
62
+ checkedBy: manual
63
+ - id: immediate-effect
64
+ level: should
65
+ statement: >-
66
+ Apply the change in `onPressedChange` straight away. A Toggle that only
67
+ takes effect after a later "save" belongs in a form as a Checkbox.
68
+ checks:
69
+ - href: ./Toggle.stories.tsx#Pressing
70
+ role: test
71
+ note: play function checks aria-pressed flips and onPressedChange is called
72
+ checkedBy: automated
73
+ - id: outline-standalone
74
+ level: should
75
+ statement: >-
76
+ Use `variant="outline"` for a Toggle standing on its own on the page,
77
+ so it reads as a control before it's pressed. `default` (no border until
78
+ pressed) suits toolbars.
79
+ example:
80
+ ref:
81
+ href: ./Toggle.stories.tsx#Variants
82
+ rel: demo
83
+ checkedBy: manual
84
+ - id: size-matches-row
85
+ level: should
86
+ statement: >-
87
+ Match `size` to the buttons beside it: `sm` 32px, `default` 36px, `lg`
88
+ 40px.
89
+ checkedBy: manual
90
+
91
+ - kind: guidelines
92
+ for: all
93
+ title: Accessibility
94
+ tags: [accessibility]
95
+ items:
96
+ - id: icon-only-label
97
+ level: must
98
+ statement: >-
99
+ An icon-only Toggle has a Thai `aria-label` naming the option, such as
100
+ "ตัวหนา" (bold).
101
+ refines:
102
+ - to: shared-a11y#icon-only-label
103
+ checks:
104
+ - href: ./Toggle.stories.tsx#IconOnly
105
+ role: test
106
+ checkedBy: automated
107
+ - id: keyboard-toggle
108
+ level: must
109
+ statement: >-
110
+ Tab reaches the Toggle and Space or Enter flips `aria-pressed`.
111
+ evidence:
112
+ - href: https://www.w3.org/WAI/ARIA/apg/patterns/button/
113
+ role: WAI-ARIA APG Button pattern (toggle button)
114
+ checks:
115
+ - href: ./Toggle.stories.tsx#Keyboard
116
+ role: test
117
+ checkedBy: automated
118
+ - id: toggle-contrast
119
+ level: must
120
+ statement: >-
121
+ Unpressed text is 5.97:1 light / 8.43:1 dark, hover text 17.76:1 /
122
+ 13.79:1, pressed text 17.76:1 / 13.79:1, and the pressed edge 3.93:1 /
123
+ 4.05:1. The pressed state relies on that edge, so don't remove it with
124
+ `className`.
125
+ refines:
126
+ - to: shared-a11y#non-text-contrast
127
+ checks:
128
+ - href: ../../../scripts/tokens.mjs
129
+ role: test
130
+ note: CONTRAST_PAIRS "Toggle …"
131
+ checkedBy: automated
132
+ - refs:
133
+ - to: shared-a11y#focus-ring
134
+ rel: same-as
135
+
136
+ - kind: guidelines
137
+ for: agent
138
+ items:
139
+ - refs:
140
+ - to: shared-testing#disabled-check-by-attribute
141
+ rel: same-as
142
+
143
+ - kind: definitions
144
+ for: all
145
+ title: States
146
+ context: labdsnov.states
147
+ items:
148
+ - term: Not pressed
149
+ definition: >-
150
+ Secondary text colour.
151
+ - term: Hover
152
+ definition: >-
153
+ Faint background, darker text. Check by hand (can't be forced in a story).
154
+ - term: Pressed
155
+ definition: >-
156
+ Faint background, dark edge (3:1), dark text, `aria-pressed="true"`.
157
+ - term: Keyboard focus
158
+ definition: >-
159
+ Solid `--focus-ring` ring.
160
+ - term: Disabled
161
+ definition: >-
162
+ Dimmed to 50%.
163
+
164
+ sourceFiles:
165
+ - platform: react
166
+ file: ./Toggle.tsx
167
+
168
+ imports:
169
+ - platform: react
170
+ code: >-
171
+ import { Toggle, toggleVariants } from "@designil/labdsnov"
172
+ package: "@designil/labdsnov"
173
+
174
+ traits:
175
+ - traitType: variant
176
+ kind: enum
177
+ id: variant
178
+ description: >-
179
+ How the Toggle looks before and after it's pressed.
180
+ values:
181
+ - id: default
182
+ description: >-
183
+ No border until pressed. For toolbars.
184
+ - id: outline
185
+ description: >-
186
+ A faint border at all times. For a Toggle on its own.
187
+ - traitType: variant
188
+ kind: enum
189
+ id: size
190
+ description: >-
191
+ Height and padding.
192
+ values:
193
+ - id: default
194
+ description: >-
195
+ 36px.
196
+ - id: sm
197
+ description: >-
198
+ 32px.
199
+ - id: lg
200
+ description: >-
201
+ 40px.
202
+ - traitType: state
203
+ kind: boolean
204
+ id: pressed
205
+ description: >-
206
+ On (`pressed` / `defaultPressed`), shown with `aria-pressed="true"`.
207
+ - traitType: state
208
+ kind: boolean
209
+ id: disabled
210
+ description: >-
211
+ Disabled, dimmed to 50%.
212
+
213
+ alternatives:
214
+ - to: switch
215
+ - to: toggle-group
216
+ - to: checkbox
217
+
218
+ refs:
219
+ - href: ./Toggle.md
220
+ rel: relates-to
221
+ role: usage doc (Thai)
222
+ - href: ./Toggle.stories.tsx
223
+ rel: demo
224
+ role: CSF stories
@@ -0,0 +1,230 @@
1
+ kind: component
2
+ id: toggle-group
3
+ name: ToggleGroup
4
+ description: >-
5
+ A group of press-and-hold buttons for picking one option (or several with
6
+ `multiple`) with an immediate effect, such as a chart's time range. Each item
7
+ looks like a Toggle and takes its `variant` and `size` from the group.
8
+ metadata:
9
+ status: {status: stable}
10
+ since: 1.0.0
11
+ tags: [action, 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 change how data on the same page is shown, such as a
21
+ <dsds:chart>'s range ("1 เดือน" / "6 เดือน" / "1 ปี", 1 month / 6
22
+ months / 1 year).
23
+ uses:
24
+ - to: chart
25
+ - level: may
26
+ statement: >-
27
+ Use `multiple` for formatting that can combine, such as bold and italic.
28
+ example:
29
+ ref:
30
+ href: ./ToggleGroup.stories.tsx#Multiple
31
+ rel: demo
32
+ - level: must-not
33
+ statement: >-
34
+ Don't use to switch between different sections of content. Use
35
+ <dsds:tabs>.
36
+ alternatives:
37
+ - to: tabs
38
+ checkedBy: manual
39
+ - level: must-not
40
+ statement: >-
41
+ Don't use for a form value that is sent on submit. Use
42
+ <dsds:radio-group> (or <dsds:checkbox> for several values).
43
+ alternatives:
44
+ - to: radio-group
45
+ - to: checkbox
46
+ checkedBy: manual
47
+ - level: should-not
48
+ statement: >-
49
+ Don't use for more than 5 options. Use <dsds:select>.
50
+ alternatives:
51
+ - to: select
52
+ - level: should-not
53
+ statement: >-
54
+ Don't use for a row of command buttons. Use <dsds:button-group>.
55
+ alternatives:
56
+ - to: button-group
57
+
58
+ - kind: guidelines
59
+ for: all
60
+ items:
61
+ - id: value-is-array
62
+ level: must
63
+ statement: >-
64
+ `value` / `defaultValue` are always arrays, even with one choice
65
+ (`defaultValue={["6m"]}`). A plain string selects nothing.
66
+ checks:
67
+ - href: ./ToggleGroup.stories.tsx#SingleChoice
68
+ role: test
69
+ note: play function checks the preset item is pressed and clicking another moves the selection
70
+ checkedBy: automated
71
+ - id: preselect-one
72
+ level: should
73
+ statement: >-
74
+ When the group picks one view, set a `defaultValue` so a view is always
75
+ shown. Whether pressing the selected item again may clear it isn't
76
+ decided (see Open decisions).
77
+ checkedBy: manual
78
+ - id: joined-bar
79
+ level: should
80
+ statement: >-
81
+ A range picker uses `variant="outline"`, `size="sm"` and `spacing={0}`
82
+ to form one bar. `spacing` is in 4px units (default 2).
83
+ example:
84
+ ref:
85
+ href: ./ToggleGroup.stories.tsx#Playground
86
+ rel: demo
87
+ checkedBy: manual
88
+ - id: short-labels
89
+ level: should
90
+ statement: >-
91
+ Item labels are 1–2 words and the same length class, so the bar stays
92
+ even.
93
+ checkedBy: manual
94
+ - id: item-value-required
95
+ level: must
96
+ statement: >-
97
+ Every `ToggleGroupItem` has a unique `value` (required). Styling comes
98
+ from the group, so don't set `variant` or `size` per item.
99
+ checkedBy: manual
100
+
101
+ - kind: guidelines
102
+ for: all
103
+ title: Accessibility
104
+ tags: [accessibility]
105
+ items:
106
+ - id: group-label
107
+ level: must
108
+ statement: >-
109
+ Always give the group an `aria-label` saying what is being chosen
110
+ ("ช่วงเวลาของกราฟ", chart time range).
111
+ evidence:
112
+ - href: https://www.w3.org/WAI/WCAG22/Understanding/name-role-value.html
113
+ role: WCAG 2.2 SC 4.1.2 (A)
114
+ checkedBy: manual
115
+ - id: icon-only-label
116
+ level: must
117
+ statement: >-
118
+ An icon-only item has a Thai `aria-label`, such as "ตัวหนา" (bold).
119
+ refines:
120
+ - to: shared-a11y#icon-only-label
121
+ checkedBy: assisted
122
+ - id: arrow-keys
123
+ level: must
124
+ statement: >-
125
+ Tab enters the group, the arrow keys move between items (left/right, or
126
+ up/down when `orientation="vertical"`), and Space or Enter selects.
127
+ evidence:
128
+ - href: https://www.w3.org/WAI/ARIA/apg/patterns/toolbar/
129
+ role: WAI-ARIA APG Toolbar pattern
130
+ checks:
131
+ - href: ./ToggleGroup.stories.tsx#Keyboard
132
+ role: test
133
+ checkedBy: automated
134
+ - id: pressed-contrast
135
+ level: must
136
+ statement: >-
137
+ The selected item uses the Toggle pressed tokens: text 17.76:1 /
138
+ 13.79:1 and edge 3.93:1 / 4.05:1. Unselected text is 5.97:1 / 8.43:1.
139
+ refs:
140
+ - to: toggle#toggle-contrast
141
+ rel: relates-to
142
+ checks:
143
+ - href: ../../../scripts/tokens.mjs
144
+ role: test
145
+ note: CONTRAST_PAIRS "Toggle …"
146
+ checkedBy: automated
147
+
148
+ - kind: definitions
149
+ for: all
150
+ context: anatomy
151
+ items:
152
+ - term: ToggleGroup
153
+ definition: >-
154
+ The group. Takes `variant`, `size`, `spacing`, `orientation`,
155
+ `multiple`, `value` / `onValueChange`, `defaultValue`, `disabled`.
156
+ - term: ToggleGroupItem
157
+ definition: >-
158
+ One option. Takes `value` (required), `disabled`, `aria-label`.
159
+
160
+ - kind: definitions
161
+ for: all
162
+ context: keyboard
163
+ items:
164
+ - term: Tab
165
+ definition: >-
166
+ Enter or leave the group.
167
+ - term: Arrow keys
168
+ definition: >-
169
+ Move between items along `orientation`.
170
+ - term: Space / Enter
171
+ definition: >-
172
+ Select the focused item.
173
+
174
+ - kind: section
175
+ for: all
176
+ title: Open decisions
177
+ freeform:
178
+ - title: TODO
179
+ body: >-
180
+ Without `multiple`, whether pressing the selected item again may clear
181
+ the selection isn't decided.
182
+
183
+ sourceFiles:
184
+ - platform: react
185
+ file: ./ToggleGroup.tsx
186
+
187
+ imports:
188
+ - platform: react
189
+ code: >-
190
+ import { ToggleGroup, ToggleGroupItem } from "@designil/labdsnov"
191
+ package: "@designil/labdsnov"
192
+
193
+ traits:
194
+ - traitType: variant
195
+ kind: boolean
196
+ id: multiple
197
+ description: >-
198
+ Several items can be selected.
199
+ - traitType: variant
200
+ kind: enum
201
+ id: orientation
202
+ description: >-
203
+ Direction of the group, and which arrow keys move.
204
+ values:
205
+ - id: horizontal
206
+ description: >-
207
+ A row (default).
208
+ - id: vertical
209
+ description: >-
210
+ A column.
211
+ - traitType: state
212
+ kind: boolean
213
+ id: disabled
214
+ description: >-
215
+ The whole group, or one item, is disabled.
216
+
217
+ uses:
218
+ - to: toggle
219
+ alternatives:
220
+ - to: tabs
221
+ - to: radio-group
222
+ - to: button-group
223
+
224
+ refs:
225
+ - href: ./ToggleGroup.md
226
+ rel: relates-to
227
+ role: usage doc (Thai)
228
+ - href: ./ToggleGroup.stories.tsx
229
+ rel: demo
230
+ role: CSF stories
@@ -0,0 +1,202 @@
1
+ kind: component
2
+ id: tooltip
3
+ name: Tooltip
4
+ description: >-
5
+ A short text that floats up when a button is pointed at or focused,
6
+ explaining what that button or word is. Inverted colours, 12px text, at most
7
+ 320px wide, with an arrow. Wraps Base UI's `Tooltip`.
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 to explain an icon-only button, with the same text as its
21
+ `aria-label`.
22
+ - level: should
23
+ statement: >-
24
+ Use for a short explanation of a term, such as fees or investment units.
25
+ - level: must-not
26
+ statement: >-
27
+ Don't put information the user needs to finish a task in a Tooltip.
28
+ Show it on the page (such as `FieldDescription`), because phones have no
29
+ hover.
30
+ alternatives:
31
+ - to: field
32
+ checkedBy: manual
33
+ - level: must-not
34
+ statement: >-
35
+ Don't put links, buttons or several lines in a Tooltip. Use
36
+ <dsds:popover>.
37
+ alternatives:
38
+ - to: popover
39
+ checkedBy: manual
40
+ - level: must-not
41
+ statement: >-
42
+ Don't use for error messages. Use `FieldError` or <dsds:alert>.
43
+ alternatives:
44
+ - to: alert
45
+ checkedBy: manual
46
+ - level: should-not
47
+ statement: >-
48
+ Don't use for a preview of where a link goes. Use <dsds:hover-card>.
49
+ alternatives:
50
+ - to: hover-card
51
+
52
+ - kind: guidelines
53
+ for: all
54
+ items:
55
+ - id: provider-once
56
+ level: must
57
+ statement: >-
58
+ Wrap the app once with `<TooltipProvider>` in the root layout. It shares
59
+ the open delay between tooltips (`delay`, default 0, opens at once).
60
+ refs:
61
+ - to: labdsnov#mount-providers-once
62
+ rel: relates-to
63
+ checkedBy: manual
64
+ - id: focusable-trigger
65
+ level: must
66
+ statement: >-
67
+ The trigger is something focusable, written as
68
+ `<TooltipTrigger render={<Button size="icon-sm" variant="ghost" aria-label="…" />}>`,
69
+ so keyboard users can open it. Never put a tooltip on plain text or a
70
+ disabled button that can't take focus.
71
+ refs:
72
+ - to: shared-composition#render-prop
73
+ rel: relates-to
74
+ uses:
75
+ - to: button
76
+ checkedBy: assisted
77
+ - id: matches-label
78
+ level: should
79
+ statement: >-
80
+ On an icon-only button the tooltip text equals the `aria-label` ("ตั้งค่า",
81
+ settings), so sighted and screen reader users get the same name.
82
+ checkedBy: manual
83
+ - id: one-line
84
+ level: should
85
+ statement: >-
86
+ Keep the text to one short sentence, no ending punctuation needed
87
+ ("หักจากบัญชีทุกเดือน 0.15% ของยอดเงิน", deducted monthly, 0.15% of the
88
+ balance).
89
+ checkedBy: manual
90
+ - id: side-default
91
+ level: may
92
+ statement: >-
93
+ Keep `side="top"` (default). Change it only when the trigger is at the
94
+ top edge.
95
+ example:
96
+ ref:
97
+ href: ./Tooltip.stories.tsx#Sides
98
+ rel: demo
99
+
100
+ - kind: guidelines
101
+ for: all
102
+ title: Accessibility
103
+ tags: [accessibility]
104
+ items:
105
+ - id: focus-and-escape
106
+ level: must
107
+ statement: >-
108
+ Keyboard focus opens the tooltip and Escape closes it without moving
109
+ focus.
110
+ evidence:
111
+ - href: https://www.w3.org/WAI/WCAG22/Understanding/content-on-hover-or-focus.html
112
+ role: WCAG 2.2 SC 1.4.13 (AA)
113
+ - href: https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/
114
+ role: WAI-ARIA APG Tooltip pattern
115
+ checks:
116
+ - href: ./Tooltip.stories.tsx#KeyboardFocus
117
+ role: test
118
+ note: play function tabs to the trigger, checks data-open, presses Escape, checks data-closed
119
+ checkedBy: automated
120
+ - id: tooltip-contrast
121
+ level: must
122
+ statement: >-
123
+ Tooltip text (`--tooltip-fg` on `--tooltip-bg`) is 19.59:1 light /
124
+ 18.93:1 dark, and a Kbd inside it 10.96:1 / 14.60:1.
125
+ checks:
126
+ - href: ../../../scripts/tokens.mjs
127
+ role: test
128
+ note: CONTRAST_PAIRS "Tooltip" and "Kbd ใน Tooltip"
129
+ checkedBy: automated
130
+ - id: not-only-name
131
+ level: must
132
+ statement: >-
133
+ The tooltip doesn't replace `aria-label`. An icon-only trigger still
134
+ needs its own `aria-label`.
135
+ refines:
136
+ - to: shared-a11y#icon-only-label
137
+ checkedBy: assisted
138
+
139
+ - kind: guidelines
140
+ for: agent
141
+ items:
142
+ - refs:
143
+ - to: shared-testing#assert-by-state
144
+ rel: same-as
145
+ - refs:
146
+ - to: shared-testing#query-portal-with-screen
147
+ rel: same-as
148
+ - id: page-focus
149
+ level: must
150
+ statement: >-
151
+ A tooltip opened by keyboard focus in a play function also needs the page
152
+ itself to have focus, or it never opens.
153
+ checkedBy: manual
154
+
155
+ - kind: definitions
156
+ for: all
157
+ context: anatomy
158
+ items:
159
+ - term: TooltipProvider
160
+ definition: >-
161
+ Mounted once near the root. Takes `delay` (ms, default 0).
162
+ - term: Tooltip
163
+ definition: >-
164
+ Root. Takes `open` / `onOpenChange`, `defaultOpen`.
165
+ - term: TooltipTrigger
166
+ definition: >-
167
+ The focusable trigger, rendered as a Button through `render`.
168
+ - term: TooltipContent
169
+ definition: >-
170
+ The bubble with an arrow. Takes `side` (default `top`), `align`
171
+ (`center`), `sideOffset` (4).
172
+
173
+ sourceFiles:
174
+ - platform: react
175
+ file: ./Tooltip.tsx
176
+
177
+ imports:
178
+ - platform: react
179
+ code: >-
180
+ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@designil/labdsnov"
181
+ package: "@designil/labdsnov"
182
+
183
+ traits:
184
+ - traitType: state
185
+ kind: boolean
186
+ id: open
187
+ description: >-
188
+ The tooltip is showing (`data-open`).
189
+
190
+ uses:
191
+ - to: button
192
+ alternatives:
193
+ - to: popover
194
+ - to: hover-card
195
+
196
+ refs:
197
+ - href: ./Tooltip.md
198
+ rel: relates-to
199
+ role: usage doc (Thai)
200
+ - href: ./Tooltip.stories.tsx
201
+ rel: demo
202
+ role: CSF stories