@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,206 @@
1
+ kind: component
2
+ id: alert
3
+ name: Alert
4
+ description: >-
5
+ An in-page message box for important information or a problem users should know
6
+ about now, which stays visible until it's resolved. Card background, icon on the
7
+ left, text on the right.
8
+ metadata:
9
+ status: {status: stable}
10
+ since: 1.0.0
11
+ tags: [feedback]
12
+
13
+ sections:
14
+ - kind: guidelines
15
+ for: all
16
+ framing: when-to-use
17
+ items:
18
+ - level: should
19
+ statement: >-
20
+ Use for information about this page that must stay visible until resolved,
21
+ e.g. invalid bank details, no beneficiary named yet.
22
+ - level: should
23
+ statement: >-
24
+ Use for errors about the whole form (e.g. it couldn't be submitted), placed
25
+ above the form.
26
+ - level: must-not
27
+ statement: >-
28
+ Never use it for the result of an action that can disappear on its own, such
29
+ as "บันทึกแล้ว" (saved); use a `toast` (<dsds:toaster>).
30
+ alternatives:
31
+ - to: toaster
32
+ checkedBy: manual
33
+ - level: must-not
34
+ statement: >-
35
+ Never use it when users must decide before going on; use <dsds:alert-dialog>
36
+ or <dsds:dialog>.
37
+ alternatives:
38
+ - to: alert-dialog
39
+ - to: dialog
40
+ checkedBy: manual
41
+ - level: must-not
42
+ statement: >-
43
+ Never use it for an error in a single field; use `FieldError` in
44
+ <dsds:field>.
45
+ alternatives:
46
+ - to: field
47
+ checkedBy: manual
48
+ - level: should-not
49
+ statement: >-
50
+ Don't use it for a short status of an item in a table or card; use
51
+ <dsds:badge>.
52
+ alternatives:
53
+ - to: badge
54
+
55
+ - kind: guidelines
56
+ for: all
57
+ items:
58
+ - id: icon-first-child
59
+ level: must
60
+ statement: >-
61
+ The icon (if any) is the first child of `Alert`. The grid layout puts the
62
+ icon on the left and the text on the right; an icon placed after
63
+ `AlertTitle` breaks the layout.
64
+ checkedBy: manual
65
+ - id: destructive-is-error
66
+ level: must
67
+ statement: >-
68
+ `destructive` is only for errors or things that must be fixed. General
69
+ information, advice and things not done yet (e.g. no beneficiary named) use
70
+ `default`.
71
+ checkedBy: manual
72
+ - id: title-says-problem
73
+ level: should
74
+ statement: >-
75
+ `AlertTitle` states the problem in one line ("ไม่สามารถรับเงินสมทบได้",
76
+ contributions can't be received) and `AlertDescription` gives the cause or
77
+ what to do.
78
+ checkedBy: manual
79
+ - id: action-xs
80
+ level: should
81
+ statement: >-
82
+ The button in `AlertAction` (top right) is `Button size="xs"
83
+ variant="outline"`, one button only, with verb text such as "ระบุเลย"
84
+ (add now).
85
+ example:
86
+ ref:
87
+ href: ./Alert.stories.tsx#WithAction
88
+ rel: demo
89
+ uses:
90
+ - to: button
91
+ checkedBy: manual
92
+ - id: no-success-variant
93
+ level: must-not
94
+ statement: >-
95
+ Never build a green or yellow Alert yourself with `className`. Even though
96
+ the `--success` / `--warning` tokens exist, those variants don't yet (see
97
+ Open decisions).
98
+ checkedBy: manual
99
+
100
+ - kind: guidelines
101
+ for: all
102
+ title: Accessibility
103
+ tags: [accessibility]
104
+ items:
105
+ - id: role-alert
106
+ level: must
107
+ statement: >-
108
+ Every Alert has `role="alert"`, so screen readers read it as soon as it
109
+ appears. Show it only when something has actually happened; never leave a
110
+ general-information Alert on every page.
111
+ evidence:
112
+ - href: https://www.w3.org/WAI/ARIA/apg/patterns/alert/
113
+ role: WAI-ARIA APG Alert pattern
114
+ checks:
115
+ - href: ./Alert.stories.tsx#Playground
116
+ role: test
117
+ note: The play function checks role="alert"
118
+ checkedBy: automated
119
+ - id: error-text-contrast
120
+ level: must
121
+ statement: >-
122
+ The red text of `destructive` (`--destructive` on `--card`) passes 6.52:1
123
+ light and 6.98:1 dark. Don't place an Alert on any background other than the
124
+ page or a card without checking.
125
+ checks:
126
+ - href: ../../../scripts/tokens.mjs
127
+ role: test
128
+ note: CONTRAST_PAIRS "ข้อความผิดพลาดใน Card / Alert" (error text in Card / Alert)
129
+ checkedBy: automated
130
+ - id: not-colour-only
131
+ level: must
132
+ statement: >-
133
+ The meaning must be in the text (`AlertTitle`), not only in the red colour or
134
+ the icon.
135
+ evidence:
136
+ - href: https://www.w3.org/WAI/WCAG22/Understanding/use-of-color.html
137
+ role: WCAG 2.2 SC 1.4.1 (A)
138
+ checkedBy: manual
139
+
140
+ - kind: definitions
141
+ for: all
142
+ context: anatomy
143
+ items:
144
+ - term: Alert
145
+ definition: >-
146
+ The frame. Takes `variant` and has `role="alert"`.
147
+ - term: Icon
148
+ definition: >-
149
+ A Hugeicons icon as the first child (optional, see story `WithoutIcon`).
150
+ - term: AlertTitle
151
+ definition: >-
152
+ The title, 14px medium.
153
+ - term: AlertDescription
154
+ definition: >-
155
+ The detail, muted (`default`); links in the text are underlined.
156
+ - term: AlertAction
157
+ definition: >-
158
+ A small button in the top right.
159
+
160
+ - kind: section
161
+ for: all
162
+ title: Open decisions
163
+ freeform:
164
+ - title: TODO
165
+ body: >-
166
+ There are no `success` / `warning` variants yet, and it isn't decided whether
167
+ non-urgent information should use `role="status"` instead of `role="alert"`.
168
+
169
+ sourceFiles:
170
+ - platform: react
171
+ file: ./Alert.tsx
172
+
173
+ imports:
174
+ - platform: react
175
+ code: >-
176
+ import { Alert, AlertAction, AlertDescription, AlertTitle } from "@designil/labdsnov"
177
+ package: "@designil/labdsnov"
178
+
179
+ traits:
180
+ - traitType: variant
181
+ kind: enum
182
+ id: variant
183
+ description: >-
184
+ What the message means.
185
+ values:
186
+ - id: default
187
+ description: >-
188
+ General information. Card background, normal text, muted description.
189
+ - id: destructive
190
+ description: >-
191
+ An error or something to fix. Card background, red text and icon.
192
+
193
+ uses:
194
+ - to: button
195
+ alternatives:
196
+ - to: toaster
197
+ - to: alert-dialog
198
+ - to: badge
199
+
200
+ refs:
201
+ - href: ./Alert.md
202
+ rel: relates-to
203
+ role: Usage doc in Thai
204
+ - href: ./Alert.stories.tsx
205
+ rel: demo
206
+ role: CSF stories
@@ -0,0 +1,243 @@
1
+ kind: component
2
+ id: alert-dialog
3
+ name: AlertDialog
4
+ description: >-
5
+ A modal that must be answered before going on, used to confirm actions that
6
+ can't be undone. No close button in the top right, and clicking outside doesn't
7
+ close it. Wraps Base UI's `AlertDialog`.
8
+ metadata:
9
+ status: {status: stable}
10
+ since: 1.0.0
11
+ tags: [overlay, feedback]
12
+
13
+ sections:
14
+ - kind: guidelines
15
+ for: all
16
+ framing: when-to-use
17
+ items:
18
+ - level: should
19
+ statement: >-
20
+ Use to confirm actions that can't be undone, e.g. removing a beneficiary or
21
+ cancelling a withdrawal request.
22
+ - level: should
23
+ statement: >-
24
+ Use for messages users must acknowledge and answer before going on.
25
+ - level: must-not
26
+ statement: >-
27
+ Never use it to confirm an action that can be undone. Do it at once and show
28
+ a `toast` with an "เลิกทำ" (undo) button (<dsds:toaster>); asking every time
29
+ teaches users to confirm without reading.
30
+ alternatives:
31
+ - to: toaster
32
+ checkedBy: manual
33
+ - level: must-not
34
+ statement: >-
35
+ Never use it for forms or content that can be closed at will; use
36
+ <dsds:dialog>.
37
+ alternatives:
38
+ - to: dialog
39
+ checkedBy: manual
40
+ - level: should-not
41
+ statement: >-
42
+ Don't use it for information that needs no decision; use <dsds:alert> or a
43
+ `toast`.
44
+ alternatives:
45
+ - to: alert
46
+ - to: toaster
47
+
48
+ - kind: guidelines
49
+ for: all
50
+ items:
51
+ - id: action-closes-itself
52
+ level: must
53
+ statement: >-
54
+ `AlertDialogAction` doesn't close the dialog. Control `open` /
55
+ `onOpenChange` and call `setOpen(false)` once the work succeeds; if it fails,
56
+ the dialog must stay open so the user can retry (the component that controls
57
+ `open` must be in a `"use client"` file).
58
+ checkedBy: manual
59
+ - id: cancel-first
60
+ level: must
61
+ statement: >-
62
+ Put `AlertDialogCancel` ("ยกเลิก" cancel) before `AlertDialogAction` in the
63
+ footer. The dialog focuses the first button when it opens, so the safest
64
+ button must get focus first.
65
+ evidence:
66
+ - href: https://www.w3.org/WAI/ARIA/apg/patterns/alertdialog/
67
+ role: WAI-ARIA APG Alert and Message Dialogs pattern
68
+ checks:
69
+ - href: ./AlertDialog.stories.tsx#OpenAndCancel
70
+ role: test
71
+ note: The play function checks that "ยกเลิก" gets focus when the dialog opens
72
+ checkedBy: automated
73
+ - id: destructive-action
74
+ level: must
75
+ statement: >-
76
+ A delete confirmation uses `AlertDialogAction variant="destructive"` with
77
+ text naming what will be deleted ("ลบ" delete, "ลบผู้รับผลประโยชน์" remove
78
+ beneficiary), not "ตกลง" (OK).
79
+ refs:
80
+ - to: shared-content#actions-are-verbs
81
+ rel: relates-to
82
+ checkedBy: manual
83
+ - id: title-is-question
84
+ level: should
85
+ statement: >-
86
+ `AlertDialogTitle` is a question naming the action ("ลบผู้รับผลประโยชน์?"
87
+ remove beneficiary?) and `AlertDialogDescription` states the consequence
88
+ ("การลบนี้ไม่สามารถย้อนกลับได้" this can't be undone).
89
+ checkedBy: manual
90
+ - id: size-sm-short
91
+ level: should
92
+ statement: >-
93
+ Use `size="sm"` (320px, centred text, two equal buttons side by side) for a
94
+ short question with `AlertDialogMedia`, such as a bin icon. Use `default`
95
+ (448px, left-aligned) when the description runs past two lines.
96
+ example:
97
+ ref:
98
+ href: ./AlertDialog.stories.tsx#SmallWithMedia
99
+ rel: demo
100
+ checkedBy: manual
101
+ - id: trigger-render
102
+ level: must
103
+ statement: >-
104
+ The opening button is written `<AlertDialogTrigger render={<Button
105
+ variant="destructive" />}>`.
106
+ refs:
107
+ - to: shared-composition#render-prop
108
+ rel: relates-to
109
+ checkedBy: assisted
110
+ - id: no-close-button
111
+ level: must-not
112
+ statement: >-
113
+ Never add a close button or close-on-outside-click. Users must choose
114
+ "ยกเลิก" (cancel) or the confirm button (Escape still closes). If you need
115
+ those behaviours, use <dsds:dialog>.
116
+ alternatives:
117
+ - to: dialog
118
+ checkedBy: manual
119
+
120
+ - kind: guidelines
121
+ for: all
122
+ title: Accessibility
123
+ tags: [accessibility]
124
+ items:
125
+ - id: role-alertdialog
126
+ level: must
127
+ statement: >-
128
+ The dialog is announced as `alertdialog`, with its description bound through
129
+ `AlertDialogDescription`. Never drop the Description: screen readers use it
130
+ as the accessible description.
131
+ checks:
132
+ - href: ./AlertDialog.stories.tsx#OpenAndCancel
133
+ role: test
134
+ note: The play function checks toHaveAccessibleDescription
135
+ checkedBy: automated
136
+ - id: escape-closes
137
+ level: must
138
+ statement: >-
139
+ Escape closes the dialog and returns focus to the button that opened it (the
140
+ trigger has `aria-expanded="false"`).
141
+ checks:
142
+ - href: ./AlertDialog.stories.tsx#OpenAndCancel
143
+ role: test
144
+ checkedBy: automated
145
+
146
+ - kind: guidelines
147
+ for: agent
148
+ items:
149
+ - refs:
150
+ - to: shared-testing#assert-by-state
151
+ rel: same-as
152
+ - refs:
153
+ - to: shared-testing#query-portal-with-screen
154
+ rel: same-as
155
+
156
+ - kind: definitions
157
+ for: all
158
+ context: anatomy
159
+ items:
160
+ - term: AlertDialog
161
+ definition: >-
162
+ Root. Takes `open` / `onOpenChange` / `defaultOpen`.
163
+ - term: AlertDialogTrigger
164
+ definition: >-
165
+ The opening button; use `render` with Button.
166
+ - term: AlertDialogContent
167
+ definition: >-
168
+ The dialog (portal and overlay built in). Takes `size`.
169
+ - term: AlertDialogHeader
170
+ definition: >-
171
+ Groups Media, Title and Description.
172
+ - term: AlertDialogMedia
173
+ definition: >-
174
+ An icon in a 64px grey circle above the title (top left on wide screens for
175
+ `default`).
176
+ - term: AlertDialogFooter
177
+ definition: >-
178
+ The buttons: a right-aligned row on wide screens; on narrow screens the last
179
+ button is on top.
180
+ - term: AlertDialogAction
181
+ definition: >-
182
+ The confirm button. Takes Button's props; doesn't close the dialog.
183
+ - term: AlertDialogCancel
184
+ definition: >-
185
+ The cancel button, `outline` by default. Always closes the dialog.
186
+
187
+ - kind: definitions
188
+ for: all
189
+ context: keyboard
190
+ items:
191
+ - term: Open
192
+ definition: >-
193
+ Focus moves to the first button in the footer.
194
+ - term: Tab / Shift+Tab
195
+ definition: >-
196
+ Cycle within the dialog.
197
+ - term: Escape
198
+ definition: >-
199
+ Close and return focus to the trigger.
200
+
201
+ sourceFiles:
202
+ - platform: react
203
+ file: ./AlertDialog.tsx
204
+
205
+ imports:
206
+ - platform: react
207
+ code: >-
208
+ import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from "@designil/labdsnov"
209
+ package: "@designil/labdsnov"
210
+
211
+ traits:
212
+ - traitType: variant
213
+ kind: enum
214
+ id: size
215
+ description: >-
216
+ Size of `AlertDialogContent`. On narrow screens every size is 320px wide with
217
+ centred text.
218
+ values:
219
+ - id: default
220
+ description: >-
221
+ 448px wide from 640px screens, left-aligned text.
222
+ - id: sm
223
+ description: >-
224
+ 320px wide, centred text, two equal-width buttons side by side.
225
+ - traitType: state
226
+ kind: boolean
227
+ id: open
228
+ description: >-
229
+ The dialog is open (`data-open`); the rest of the page can't be used.
230
+
231
+ uses:
232
+ - to: button
233
+ alternatives:
234
+ - to: dialog
235
+ - to: toaster
236
+
237
+ refs:
238
+ - href: ./AlertDialog.md
239
+ rel: relates-to
240
+ role: Usage doc in Thai
241
+ - href: ./AlertDialog.stories.tsx
242
+ rel: demo
243
+ role: CSF stories
@@ -0,0 +1,172 @@
1
+ kind: component
2
+ id: avatar
3
+ name: Avatar
4
+ description: >-
5
+ A round profile picture that shows initials instead when there's no image or it
6
+ fails to load. Wraps Base UI's `Avatar`.
7
+ metadata:
8
+ status: {status: stable}
9
+ since: 1.0.0
10
+ tags: [display]
11
+
12
+ sections:
13
+ - kind: guidelines
14
+ for: all
15
+ framing: when-to-use
16
+ items:
17
+ - level: should
18
+ statement: >-
19
+ Use to show who a member, beneficiary or staff member is, next to their name.
20
+ - level: must-not
21
+ statement: >-
22
+ Never use it for images that are content (fund images, documents); use a
23
+ plain `<img>`.
24
+ checkedBy: manual
25
+ - level: must-not
26
+ statement: >-
27
+ Never use an Avatar in place of a name: there must always be a name next to
28
+ it or an image `alt`.
29
+ checkedBy: manual
30
+
31
+ - kind: guidelines
32
+ for: all
33
+ items:
34
+ - id: always-fallback
35
+ level: must
36
+ statement: >-
37
+ Include `AvatarFallback` whenever there's an `AvatarImage`. The fallback shows
38
+ while loading and when the image is broken; without it the circle is empty.
39
+ checks:
40
+ - href: ./Avatar.stories.tsx#ImageFallback
41
+ role: test
42
+ note: The play function checks the initials "สจ" appear when the image fails
43
+ checkedBy: automated
44
+ - id: thai-initials
45
+ level: should
46
+ statement: >-
47
+ Thai initials use the first consonant of the first name and the surname, e.g.
48
+ "สมชาย ใจดี" → "สจ" (rules for leading vowels, tone marks and English names
49
+ aren't defined yet, see Open decisions).
50
+ checkedBy: manual
51
+ - id: size-by-context
52
+ level: should
53
+ statement: >-
54
+ `sm` (24px) in tables and dense lists, `default` (32px) next to names in
55
+ general, `lg` (40px) in card headers or profile pages.
56
+ checkedBy: manual
57
+ - id: group-count
58
+ level: should
59
+ statement: >-
60
+ A group of more than 3 people shows 2–3 Avatars followed by
61
+ `AvatarGroupCount` ("+2"), which sizes itself to match the Avatars in the
62
+ group.
63
+ example:
64
+ ref:
65
+ href: ./Avatar.stories.tsx#Group
66
+ rel: demo
67
+ checkedBy: manual
68
+ - id: badge-not-alone
69
+ level: must-not
70
+ statement: >-
71
+ Never use `AvatarBadge` (the primary-coloured dot in the bottom right) as the
72
+ only status indicator: there must be status text too, and the dot's meaning
73
+ isn't defined yet.
74
+ evidence:
75
+ - href: https://www.w3.org/WAI/WCAG22/Understanding/use-of-color.html
76
+ role: WCAG 2.2 SC 1.4.1 (A)
77
+ checkedBy: manual
78
+
79
+ - kind: guidelines
80
+ for: all
81
+ title: Accessibility
82
+ tags: [accessibility]
83
+ items:
84
+ - id: image-alt
85
+ level: must
86
+ statement: >-
87
+ `AvatarImage` has an `alt` with the person's full name. If the name is
88
+ already written next to it, use `alt=""` so the name isn't read twice.
89
+ evidence:
90
+ - href: https://www.w3.org/WAI/WCAG22/Understanding/non-text-content.html
91
+ role: WCAG 2.2 SC 1.1.1 (A)
92
+ checkedBy: manual
93
+ - id: group-label
94
+ level: must
95
+ statement: >-
96
+ `AvatarGroup` has an `aria-label` giving the total, e.g.
97
+ "ผู้รับผลประโยชน์ 4 คน" (4 beneficiaries), because "+2" alone doesn't say
98
+ what it counts.
99
+ checkedBy: manual
100
+
101
+ - kind: definitions
102
+ for: all
103
+ context: anatomy
104
+ items:
105
+ - term: Avatar
106
+ definition: >-
107
+ The circle. Takes `size`.
108
+ - term: AvatarImage
109
+ definition: >-
110
+ The image (`src`, `alt`), cropped to a circle.
111
+ - term: AvatarFallback
112
+ definition: >-
113
+ Initials on a grey background.
114
+ - term: AvatarBadge
115
+ definition: >-
116
+ A primary-coloured dot in the bottom right, with a ring in the page
117
+ background colour around it.
118
+ - term: AvatarGroup
119
+ definition: >-
120
+ Overlapping Avatars, each separated by a ring in the page background colour.
121
+ - term: AvatarGroupCount
122
+ definition: >-
123
+ A "+N" circle at the end of the group.
124
+
125
+ - kind: section
126
+ for: all
127
+ title: Open decisions
128
+ freeform:
129
+ - title: TODO
130
+ body: >-
131
+ Initials rules (leading vowels, tone marks, English names) and the meaning of
132
+ the `AvatarBadge` dot aren't defined yet.
133
+
134
+ sourceFiles:
135
+ - platform: react
136
+ file: ./Avatar.tsx
137
+
138
+ imports:
139
+ - platform: react
140
+ code: >-
141
+ import { Avatar, AvatarFallback, AvatarImage } from "@designil/labdsnov"
142
+ package: "@designil/labdsnov"
143
+
144
+ traits:
145
+ - traitType: variant
146
+ kind: enum
147
+ id: size
148
+ description: >-
149
+ Diameter.
150
+ values:
151
+ - id: sm
152
+ description: >-
153
+ 24px
154
+ - id: default
155
+ description: >-
156
+ 32px
157
+ - id: lg
158
+ description: >-
159
+ 40px
160
+ - traitType: state
161
+ kind: boolean
162
+ id: fallback
163
+ description: >-
164
+ The image is loading or broken, so initials show instead.
165
+
166
+ refs:
167
+ - href: ./Avatar.md
168
+ rel: relates-to
169
+ role: Usage doc in Thai
170
+ - href: ./Avatar.stories.tsx
171
+ rel: demo
172
+ role: CSF stories