@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,285 @@
1
+ kind: component
2
+ id: field
3
+ name: Field
4
+ description: >-
5
+ Lays out one form field's label, control, help text and error message the same way
6
+ across the system. Includes FieldSet for groups of options and choice cards.
7
+ metadata:
8
+ status: {status: stable}
9
+ since: 1.0.0
10
+ tags: [form, layout]
11
+
12
+ sections:
13
+ - kind: guidelines
14
+ for: all
15
+ framing: when-to-use
16
+ items:
17
+ - level: must
18
+ statement: >-
19
+ Every form control (<dsds:input>, <dsds:textarea>, <dsds:select>, <dsds:checkbox>,
20
+ <dsds:radio-group>, <dsds:switch>) sits in a `Field`, so forms share spacing,
21
+ labels and error messages.
22
+ checkedBy: manual
23
+ - level: should
24
+ statement: >-
25
+ Groups of options (several checkboxes, a radio group) use `FieldSet` +
26
+ `FieldLegend` as the group's name.
27
+ example:
28
+ ref:
29
+ href: ./Field.stories.tsx#RadioSet
30
+ rel: demo
31
+ - level: should
32
+ statement: >-
33
+ Options with long descriptions (e.g. investment plans) become selectable cards:
34
+ `FieldLabel` wraps a whole `Field`. Use this instead of a clickable Card.
35
+ example:
36
+ ref:
37
+ href: ./Field.stories.tsx#ChoiceCards
38
+ rel: demo
39
+ - level: must-not
40
+ statement: >-
41
+ Don't use `FieldError` for an error about the whole form. Use an <dsds:alert>
42
+ above the form.
43
+ alternatives:
44
+ - to: alert
45
+ checkedBy: manual
46
+ - level: may
47
+ statement: >-
48
+ A standalone label with no help text, outside a form, can use <dsds:label>.
49
+
50
+ - kind: guidelines
51
+ for: all
52
+ items:
53
+ - id: describedby-manual
54
+ level: must
55
+ statement: >-
56
+ Field doesn't wire up text for you. Give `FieldDescription` and `FieldError` an
57
+ `id`, and list both in the control's `aria-describedby`
58
+ (`"email-desc email-error"`).
59
+ checks:
60
+ - href: ./Field.stories.tsx#Playground
61
+ role: test
62
+ note: play function checks the control's toHaveAccessibleDescription
63
+ - href: ./Field.stories.tsx#Invalid
64
+ role: test
65
+ checkedBy: automated
66
+ - id: invalid-two-places
67
+ level: must
68
+ statement: >-
69
+ The error state goes in two places: `data-invalid` on `Field` (label and text turn
70
+ red) and `aria-invalid` on the control (red border). Setting only one gives only
71
+ half the effect.
72
+ refines:
73
+ - to: shared-a11y#invalid-has-message
74
+ checkedBy: manual
75
+ - id: disabled-two-places
76
+ level: must
77
+ statement: >-
78
+ To disable, set `data-disabled="true"` on `Field` (label dims to 50%) and
79
+ `disabled` on the control.
80
+ checkedBy: manual
81
+ - id: required-two-places
82
+ level: must
83
+ statement: >-
84
+ `FieldLabel required` only shows a red asterisk. Set `required` on the control
85
+ itself too.
86
+ checkedBy: manual
87
+ - id: error-says-fix
88
+ level: must
89
+ statement: >-
90
+ `FieldError` text says how to fix it ("เลขประจำตัวผู้เสียภาษีต้องมี 9 หลัก",
91
+ the TFN must have 9 digits), not just "ไม่ถูกต้อง" (invalid).
92
+ evidence:
93
+ - href: https://www.w3.org/WAI/WCAG22/Understanding/error-suggestion.html
94
+ role: WCAG 2.2 SC 3.3.3 (AA)
95
+ checkedBy: manual
96
+ - id: orientation-by-control
97
+ level: must
98
+ statement: >-
99
+ `vertical` (label on top) for Input, Textarea, Select. `horizontal` (control before
100
+ the label) for Checkbox, Switch, RadioGroupItem. `responsive` for settings forms
101
+ with the label left and control right once the `FieldGroup` is 448px or wider.
102
+ example:
103
+ ref:
104
+ href: ./Field.stories.tsx#Horizontal
105
+ rel: demo
106
+ checkedBy: manual
107
+ - id: error-always-mounted
108
+ level: should
109
+ statement: >-
110
+ Keep `FieldError` mounted. It renders nothing without a message and announces
111
+ (`role="alert"`) as soon as one appears, so don't write `{error && …}` yourself.
112
+ checkedBy: manual
113
+ - id: errors-prop
114
+ level: should
115
+ statement: >-
116
+ Pass form-library errors as `errors={[{ message }]}`. Duplicate messages show once;
117
+ several show as a list.
118
+ checks:
119
+ - href: ./Field.stories.tsx#ErrorList
120
+ role: test
121
+ checkedBy: automated
122
+ - id: field-group-spacing
123
+ level: should
124
+ statement: >-
125
+ Stack fields with `FieldGroup` (28px apart), not your own `gap`.
126
+ example:
127
+ ref:
128
+ href: ./Field.stories.tsx#Form
129
+ rel: demo
130
+ checkedBy: manual
131
+ - id: description-before-typing
132
+ level: should
133
+ statement: >-
134
+ Anything the user must know before typing (format, limits) goes in
135
+ `FieldDescription`, not the placeholder, which disappears once they start typing.
136
+ checkedBy: manual
137
+
138
+ - kind: guidelines
139
+ for: all
140
+ title: Accessibility
141
+ tags: [accessibility]
142
+ items:
143
+ - id: fieldset-legend
144
+ level: must
145
+ statement: >-
146
+ A radio or checkbox group needs a `FieldLegend` inside a `FieldSet` as its name
147
+ (use `variant="label"` to make it look like a field label).
148
+ evidence:
149
+ - href: https://www.w3.org/WAI/WCAG22/Understanding/info-and-relationships.html
150
+ role: WCAG 2.2 SC 1.3.1 (A)
151
+ checks:
152
+ - href: ./Field.stories.tsx#RadioSet
153
+ role: test
154
+ checkedBy: automated
155
+ - id: error-announced
156
+ level: must
157
+ statement: >-
158
+ `FieldError` has `role="alert"`, so a new error message is read out immediately.
159
+ checks:
160
+ - href: ./Field.stories.tsx#Invalid
161
+ role: test
162
+ note: play function checks role alert and the text "ต้องมี 9 หลัก"
163
+ checkedBy: automated
164
+ - refs:
165
+ - to: shared-a11y#invalid-keeps-focus
166
+ rel: same-as
167
+
168
+ - kind: definitions
169
+ for: all
170
+ context: anatomy
171
+ items:
172
+ - term: FieldGroup
173
+ definition: >-
174
+ Stacks several fields 28px apart.
175
+ - term: Field
176
+ definition: >-
177
+ One field. Takes `orientation`, `data-invalid`, `data-disabled`.
178
+ - term: FieldLabel / FieldTitle
179
+ definition: >-
180
+ The label (`required` shows an asterisk) / the title of a choice card.
181
+ - term: FieldContent
182
+ definition: >-
183
+ Wraps the label and description when they sit beside a Checkbox or Switch.
184
+ - term: FieldDescription
185
+ definition: >-
186
+ Help text.
187
+ - term: FieldError
188
+ definition: >-
189
+ Error message, `role="alert"`. Takes `errors`.
190
+ - term: FieldSeparator
191
+ definition: >-
192
+ A divider, optionally with centred text such as "หรือ" (or).
193
+ - term: FieldSet + FieldLegend
194
+ definition: >-
195
+ A group of related fields with a group name.
196
+
197
+ - kind: section
198
+ for: all
199
+ title: Open decisions
200
+ freeform:
201
+ - title: TODO
202
+ body: >-
203
+ Not yet decided whether to switch to Base UI's Field, which wires
204
+ `aria-describedby` automatically, or whether `data-invalid` should turn the whole
205
+ field red (label, help text) as shadcn does, or only the error message.
206
+
207
+ sourceFiles:
208
+ - platform: react
209
+ file: ./Field.tsx
210
+
211
+ imports:
212
+ - platform: react
213
+ code: >-
214
+ import { Field, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSet } from "@designil/labdsnov"
215
+ package: "@designil/labdsnov"
216
+
217
+ traits:
218
+ - traitType: variant
219
+ kind: enum
220
+ id: orientation
221
+ description: >-
222
+ Where the label sits relative to the control.
223
+ values:
224
+ - id: vertical
225
+ description: >-
226
+ Label on top, control full width (default).
227
+ - id: horizontal
228
+ description: >-
229
+ Control beside the label, for Checkbox, Switch, RadioGroupItem.
230
+ - id: responsive
231
+ description: >-
232
+ Vertical on narrow screens, horizontal once the FieldGroup is 448px or wider.
233
+ - traitType: variant
234
+ kind: enum
235
+ id: legendVariant
236
+ name: FieldLegend variant
237
+ description: >-
238
+ The `variant` prop of `FieldLegend`.
239
+ values:
240
+ - id: legend
241
+ description: >-
242
+ 16px group heading (default).
243
+ - id: label
244
+ description: >-
245
+ 14px, looks like a field label.
246
+ - traitType: state
247
+ kind: boolean
248
+ id: data-invalid
249
+ name: Invalid
250
+ description: >-
251
+ Label, help text and error message turn red.
252
+ - traitType: state
253
+ kind: boolean
254
+ id: data-disabled
255
+ name: Disabled
256
+ description: >-
257
+ The label dims to 50%.
258
+
259
+ uses:
260
+ - to: label
261
+ alternatives:
262
+ - to: label
263
+ - to: alert
264
+
265
+ refs:
266
+ - href: ./Field.md
267
+ rel: relates-to
268
+ role: Thai usage doc
269
+ - href: ./Field.stories.tsx
270
+ rel: demo
271
+ role: CSF stories
272
+ - href: https://www.figma.com/design/QsKWb3A53lIh4QBDnAkGHh/labdsnov?node-id=12-109
273
+ rel: design
274
+ role: Field in Figma
275
+ - href: https://www.figma.com/design/QsKWb3A53lIh4QBDnAkGHh/labdsnov?node-id=12-120
276
+ rel: design
277
+ role: Choice Field in Figma
278
+ - href: ../../../figma/Field.figma.ts
279
+ rel: source
280
+ role: Code Connect template
281
+
282
+ $extensions:
283
+ com.figma:
284
+ nodeId: "12:109"
285
+ choiceFieldNodeId: "12:120"
@@ -0,0 +1,195 @@
1
+ kind: component
2
+ id: fund-card
3
+ name: FundCard
4
+ description: >-
5
+ A card showing one investment option with its fund manager, unit price (AUD, 4 decimal
6
+ places) and price date. The labdsnovweek1 app's own component, not from shadcn.
7
+ metadata:
8
+ status: {status: stable}
9
+ since: 1.0.0
10
+ tags: [data-display, finance]
11
+
12
+ sections:
13
+ - kind: guidelines
14
+ for: all
15
+ framing: when-to-use
16
+ items:
17
+ - level: should
18
+ statement: >-
19
+ Use on the investment options page, in a grid of 2 columns on mobile and 4 columns
20
+ from 640px screens (`grid-cols-2 sm:grid-cols-4`).
21
+ example:
22
+ ref:
23
+ href: ./FundCard.stories.tsx#FundOptions
24
+ rel: demo
25
+ - level: may
26
+ statement: >-
27
+ Show a single investment option, e.g. the member's current plan (no example in the
28
+ app yet).
29
+ - level: must-not
30
+ statement: >-
31
+ Don't use it to compare figures across funds (past returns, fees): the card has no
32
+ slots for them. Use <dsds:table>.
33
+ alternatives:
34
+ - to: table
35
+ checkedBy: manual
36
+ - level: must-not
37
+ statement: >-
38
+ Don't wrap FundCard in a button or link to make it selectable: it has no hover or
39
+ selected state. To choose a plan, use <dsds:field>'s choice cards (see Open
40
+ decisions).
41
+ alternatives:
42
+ - to: field
43
+ checkedBy: manual
44
+ - level: must-not
45
+ statement: >-
46
+ Don't use it for assets that aren't traded in units or aren't priced in AUD: the
47
+ price always reads "AU$… ต่อหน่วย" (per unit).
48
+ checkedBy: manual
49
+ - level: should-not
50
+ statement: >-
51
+ Don't show investment options with a generic <dsds:card>. Use FundCard so prices
52
+ and dates are formatted the same everywhere.
53
+ alternatives:
54
+ - to: card
55
+
56
+ - kind: guidelines
57
+ for: all
58
+ items:
59
+ - id: price-is-number
60
+ level: must
61
+ statement: >-
62
+ `unitPrice` is a raw number (`1.8342`), not a formatted string. The card formats it
63
+ as "AU$1.8342" with `Intl` `th-TH`, currency AUD, 4 decimal places.
64
+ checks:
65
+ - href: ./FundCard.stories.tsx#Playground
66
+ role: test
67
+ note: play function checks the price 1.8342 and <time dateTime>
68
+ checkedBy: automated
69
+ - id: price-date-is-date
70
+ level: must
71
+ statement: >-
72
+ `priceDate` is a `Date`, not a string. The card shows
73
+ "ต่อหน่วย · ณ วันที่ 13 พ.ย. 2569" (per unit · as at 13 Nov, Buddhist year) and
74
+ adds `<time dateTime>`. If there's no date, omit it and only "ต่อหน่วย" remains.
75
+ refines:
76
+ - to: shared-content#buddhist-year
77
+ checks:
78
+ - href: ./FundCard.stories.tsx#WithoutPriceDate
79
+ role: test
80
+ checkedBy: automated
81
+ - id: name-thai-english
82
+ level: should
83
+ statement: >-
84
+ Write `name` in Thai followed by the English name in brackets, e.g.
85
+ "สมดุล (Balanced)". Long names wrap. A `manager` longer than one line is truncated
86
+ with "…".
87
+ example:
88
+ ref:
89
+ href: ./FundCard.stories.tsx#LongName
90
+ rel: demo
91
+ checkedBy: manual
92
+ - id: image-plain-img
93
+ level: should
94
+ statement: >-
95
+ `image.src` is a URL the browser can load (e.g. `/funds/balanced.svg` in
96
+ `public`). It renders as a plain lazy `<img>`, not through `next/image`, so use a
97
+ correctly sized square image or an SVG. Without an image, the card shows a pie
98
+ chart icon.
99
+ refs:
100
+ - to: shared-composition#no-next-imports
101
+ rel: relates-to
102
+ checkedBy: manual
103
+ - id: same-grid-same-data
104
+ level: should
105
+ statement: >-
106
+ Cards in one grid carry the same set of data (all with images or none, all with a
107
+ `priceDate`), otherwise their heights differ.
108
+ checkedBy: manual
109
+
110
+ - kind: guidelines
111
+ for: all
112
+ title: Accessibility
113
+ tags: [accessibility]
114
+ items:
115
+ - id: article-h3
116
+ level: must
117
+ statement: >-
118
+ The card is an `<article>` and its name is always an `h3`. Place the grid under an
119
+ `h2` on the page (e.g. "ตัวเลือกการลงทุน", investment options) so heading levels
120
+ don't skip.
121
+ evidence:
122
+ - href: https://www.w3.org/WAI/WCAG22/Understanding/info-and-relationships.html
123
+ role: WCAG 2.2 SC 1.3.1 (A)
124
+ checkedBy: manual
125
+ - id: image-alt-thai
126
+ level: must
127
+ statement: >-
128
+ `image.alt` describes the image in Thai, e.g. "ภาพประกอบแผนภูมิวงกลม" (pie chart
129
+ illustration). Whether decorative images should use `alt=""` isn't decided yet
130
+ (see Open decisions).
131
+ refs:
132
+ - to: shared-content#thai-copy
133
+ rel: relates-to
134
+ checkedBy: manual
135
+
136
+ - kind: definitions
137
+ for: all
138
+ context: anatomy
139
+ items:
140
+ - term: Media
141
+ definition: >-
142
+ A square image at the top, or a pie chart icon when there's no image.
143
+ - term: Manager
144
+ definition: >-
145
+ Fund manager, one line, truncated with "…".
146
+ - term: Name
147
+ definition: >-
148
+ `h3` with the investment option's name.
149
+ - term: Price
150
+ definition: >-
151
+ "AU$1.8342" followed by "ต่อหน่วย · ณ วันที่ …" (per unit · as at …).
152
+
153
+ - kind: section
154
+ for: all
155
+ title: Open decisions
156
+ freeform:
157
+ - title: TODO
158
+ body: >-
159
+ Not yet decided whether the card becomes selectable or whether illustrations use an
160
+ empty `alt`. The `h3` level can't be changed yet, and the app has no single-card
161
+ example.
162
+
163
+ sourceFiles:
164
+ - platform: react
165
+ file: ./FundCard.tsx
166
+
167
+ imports:
168
+ - platform: react
169
+ code: >-
170
+ import { FundCard } from "@designil/labdsnov"
171
+ package: "@designil/labdsnov"
172
+
173
+ traits:
174
+ - traitType: variant
175
+ kind: boolean
176
+ id: image
177
+ description: >-
178
+ Has an image at the top. Without one, a pie chart icon shows.
179
+ - traitType: variant
180
+ kind: boolean
181
+ id: priceDate
182
+ description: >-
183
+ Has a price date, shown as "· ณ วันที่ …" (as at …) after "ต่อหน่วย" (per unit).
184
+
185
+ alternatives:
186
+ - to: table
187
+ - to: card
188
+
189
+ refs:
190
+ - href: ./FundCard.md
191
+ rel: relates-to
192
+ role: Thai usage doc
193
+ - href: ./FundCard.stories.tsx
194
+ rel: demo
195
+ role: CSF stories
@@ -24,7 +24,7 @@ import { FundCard } from "@designil/labdsnov"
24
24
  />
25
25
  ```
26
26
 
27
- `priceDate` ต้องเป็น `Date` (ไม่ใช่ข้อความ) และ `image.src` ต้องเป็นภาพที่ Next.js โหลดได้ เช่น ไฟล์ในโฟลเดอร์ `public` ของแอป
27
+ `priceDate` ต้องเป็น `Date` (ไม่ใช่ข้อความ) และ `image.src` เป็น URL ของภาพที่เบราว์เซอร์โหลดได้ เช่น ไฟล์ในโฟลเดอร์ `public` ของแอป (แสดงด้วย `<img>` ธรรมดาแบบ lazy load ไม่ผ่าน `next/image`)
28
28
 
29
29
  ## When to use
30
30
 
@@ -52,7 +52,7 @@ import { FundCard } from "@designil/labdsnov"
52
52
 
53
53
  - `alt` ของภาพเป็นภาษาไทยและบรรยายภาพ เช่น "ภาพประกอบแผนภูมิวงกลม" TODO: ภาพเป็นภาพประกอบเฉย ๆ ควรใช้ `alt` ว่างหรือไม่ ยังไม่ได้ตัดสินใจ
54
54
  - ชื่อตัวเลือกเป็นหัวข้อระดับ 3 เสมอ TODO: ถ้าโครงสร้างหัวข้อของหน้าไม่ตรง ยังเปลี่ยนระดับไม่ได้
55
- - ใช้ได้เฉพาะในแอป Next.js เพราะภาพแสดงผ่าน Next.js
55
+ - ใช้ได้ทุกแอป React ภาพเป็น `<img>` ธรรมดา จึงไม่ได้ปรับขนาดหรือแปลงไฟล์ให้ ใช้ภาพขนาดพอดีการ์ด (เช่น SVG)
56
56
 
57
57
  ## Tokens used
58
58
 
@@ -0,0 +1,157 @@
1
+ kind: component
2
+ id: hover-card
3
+ name: HoverCard
4
+ description: >-
5
+ A floating card that previews information when a link is hovered or focused, e.g. a
6
+ fund summary on a fund name. 288px wide, 22px corner radius. Wraps Base UI's
7
+ `PreviewCard`.
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 a short preview of what a link leads to, such as a fund's risk and return.
21
+ - level: must-not
22
+ statement: >-
23
+ Don't put buttons or inputs in the card. Use <dsds:popover>, which opens on click.
24
+ alternatives:
25
+ - to: popover
26
+ checkedBy: manual
27
+ - level: must-not
28
+ statement: >-
29
+ Don't put information the user needs to finish a task in the card. Show it on the
30
+ page: mobile has no hover.
31
+ checkedBy: manual
32
+ - level: should-not
33
+ statement: >-
34
+ Don't use it for a one-line explanation of a button or icon. Use <dsds:tooltip>.
35
+ alternatives:
36
+ - to: tooltip
37
+
38
+ - kind: guidelines
39
+ for: all
40
+ items:
41
+ - id: trigger-has-href
42
+ level: must
43
+ statement: >-
44
+ `HoverCardTrigger` is an `<a>` and must have an `href` to a page with the full
45
+ information. On mobile there's no hover, so tapping goes to that page.
46
+ checkedBy: manual
47
+ - id: content-duplicated
48
+ level: must
49
+ statement: >-
50
+ Everything in the card must also be available on the linked page. The card is
51
+ supplementary only.
52
+ checkedBy: manual
53
+ - id: trigger-looks-like-link
54
+ level: should
55
+ statement: >-
56
+ The link that opens the card looks like a link
57
+ (`font-medium text-primary underline underline-offset-4`), not plain text, so users
58
+ know there's something to hover.
59
+ example:
60
+ ref:
61
+ href: ./HoverCard.stories.tsx#Playground
62
+ rel: demo
63
+ checkedBy: manual
64
+ - id: short-preview
65
+ level: should
66
+ statement: >-
67
+ Keep content to 2–4 lines: the name (and a risk <dsds:badge>), a muted description,
68
+ and one key figure.
69
+ uses:
70
+ - to: badge
71
+ checkedBy: manual
72
+ - id: default-delays
73
+ level: may
74
+ statement: >-
75
+ You can tune `delay` / `closeDelay` on `HoverCardTrigger`, but the defaults stop
76
+ the card popping up when the pointer merely passes over.
77
+
78
+ - kind: guidelines
79
+ for: all
80
+ title: Accessibility
81
+ tags: [accessibility]
82
+ items:
83
+ - id: focus-opens
84
+ level: must
85
+ statement: >-
86
+ Focusing the link with the keyboard opens the card and Escape closes it, so
87
+ keyboard users get the same information as mouse users.
88
+ evidence:
89
+ - href: https://www.w3.org/WAI/WCAG22/Understanding/content-on-hover-or-focus.html
90
+ role: WCAG 2.2 SC 1.4.13 (AA)
91
+ checks:
92
+ - href: ./HoverCard.stories.tsx#FocusToOpen
93
+ role: test
94
+ - href: ./HoverCard.stories.tsx#HoverToOpen
95
+ role: test
96
+ note: play function checks data-open / data-closed on hover and unhover
97
+ checkedBy: automated
98
+ - id: hoverable
99
+ level: must
100
+ statement: >-
101
+ The pointer can move from the link into the card without it closing. Don't set
102
+ `closeDelay={0}`.
103
+ evidence:
104
+ - href: https://www.w3.org/WAI/WCAG22/Understanding/content-on-hover-or-focus.html
105
+ role: WCAG 2.2 SC 1.4.13 (AA)
106
+ checkedBy: manual
107
+
108
+ - kind: guidelines
109
+ for: agent
110
+ items:
111
+ - refs:
112
+ - to: shared-testing#assert-by-state
113
+ rel: same-as
114
+
115
+ - kind: definitions
116
+ for: all
117
+ context: anatomy
118
+ items:
119
+ - term: HoverCard
120
+ definition: >-
121
+ Root. Takes `open` / `onOpenChange`, `defaultOpen`.
122
+ - term: HoverCardTrigger
123
+ definition: >-
124
+ The `<a href>` link. Takes `delay`, `closeDelay`.
125
+ - term: HoverCardContent
126
+ definition: >-
127
+ The floating card. Takes `side` (default `bottom`, flips when there's no room),
128
+ `align` (`center`), `sideOffset` (4).
129
+
130
+ sourceFiles:
131
+ - platform: react
132
+ file: ./HoverCard.tsx
133
+
134
+ imports:
135
+ - platform: react
136
+ code: >-
137
+ import { HoverCard, HoverCardContent, HoverCardTrigger } from "@designil/labdsnov"
138
+ package: "@designil/labdsnov"
139
+
140
+ traits:
141
+ - traitType: state
142
+ kind: boolean
143
+ id: open
144
+ description: >-
145
+ The card is open (`data-open`).
146
+
147
+ alternatives:
148
+ - to: tooltip
149
+ - to: popover
150
+
151
+ refs:
152
+ - href: ./HoverCard.md
153
+ rel: relates-to
154
+ role: Thai usage doc
155
+ - href: ./HoverCard.stories.tsx
156
+ rel: demo
157
+ role: CSF stories