@designil/labdsnov 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +150 -2
- package/dist/components/Accordion/Accordion.d.ts +8 -0
- package/dist/components/Accordion/Accordion.js +82 -0
- package/dist/components/Accordion/Accordion.module.css.js +23 -0
- package/dist/components/Accordion/index.d.ts +1 -0
- package/dist/components/Alert/Alert.d.ts +17 -0
- package/dist/components/Alert/Alert.js +58 -0
- package/dist/components/Alert/Alert.module.css.js +17 -0
- package/dist/components/Alert/index.d.ts +1 -0
- package/dist/components/AlertDialog/AlertDialog.d.ts +29 -0
- package/dist/components/AlertDialog/AlertDialog.js +150 -0
- package/dist/components/AlertDialog/AlertDialog.module.css.js +23 -0
- package/dist/components/AlertDialog/index.d.ts +1 -0
- package/dist/components/Avatar/Avatar.d.ts +23 -0
- package/dist/components/Avatar/Avatar.js +84 -0
- package/dist/components/Avatar/Avatar.module.css.js +23 -0
- package/dist/components/Avatar/index.d.ts +1 -0
- package/dist/components/Badge/Badge.d.ts +17 -0
- package/dist/components/Badge/Badge.js +37 -0
- package/dist/components/Badge/Badge.module.css.js +19 -0
- package/dist/components/Badge/index.d.ts +1 -0
- package/dist/components/Breadcrumb/Breadcrumb.d.ts +15 -0
- package/dist/components/Breadcrumb/Breadcrumb.js +111 -0
- package/dist/components/Breadcrumb/Breadcrumb.module.css.js +19 -0
- package/dist/components/Breadcrumb/index.d.ts +1 -0
- package/dist/components/Button/Button.d.ts +39 -0
- package/dist/components/Button/Button.js +62 -0
- package/dist/components/Button/Button.module.css.js +37 -0
- package/dist/components/Button/index.d.ts +1 -0
- package/dist/components/ButtonGroup/ButtonGroup.d.ts +21 -0
- package/dist/components/ButtonGroup/ButtonGroup.js +59 -0
- package/dist/components/ButtonGroup/ButtonGroup.module.css.js +15 -0
- package/dist/components/ButtonGroup/index.d.ts +1 -0
- package/dist/components/Calendar/Calendar.d.ts +17 -0
- package/dist/components/Calendar/Calendar.js +154 -0
- package/dist/components/Calendar/Calendar.module.css.js +67 -0
- package/dist/components/Calendar/index.d.ts +1 -0
- package/dist/components/Card/Card.d.ts +20 -0
- package/dist/components/Card/Card.js +87 -0
- package/dist/components/Card/Card.module.css.js +23 -0
- package/dist/components/Card/index.d.ts +1 -0
- package/dist/components/Chart/Chart.d.ts +59 -0
- package/dist/components/Chart/Chart.js +199 -0
- package/dist/components/Chart/Chart.module.css.js +47 -0
- package/dist/components/Chart/index.d.ts +1 -0
- package/dist/components/Checkbox/Checkbox.d.ts +4 -0
- package/dist/components/Checkbox/Checkbox.js +44 -0
- package/dist/components/Checkbox/Checkbox.module.css.js +13 -0
- package/dist/components/Checkbox/index.d.ts +1 -0
- package/dist/components/Collapsible/Collapsible.d.ts +8 -0
- package/dist/components/Collapsible/Collapsible.js +28 -0
- package/dist/components/Collapsible/Collapsible.module.css.js +7 -0
- package/dist/components/Collapsible/index.d.ts +1 -0
- package/dist/components/Combobox/Combobox.d.ts +36 -0
- package/dist/components/Combobox/Combobox.js +296 -0
- package/dist/components/Combobox/Combobox.module.css.js +39 -0
- package/dist/components/Combobox/index.d.ts +1 -0
- package/dist/components/DatePicker/DatePicker.d.ts +28 -0
- package/dist/components/DatePicker/DatePicker.js +73 -0
- package/dist/components/DatePicker/DatePicker.module.css.js +9 -0
- package/dist/components/DatePicker/index.d.ts +1 -0
- package/dist/components/Dialog/Dialog.d.ts +27 -0
- package/dist/components/Dialog/Dialog.js +144 -0
- package/dist/components/Dialog/Dialog.module.css.js +29 -0
- package/dist/components/Dialog/index.d.ts +1 -0
- package/dist/components/Drawer/Drawer.d.ts +22 -0
- package/dist/components/Drawer/Drawer.js +166 -0
- package/dist/components/Drawer/Drawer.module.css.js +23 -0
- package/dist/components/Drawer/index.d.ts +1 -0
- package/dist/components/DropdownMenu/DropdownMenu.d.ts +32 -0
- package/dist/components/DropdownMenu/DropdownMenu.js +245 -0
- package/dist/components/DropdownMenu/DropdownMenu.module.css.js +33 -0
- package/dist/components/DropdownMenu/index.d.ts +1 -0
- package/dist/components/Empty/Empty.d.ts +18 -0
- package/dist/components/Empty/Empty.js +76 -0
- package/dist/components/Empty/Empty.module.css.js +21 -0
- package/dist/components/Empty/index.d.ts +1 -0
- package/dist/components/Field/Field.d.ts +53 -0
- package/dist/components/Field/Field.js +172 -0
- package/dist/components/Field/Field.module.css.js +41 -0
- package/dist/components/Field/index.d.ts +1 -0
- package/dist/components/FundCard/FundCard.d.ts +18 -0
- package/dist/components/FundCard/FundCard.js +66 -0
- package/dist/components/FundCard/FundCard.module.css.js +25 -0
- package/dist/components/FundCard/index.d.ts +1 -0
- package/dist/components/HoverCard/HoverCard.d.ts +8 -0
- package/dist/components/HoverCard/HoverCard.js +42 -0
- package/dist/components/HoverCard/HoverCard.module.css.js +9 -0
- package/dist/components/HoverCard/index.d.ts +1 -0
- package/dist/components/Input/Input.d.ts +12 -0
- package/dist/components/Input/Input.js +23 -0
- package/dist/components/Input/Input.module.css.js +11 -0
- package/dist/components/Input/index.d.ts +1 -0
- package/dist/components/InputGroup/InputGroup.d.ts +39 -0
- package/dist/components/InputGroup/InputGroup.js +103 -0
- package/dist/components/InputGroup/InputGroup.module.css.js +31 -0
- package/dist/components/InputGroup/index.d.ts +1 -0
- package/dist/components/InputOTP/InputOTP.d.ts +18 -0
- package/dist/components/InputOTP/InputOTP.js +72 -0
- package/dist/components/InputOTP/InputOTP.module.css.js +19 -0
- package/dist/components/InputOTP/index.d.ts +1 -0
- package/dist/components/Kbd/Kbd.d.ts +5 -0
- package/dist/components/Kbd/Kbd.js +20 -0
- package/dist/components/Kbd/Kbd.module.css.js +9 -0
- package/dist/components/Kbd/index.d.ts +1 -0
- package/dist/components/Label/Label.d.ts +7 -0
- package/dist/components/Label/Label.js +17 -0
- package/dist/components/Label/Label.module.css.js +9 -0
- package/dist/components/Label/index.d.ts +1 -0
- package/dist/components/NavigationMenu/NavigationMenu.d.ts +20 -0
- package/dist/components/NavigationMenu/NavigationMenu.js +153 -0
- package/dist/components/NavigationMenu/NavigationMenu.module.css.js +29 -0
- package/dist/components/NavigationMenu/index.d.ts +1 -0
- package/dist/components/Pagination/Pagination.d.ts +29 -0
- package/dist/components/Pagination/Pagination.js +133 -0
- package/dist/components/Pagination/Pagination.module.css.js +19 -0
- package/dist/components/Pagination/index.d.ts +1 -0
- package/dist/components/Popover/Popover.d.ts +10 -0
- package/dist/components/Popover/Popover.js +78 -0
- package/dist/components/Popover/Popover.module.css.js +15 -0
- package/dist/components/Popover/index.d.ts +1 -0
- package/dist/components/Progress/Progress.d.ts +12 -0
- package/dist/components/Progress/Progress.js +74 -0
- package/dist/components/Progress/Progress.module.css.js +15 -0
- package/dist/components/Progress/index.d.ts +1 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +6 -0
- package/dist/components/RadioGroup/RadioGroup.js +37 -0
- package/dist/components/RadioGroup/RadioGroup.module.css.js +13 -0
- package/dist/components/RadioGroup/index.d.ts +1 -0
- package/dist/components/ScrollArea/ScrollArea.d.ts +9 -0
- package/dist/components/ScrollArea/ScrollArea.js +60 -0
- package/dist/components/ScrollArea/ScrollArea.module.css.js +17 -0
- package/dist/components/ScrollArea/index.d.ts +1 -0
- package/dist/components/Select/Select.d.ts +23 -0
- package/dist/components/Select/Select.js +188 -0
- package/dist/components/Select/Select.module.css.js +37 -0
- package/dist/components/Select/index.d.ts +1 -0
- package/dist/components/Separator/Separator.d.ts +4 -0
- package/dist/components/Separator/Separator.js +22 -0
- package/dist/components/Separator/Separator.module.css.js +7 -0
- package/dist/components/Separator/index.d.ts +1 -0
- package/dist/components/Skeleton/Skeleton.d.ts +4 -0
- package/dist/components/Skeleton/Skeleton.js +16 -0
- package/dist/components/Skeleton/Skeleton.module.css.js +7 -0
- package/dist/components/Skeleton/index.d.ts +1 -0
- package/dist/components/Slider/Slider.d.ts +13 -0
- package/dist/components/Slider/Slider.js +61 -0
- package/dist/components/Slider/Slider.module.css.js +15 -0
- package/dist/components/Slider/index.d.ts +1 -0
- package/dist/components/Spinner/Spinner.d.ts +6 -0
- package/dist/components/Spinner/Spinner.js +22 -0
- package/dist/components/Spinner/Spinner.module.css.js +7 -0
- package/dist/components/Spinner/index.d.ts +1 -0
- package/dist/components/Switch/Switch.d.ts +13 -0
- package/dist/components/Switch/Switch.js +29 -0
- package/dist/components/Switch/Switch.module.css.js +13 -0
- package/dist/components/Switch/index.d.ts +1 -0
- package/dist/components/Table/Table.d.ts +12 -0
- package/dist/components/Table/Table.js +96 -0
- package/dist/components/Table/Table.module.css.js +23 -0
- package/dist/components/Table/index.d.ts +1 -0
- package/dist/components/Tabs/Tabs.d.ts +16 -0
- package/dist/components/Tabs/Tabs.js +55 -0
- package/dist/components/Tabs/Tabs.module.css.js +17 -0
- package/dist/components/Tabs/index.d.ts +1 -0
- package/dist/components/Textarea/Textarea.d.ts +4 -0
- package/dist/components/Textarea/Textarea.js +16 -0
- package/dist/components/Textarea/Textarea.module.css.js +7 -0
- package/dist/components/Textarea/index.d.ts +1 -0
- package/dist/components/Toaster/Toaster.d.ts +8 -0
- package/dist/components/Toaster/Toaster.js +85 -0
- package/dist/components/Toaster/Toaster.module.css.js +11 -0
- package/dist/components/Toaster/index.d.ts +1 -0
- package/dist/components/Toggle/Toggle.d.ts +26 -0
- package/dist/components/Toggle/Toggle.js +35 -0
- package/dist/components/Toggle/Toggle.module.css.js +17 -0
- package/dist/components/Toggle/index.d.ts +1 -0
- package/dist/components/ToggleGroup/ToggleGroup.d.ts +20 -0
- package/dist/components/ToggleGroup/ToggleGroup.js +64 -0
- package/dist/components/ToggleGroup/ToggleGroup.module.css.js +11 -0
- package/dist/components/ToggleGroup/index.d.ts +1 -0
- package/dist/components/Tooltip/Tooltip.d.ts +8 -0
- package/dist/components/Tooltip/Tooltip.js +61 -0
- package/dist/components/Tooltip/Tooltip.module.css.js +11 -0
- package/dist/components/Tooltip/index.d.ts +1 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +265 -0
- package/dist/styles.css +1 -0
- package/docs/Accessibility.md +129 -0
- package/docs/Colors.md +149 -0
- package/docs/ComponentTokens.md +191 -0
- package/docs/Contributing.md +104 -0
- package/docs/GettingStarted.md +106 -0
- package/docs/Radius.md +25 -0
- package/docs/Typography.md +38 -0
- package/package.json +88 -4
- package/src/components/Accordion/Accordion.dsds.yaml +195 -0
- package/src/components/Accordion/Accordion.md +102 -0
- package/src/components/Alert/Alert.dsds.yaml +206 -0
- package/src/components/Alert/Alert.md +90 -0
- package/src/components/AlertDialog/AlertDialog.dsds.yaml +243 -0
- package/src/components/AlertDialog/AlertDialog.md +131 -0
- package/src/components/Avatar/Avatar.dsds.yaml +172 -0
- package/src/components/Avatar/Avatar.md +77 -0
- package/src/components/Badge/Badge.dsds.yaml +191 -0
- package/src/components/Badge/Badge.md +124 -0
- package/src/components/Breadcrumb/Breadcrumb.dsds.yaml +162 -0
- package/src/components/Breadcrumb/Breadcrumb.md +110 -0
- package/src/components/Button/Button.dsds.yaml +350 -0
- package/src/components/Button/Button.md +165 -0
- package/src/components/ButtonGroup/ButtonGroup.dsds.yaml +193 -0
- package/src/components/ButtonGroup/ButtonGroup.md +96 -0
- package/src/components/Calendar/Calendar.dsds.yaml +236 -0
- package/src/components/Calendar/Calendar.md +111 -0
- package/src/components/Card/Card.dsds.yaml +199 -0
- package/src/components/Card/Card.md +99 -0
- package/src/components/Chart/Chart.dsds.yaml +216 -0
- package/src/components/Chart/Chart.md +112 -0
- package/src/components/Checkbox/Checkbox.dsds.yaml +215 -0
- package/src/components/Checkbox/Checkbox.md +105 -0
- package/src/components/Collapsible/Collapsible.dsds.yaml +146 -0
- package/src/components/Collapsible/Collapsible.md +86 -0
- package/src/components/Combobox/Combobox.dsds.yaml +241 -0
- package/src/components/Combobox/Combobox.md +143 -0
- package/src/components/DatePicker/DatePicker.dsds.yaml +179 -0
- package/src/components/DatePicker/DatePicker.md +82 -0
- package/src/components/Dialog/Dialog.dsds.yaml +300 -0
- package/src/components/Dialog/Dialog.md +193 -0
- package/src/components/Drawer/Drawer.dsds.yaml +207 -0
- package/src/components/Drawer/Drawer.md +125 -0
- package/src/components/DropdownMenu/DropdownMenu.dsds.yaml +265 -0
- package/src/components/DropdownMenu/DropdownMenu.md +151 -0
- package/src/components/Empty/Empty.dsds.yaml +171 -0
- package/src/components/Empty/Empty.md +90 -0
- package/src/components/Field/Field.dsds.yaml +285 -0
- package/src/components/Field/Field.md +139 -0
- package/src/components/FundCard/FundCard.dsds.yaml +195 -0
- package/src/components/FundCard/FundCard.md +93 -0
- package/src/components/HoverCard/HoverCard.dsds.yaml +157 -0
- package/src/components/HoverCard/HoverCard.md +100 -0
- package/src/components/Input/Input.dsds.yaml +235 -0
- package/src/components/Input/Input.md +115 -0
- package/src/components/InputGroup/InputGroup.dsds.yaml +234 -0
- package/src/components/InputGroup/InputGroup.md +115 -0
- package/src/components/InputOTP/InputOTP.dsds.yaml +184 -0
- package/src/components/InputOTP/InputOTP.md +105 -0
- package/src/components/Kbd/Kbd.dsds.yaml +119 -0
- package/src/components/Kbd/Kbd.md +85 -0
- package/src/components/Label/Label.dsds.yaml +141 -0
- package/src/components/Label/Label.md +75 -0
- package/src/components/NavigationMenu/NavigationMenu.dsds.yaml +196 -0
- package/src/components/NavigationMenu/NavigationMenu.md +128 -0
- package/src/components/Pagination/Pagination.dsds.yaml +172 -0
- package/src/components/Pagination/Pagination.md +115 -0
- package/src/components/Popover/Popover.dsds.yaml +168 -0
- package/src/components/Popover/Popover.md +111 -0
- package/src/components/Progress/Progress.dsds.yaml +169 -0
- package/src/components/Progress/Progress.md +83 -0
- package/src/components/RadioGroup/RadioGroup.dsds.yaml +215 -0
- package/src/components/RadioGroup/RadioGroup.md +123 -0
- package/src/components/ScrollArea/ScrollArea.dsds.yaml +153 -0
- package/src/components/ScrollArea/ScrollArea.md +88 -0
- package/src/components/Select/Select.dsds.yaml +239 -0
- package/src/components/Select/Select.md +170 -0
- package/src/components/Separator/Separator.dsds.yaml +121 -0
- package/src/components/Separator/Separator.md +68 -0
- package/src/components/Skeleton/Skeleton.dsds.yaml +124 -0
- package/src/components/Skeleton/Skeleton.md +68 -0
- package/src/components/Slider/Slider.dsds.yaml +194 -0
- package/src/components/Slider/Slider.md +107 -0
- package/src/components/Spinner/Spinner.dsds.yaml +126 -0
- package/src/components/Spinner/Spinner.md +64 -0
- package/src/components/Switch/Switch.dsds.yaml +198 -0
- package/src/components/Switch/Switch.md +101 -0
- package/src/components/Table/Table.dsds.yaml +195 -0
- package/src/components/Table/Table.md +117 -0
- package/src/components/Tabs/Tabs.dsds.yaml +239 -0
- package/src/components/Tabs/Tabs.md +173 -0
- package/src/components/Textarea/Textarea.dsds.yaml +167 -0
- package/src/components/Textarea/Textarea.md +89 -0
- package/src/components/Toaster/Toaster.dsds.yaml +226 -0
- package/src/components/Toaster/Toaster.md +107 -0
- package/src/components/Toggle/Toggle.dsds.yaml +224 -0
- package/src/components/Toggle/Toggle.md +103 -0
- package/src/components/ToggleGroup/ToggleGroup.dsds.yaml +230 -0
- package/src/components/ToggleGroup/ToggleGroup.md +95 -0
- package/src/components/Tooltip/Tooltip.dsds.yaml +202 -0
- package/src/components/Tooltip/Tooltip.md +104 -0
- package/src/index.dsds.yaml +467 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: radio-group
|
|
3
|
+
name: RadioGroup
|
|
4
|
+
description: >-
|
|
5
|
+
Pick exactly one option from a short list where every option is visible at once. 16px
|
|
6
|
+
circles, options stacked 12px apart. Wraps Base UI's `RadioGroup` and `Radio`.
|
|
7
|
+
metadata:
|
|
8
|
+
status: {status: stable}
|
|
9
|
+
since: 1.0.0
|
|
10
|
+
tags: [form, selection]
|
|
11
|
+
|
|
12
|
+
sections:
|
|
13
|
+
- kind: guidelines
|
|
14
|
+
for: all
|
|
15
|
+
framing: when-to-use
|
|
16
|
+
items:
|
|
17
|
+
- level: should
|
|
18
|
+
statement: >-
|
|
19
|
+
Use to pick one of 2–5 options the user should see before deciding, such as an
|
|
20
|
+
investment plan or statement frequency.
|
|
21
|
+
- level: should-not
|
|
22
|
+
statement: >-
|
|
23
|
+
Don't use when there are many options (more than 5–7); use <dsds:select>.
|
|
24
|
+
alternatives:
|
|
25
|
+
- to: select
|
|
26
|
+
- level: must-not
|
|
27
|
+
statement: >-
|
|
28
|
+
Don't use when several options can be chosen; use <dsds:checkbox>.
|
|
29
|
+
alternatives:
|
|
30
|
+
- to: checkbox
|
|
31
|
+
checkedBy: manual
|
|
32
|
+
- level: must-not
|
|
33
|
+
statement: >-
|
|
34
|
+
Don't use two radios for on/off; use <dsds:switch> or <dsds:checkbox>.
|
|
35
|
+
alternatives:
|
|
36
|
+
- to: switch
|
|
37
|
+
checkedBy: manual
|
|
38
|
+
- level: must-not
|
|
39
|
+
statement: >-
|
|
40
|
+
Don't use to switch views of content; use <dsds:tabs>.
|
|
41
|
+
alternatives:
|
|
42
|
+
- to: tabs
|
|
43
|
+
checkedBy: manual
|
|
44
|
+
|
|
45
|
+
- kind: guidelines
|
|
46
|
+
for: all
|
|
47
|
+
items:
|
|
48
|
+
- id: item-label
|
|
49
|
+
level: must
|
|
50
|
+
statement: >-
|
|
51
|
+
Every `RadioGroupItem` has a `value` (required) and an `id` tied to a
|
|
52
|
+
<dsds:label> `htmlFor`, so clicking the text selects it. In forms use
|
|
53
|
+
`Field orientation="horizontal"`.
|
|
54
|
+
checks:
|
|
55
|
+
- href: ./RadioGroup.stories.tsx#Choosing
|
|
56
|
+
role: test
|
|
57
|
+
note: play function clicks the "เติบโตสูง" (high growth) text, then checks it's selected and onValueChange ran
|
|
58
|
+
uses:
|
|
59
|
+
- to: label
|
|
60
|
+
- to: field
|
|
61
|
+
checkedBy: automated
|
|
62
|
+
- id: preselect-safe
|
|
63
|
+
level: should
|
|
64
|
+
statement: >-
|
|
65
|
+
Preselect the safe or current value with `defaultValue` (e.g. the member's current
|
|
66
|
+
plan). Don't preselect when the choice has financial consequences the user must
|
|
67
|
+
choose deliberately.
|
|
68
|
+
checkedBy: manual
|
|
69
|
+
- id: choice-cards
|
|
70
|
+
level: should
|
|
71
|
+
statement: >-
|
|
72
|
+
Options with long descriptions (e.g. investment plans with their risk) become cards,
|
|
73
|
+
following the `ChoiceCards` story in <dsds:field>, instead of long label text.
|
|
74
|
+
uses:
|
|
75
|
+
- to: field
|
|
76
|
+
checkedBy: manual
|
|
77
|
+
- id: order-logical
|
|
78
|
+
level: should
|
|
79
|
+
statement: >-
|
|
80
|
+
Order options in a meaningful sequence (low to high risk, least to most frequent),
|
|
81
|
+
not alphabetically.
|
|
82
|
+
checkedBy: manual
|
|
83
|
+
|
|
84
|
+
- kind: guidelines
|
|
85
|
+
for: all
|
|
86
|
+
title: Accessibility
|
|
87
|
+
tags: [accessibility]
|
|
88
|
+
items:
|
|
89
|
+
- id: group-name
|
|
90
|
+
level: must
|
|
91
|
+
statement: >-
|
|
92
|
+
The group has a name: an `aria-label` on RadioGroup, or a `FieldSet` with a
|
|
93
|
+
`FieldLegend` around it.
|
|
94
|
+
refs:
|
|
95
|
+
- to: field#fieldset-legend
|
|
96
|
+
rel: relates-to
|
|
97
|
+
checks:
|
|
98
|
+
- href: ./RadioGroup.stories.tsx#Playground
|
|
99
|
+
role: test
|
|
100
|
+
note: play function checks the radiogroup's name
|
|
101
|
+
checkedBy: automated
|
|
102
|
+
- id: arrow-keys
|
|
103
|
+
level: must
|
|
104
|
+
statement: >-
|
|
105
|
+
Tab focuses the selected option (the whole group is a single Tab stop); up/down
|
|
106
|
+
arrows move and select at once. So never give a selection side effects that can't
|
|
107
|
+
be undone (such as submitting the form).
|
|
108
|
+
evidence:
|
|
109
|
+
- href: https://www.w3.org/WAI/ARIA/apg/patterns/radio/
|
|
110
|
+
role: WAI-ARIA APG Radio Group pattern
|
|
111
|
+
checks:
|
|
112
|
+
- href: ./RadioGroup.stories.tsx#Keyboard
|
|
113
|
+
role: test
|
|
114
|
+
checkedBy: automated
|
|
115
|
+
- id: control-contrast
|
|
116
|
+
level: must
|
|
117
|
+
statement: >-
|
|
118
|
+
An unselected circle's border (`--control-border`) passes 3.93:1 / 3.44:1, a
|
|
119
|
+
selected circle 5.23:1 / 6.99:1, and its dot 4.93:1 / 6.46:1. The hit area is at
|
|
120
|
+
least 24×24px.
|
|
121
|
+
refines:
|
|
122
|
+
- to: shared-a11y#non-text-contrast
|
|
123
|
+
checks:
|
|
124
|
+
- href: ../../../scripts/tokens.mjs
|
|
125
|
+
role: test
|
|
126
|
+
note: CONTRAST_PAIRS "… Checkbox / Radio …"
|
|
127
|
+
checkedBy: automated
|
|
128
|
+
- refs:
|
|
129
|
+
- to: shared-a11y#invalid-has-message
|
|
130
|
+
rel: same-as
|
|
131
|
+
|
|
132
|
+
- kind: definitions
|
|
133
|
+
for: all
|
|
134
|
+
context: anatomy
|
|
135
|
+
items:
|
|
136
|
+
- term: RadioGroup
|
|
137
|
+
definition: >-
|
|
138
|
+
The group. Takes `defaultValue`, `value` / `onValueChange`, `name`, `disabled`,
|
|
139
|
+
`aria-label`.
|
|
140
|
+
- term: RadioGroupItem
|
|
141
|
+
definition: >-
|
|
142
|
+
A 16px circle. Takes `value` (required), `id`, `disabled`, `aria-invalid`.
|
|
143
|
+
|
|
144
|
+
- kind: definitions
|
|
145
|
+
for: all
|
|
146
|
+
context: keyboard
|
|
147
|
+
items:
|
|
148
|
+
- term: Tab
|
|
149
|
+
definition: >-
|
|
150
|
+
Enters or leaves the group, focusing the selected option.
|
|
151
|
+
- term: Up / Down (Left / Right) arrows
|
|
152
|
+
definition: >-
|
|
153
|
+
Move to and select the previous / next option.
|
|
154
|
+
|
|
155
|
+
- kind: section
|
|
156
|
+
for: all
|
|
157
|
+
title: Open decisions
|
|
158
|
+
freeform:
|
|
159
|
+
- title: TODO
|
|
160
|
+
body: >-
|
|
161
|
+
The maximum number of options before switching to Select isn't defined ("5–7" is
|
|
162
|
+
an estimate).
|
|
163
|
+
|
|
164
|
+
sourceFiles:
|
|
165
|
+
- platform: react
|
|
166
|
+
file: ./RadioGroup.tsx
|
|
167
|
+
|
|
168
|
+
imports:
|
|
169
|
+
- platform: react
|
|
170
|
+
code: >-
|
|
171
|
+
import { RadioGroup, RadioGroupItem } from "@designil/labdsnov"
|
|
172
|
+
package: "@designil/labdsnov"
|
|
173
|
+
|
|
174
|
+
traits:
|
|
175
|
+
- traitType: state
|
|
176
|
+
kind: boolean
|
|
177
|
+
id: checked
|
|
178
|
+
description: >-
|
|
179
|
+
The selected option: a primary-coloured circle with a light dot.
|
|
180
|
+
- traitType: state
|
|
181
|
+
kind: boolean
|
|
182
|
+
id: disabled
|
|
183
|
+
description: >-
|
|
184
|
+
The whole group or one option is disabled, dimmed to 50%.
|
|
185
|
+
- traitType: state
|
|
186
|
+
kind: boolean
|
|
187
|
+
id: aria-invalid
|
|
188
|
+
name: Invalid
|
|
189
|
+
description: >-
|
|
190
|
+
On `RadioGroupItem`: red border and faint red ring.
|
|
191
|
+
|
|
192
|
+
uses:
|
|
193
|
+
- to: label
|
|
194
|
+
alternatives:
|
|
195
|
+
- to: select
|
|
196
|
+
- to: checkbox
|
|
197
|
+
- to: switch
|
|
198
|
+
|
|
199
|
+
refs:
|
|
200
|
+
- href: ./RadioGroup.md
|
|
201
|
+
rel: relates-to
|
|
202
|
+
role: Thai usage doc
|
|
203
|
+
- href: ./RadioGroup.stories.tsx
|
|
204
|
+
rel: demo
|
|
205
|
+
role: CSF stories
|
|
206
|
+
- href: https://www.figma.com/design/QsKWb3A53lIh4QBDnAkGHh/labdsnov?node-id=12-64
|
|
207
|
+
rel: design
|
|
208
|
+
role: Radio in Figma
|
|
209
|
+
- href: ../../../figma/Radio.figma.ts
|
|
210
|
+
rel: source
|
|
211
|
+
role: Code Connect template
|
|
212
|
+
|
|
213
|
+
$extensions:
|
|
214
|
+
com.figma:
|
|
215
|
+
nodeId: "12:64"
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# RadioGroup (ตัวเลือกแบบเลือกได้ข้อเดียว)
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
เลือกได้หนึ่งข้อจากรายการสั้น ๆ ที่เห็นทุกตัวเลือกพร้อมกัน
|
|
6
|
+
|
|
7
|
+
## Import and usage
|
|
8
|
+
|
|
9
|
+
**ตั้งค่าครั้งเดียวในแอป** (ใช้ร่วมกันทุกคอมโพเนนต์):
|
|
10
|
+
|
|
11
|
+
1. ติดตั้ง `@designil/labdsnov` (`pnpm add @designil/labdsnov`) พร้อม `react` และ `react-dom` 19
|
|
12
|
+
2. import สไตล์ครั้งเดียวที่ root layout: `import "@designil/labdsnov/styles.css"`
|
|
13
|
+
3. กำหนดตัวแปร `--font-heading` (แอปใช้ IBM Plex Sans Thai) และใส่ class `dark` ที่ `<html>` เมื่อต้องการโหมดมืด
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { Label, RadioGroup, RadioGroupItem } from "@designil/labdsnov"
|
|
17
|
+
|
|
18
|
+
;<RadioGroup defaultValue="balanced" aria-label="แผนการลงทุน">
|
|
19
|
+
<div className="flex items-center gap-2">
|
|
20
|
+
<RadioGroupItem value="balanced" id="plan-balanced" />
|
|
21
|
+
<Label htmlFor="plan-balanced">สมดุล (Balanced)</Label>
|
|
22
|
+
</div>
|
|
23
|
+
<div className="flex items-center gap-2">
|
|
24
|
+
<RadioGroupItem value="growth" id="plan-growth" />
|
|
25
|
+
<Label htmlFor="plan-growth">เติบโตสูง (High Growth)</Label>
|
|
26
|
+
</div>
|
|
27
|
+
</RadioGroup>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
- ตั้งชื่อให้ทั้งกลุ่ม: `aria-label` หรือวางใน `FieldSet` ที่มี `FieldLegend` (ดู [Field](../Field/Field.md))
|
|
31
|
+
- ตัวเลือกที่มีคำอธิบายยาว ทำเป็นการ์ดให้เลือกได้ตาม story `ChoiceCards` ของ Field
|
|
32
|
+
|
|
33
|
+
## When to use
|
|
34
|
+
|
|
35
|
+
- เลือกหนึ่งข้อจาก 2–5 ตัวเลือก ที่ผู้ใช้ควรเห็นทุกตัวเลือกก่อนตัดสินใจ เช่น แผนการลงทุน ความถี่ของใบแจ้งยอด
|
|
36
|
+
|
|
37
|
+
## When not to use
|
|
38
|
+
|
|
39
|
+
| สถานการณ์ | ใช้แทน |
|
|
40
|
+
| ---------------------- | ----------------------- |
|
|
41
|
+
| ตัวเลือกมาก (เกิน 5–7 ข้อ) | `Select` |
|
|
42
|
+
| เลือกได้หลายข้อ | `Checkbox` |
|
|
43
|
+
| เปิด/ปิดอย่างเดียว | `Switch` หรือ `Checkbox` |
|
|
44
|
+
| สลับมุมมองของเนื้อหา | `Tabs` |
|
|
45
|
+
|
|
46
|
+
TODO: ยังไม่ได้กำหนดจำนวนตัวเลือกสูงสุดก่อนเปลี่ยนไปใช้ `Select`
|
|
47
|
+
|
|
48
|
+
## Props and variants
|
|
49
|
+
|
|
50
|
+
ไม่มี variant หรือ size วงกลมขนาด 16px ตัวเลือกเรียงลงมาห่างกัน 12px
|
|
51
|
+
|
|
52
|
+
### RadioGroup
|
|
53
|
+
|
|
54
|
+
| Prop | ค่า | ค่าเริ่มต้น | ความหมาย |
|
|
55
|
+
| ------------------------- | --------------- | ------- | ----------------------------- |
|
|
56
|
+
| `defaultValue` | value ของตัวเลือก | – | ตัวเลือกที่เลือกไว้ตอนแรก |
|
|
57
|
+
| `value` / `onValueChange` | value / ฟังก์ชัน | – | ควบคุมจากภายนอก |
|
|
58
|
+
| `name` | ข้อความ | – | ชื่อที่ส่งไปกับฟอร์ม |
|
|
59
|
+
| `disabled` | `boolean` | `false` | ปิดใช้งานทั้งกลุ่ม |
|
|
60
|
+
| `aria-label` | ข้อความ | – | ชื่อของกลุ่ม เมื่อไม่มี `FieldLegend` |
|
|
61
|
+
| `className` | class | – | ปรับหน้าตาเฉพาะจุดครั้งเดียว |
|
|
62
|
+
|
|
63
|
+
### RadioGroupItem
|
|
64
|
+
|
|
65
|
+
| Prop | ค่า | ความหมาย |
|
|
66
|
+
| -------------- | --------- | ------------------------------------- |
|
|
67
|
+
| `value` | ข้อความ | **บังคับ** ค่าของตัวเลือกนี้ |
|
|
68
|
+
| `id` | ข้อความ | ผูกกับ `Label` ผ่าน `htmlFor` |
|
|
69
|
+
| `disabled` | `boolean` | ปิดใช้งานตัวเลือกนี้ จางลง 50% |
|
|
70
|
+
| `aria-invalid` | `boolean` | ข้อมูลไม่ถูกต้อง เส้นขอบสีแดงและวงแหวนแดงจาง |
|
|
71
|
+
|
|
72
|
+
### พฤติกรรมที่มีให้แล้ว
|
|
73
|
+
|
|
74
|
+
- กด Tab แล้วโฟกัสไปที่ตัวเลือกที่เลือกอยู่ ลูกศรขึ้น/ลงเลื่อนและเลือกตัวเลือกถัดไปทันที
|
|
75
|
+
|
|
76
|
+
## Tokens used
|
|
77
|
+
|
|
78
|
+
ค่าทั้งหมดมาจาก `src/styles/theme.css`
|
|
79
|
+
|
|
80
|
+
### Component tokens
|
|
81
|
+
|
|
82
|
+
token เฉพาะของคอมโพเนนต์นี้ ชี้ไปที่ semantic token ด้านล่าง เปลี่ยนที่นี่เพื่อปรับเฉพาะคอมโพเนนต์นี้ (โหมดมืด "–" = ใช้ค่าเดียวกับโหมดสว่าง)
|
|
83
|
+
|
|
84
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
85
|
+
| ---------------------- | ---------------------- | ------------------- | ----------------------------------------------- |
|
|
86
|
+
| `--control-bg` | `--background` | `--input` 50% | พื้นตอนยังไม่เลือก |
|
|
87
|
+
| `--control-checked-bg` | `--primary` | – | พื้นและเส้นขอบตอนเลือก |
|
|
88
|
+
| `--control-checked-fg` | `--primary-foreground` | – | เครื่องหมายถูก / จุด ตอนเลือก |
|
|
89
|
+
| `--focus-ring` | `--ring` | – | วงแหวน focus จากคีย์บอร์ดของทุกคอมโพเนนต์ (ทึบ 2px) |
|
|
90
|
+
| `--invalid-border` | `--destructive` | – | เส้นขอบเมื่อข้อมูลไม่ถูกต้อง และวงแหวน focus ขณะไม่ถูกต้อง |
|
|
91
|
+
| `--invalid-ring` | `--destructive` 20% | `--destructive` 40% | วงแหวนจางรอบช่องที่ไม่ถูกต้อง (ตกแต่ง) |
|
|
92
|
+
|
|
93
|
+
### Semantic tokens
|
|
94
|
+
|
|
95
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
96
|
+
| ---------------------- | --------------------------- | --------------------------- | --------------------------- |
|
|
97
|
+
| `--input` | `oklch(0.93 0.007 106.5)` | `oklch(1 0 0 / 15%)` | พื้นวงกลมที่ไม่ได้เลือก (90%) |
|
|
98
|
+
| `--primary` | `oklch(0.553 0.195 38.402)` | `oklch(0.705 0.187 47.604)` | พื้นวงกลมที่เลือก |
|
|
99
|
+
| `--primary-foreground` | `oklch(0.98 0.016 73.684)` | `oklch(0.205 0.05 40)` | จุดตรงกลาง |
|
|
100
|
+
| `--ring` | `oklch(0.45 0.03 106.9)` | `oklch(0.8 0.02 106.9)` | วงแหวน focus |
|
|
101
|
+
| `--destructive` | `oklch(0.505 0.2 27.325)` | `oklch(0.75 0.16 22.216)` | สถานะไม่ถูกต้อง |
|
|
102
|
+
| `--background` | `oklch(1 0 0)` | `oklch(0.153 0.006 107.1)` | ผ่าน token ของคอมโพเนนต์ด้านบน |
|
|
103
|
+
|
|
104
|
+
## Example
|
|
105
|
+
|
|
106
|
+
จาก story `Playground` ใน `RadioGroup.stories.tsx`:
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
<RadioGroup defaultValue="balanced" aria-label="แผนการลงทุน" className="w-72">
|
|
110
|
+
<div className="flex items-center gap-2">
|
|
111
|
+
<RadioGroupItem value="conservative" id="plan-conservative" />
|
|
112
|
+
<Label htmlFor="plan-conservative">อนุรักษ์นิยม (Conservative)</Label>
|
|
113
|
+
</div>
|
|
114
|
+
<div className="flex items-center gap-2">
|
|
115
|
+
<RadioGroupItem value="balanced" id="plan-balanced" />
|
|
116
|
+
<Label htmlFor="plan-balanced">สมดุล (Balanced)</Label>
|
|
117
|
+
</div>
|
|
118
|
+
<div className="flex items-center gap-2">
|
|
119
|
+
<RadioGroupItem value="growth" id="plan-growth" />
|
|
120
|
+
<Label htmlFor="plan-growth">เติบโตสูง (High Growth)</Label>
|
|
121
|
+
</div>
|
|
122
|
+
</RadioGroup>
|
|
123
|
+
```
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: scroll-area
|
|
3
|
+
name: ScrollArea
|
|
4
|
+
description: >-
|
|
5
|
+
A fixed-size box whose content scrolls, with a thin 10px scrollbar that looks the same
|
|
6
|
+
on every operating system. Wraps Base UI's `ScrollArea`.
|
|
7
|
+
metadata:
|
|
8
|
+
status: {status: stable}
|
|
9
|
+
since: 1.0.0
|
|
10
|
+
tags: [layout]
|
|
11
|
+
|
|
12
|
+
sections:
|
|
13
|
+
- kind: guidelines
|
|
14
|
+
for: all
|
|
15
|
+
framing: when-to-use
|
|
16
|
+
items:
|
|
17
|
+
- level: should
|
|
18
|
+
statement: >-
|
|
19
|
+
Use for a long list in a confined space, such as recent activity in a <dsds:card>
|
|
20
|
+
or <dsds:popover>.
|
|
21
|
+
- level: may
|
|
22
|
+
statement: >-
|
|
23
|
+
Use for a row of cards that scrolls sideways (add
|
|
24
|
+
`<ScrollBar orientation="horizontal" />`).
|
|
25
|
+
example:
|
|
26
|
+
ref:
|
|
27
|
+
href: ./ScrollArea.stories.tsx#Horizontal
|
|
28
|
+
rel: demo
|
|
29
|
+
- level: must-not
|
|
30
|
+
statement: >-
|
|
31
|
+
Don't wrap the page's main content; let the page scroll normally. Nested scrolling
|
|
32
|
+
makes the mouse wheel and trackpad hard to use.
|
|
33
|
+
checkedBy: manual
|
|
34
|
+
- level: should-not
|
|
35
|
+
statement: >-
|
|
36
|
+
Don't wrap a <dsds:table> (it already scrolls sideways) or the lists of Select /
|
|
37
|
+
Combobox / DropdownMenu (they already scroll).
|
|
38
|
+
alternatives:
|
|
39
|
+
- to: table
|
|
40
|
+
|
|
41
|
+
- kind: guidelines
|
|
42
|
+
for: all
|
|
43
|
+
items:
|
|
44
|
+
- id: fixed-size
|
|
45
|
+
level: must
|
|
46
|
+
statement: >-
|
|
47
|
+
Set a size (`h-…` or `w-…`) with `className`. Otherwise the box grows with its
|
|
48
|
+
content and never scrolls.
|
|
49
|
+
checks:
|
|
50
|
+
- href: ./ScrollArea.stories.tsx#Playground
|
|
51
|
+
role: test
|
|
52
|
+
note: play function checks scrollHeight exceeds clientHeight and that it scrolls
|
|
53
|
+
checkedBy: assisted
|
|
54
|
+
- id: padding-inside
|
|
55
|
+
level: must
|
|
56
|
+
statement: >-
|
|
57
|
+
Put padding (`p-4`) on the content inside, not on `ScrollArea`, or the scrollbar is
|
|
58
|
+
pushed inwards too.
|
|
59
|
+
checkedBy: manual
|
|
60
|
+
- id: horizontal-nowrap
|
|
61
|
+
level: should
|
|
62
|
+
statement: >-
|
|
63
|
+
For a horizontal row, use `whitespace-nowrap` on the ScrollArea and `flex w-max` on
|
|
64
|
+
the content.
|
|
65
|
+
checkedBy: manual
|
|
66
|
+
- id: hint-more
|
|
67
|
+
level: should
|
|
68
|
+
statement: >-
|
|
69
|
+
Show that there's more: cut the height mid-item (not exactly at an item's edge), or
|
|
70
|
+
let the last card in a horizontal row peek out halfway.
|
|
71
|
+
checkedBy: manual
|
|
72
|
+
|
|
73
|
+
- kind: guidelines
|
|
74
|
+
for: all
|
|
75
|
+
title: Accessibility
|
|
76
|
+
tags: [accessibility]
|
|
77
|
+
items:
|
|
78
|
+
- id: keyboard-scroll
|
|
79
|
+
level: must
|
|
80
|
+
statement: >-
|
|
81
|
+
The area can be reached with Tab (with an inset focus ring) and scrolled with the
|
|
82
|
+
arrow keys. Add an `aria-label` on ScrollArea when nothing inside says what it is.
|
|
83
|
+
evidence:
|
|
84
|
+
- href: https://www.w3.org/WAI/WCAG22/Understanding/keyboard.html
|
|
85
|
+
role: WCAG 2.2 SC 2.1.1 (A)
|
|
86
|
+
checkedBy: manual
|
|
87
|
+
- id: thumb-contrast
|
|
88
|
+
level: must
|
|
89
|
+
statement: >-
|
|
90
|
+
The scrollbar thumb (`--scroll-area-thumb`) passes 3.93:1 light / 4.05:1 dark on
|
|
91
|
+
the page background.
|
|
92
|
+
checks:
|
|
93
|
+
- href: ../../../scripts/tokens.mjs
|
|
94
|
+
role: test
|
|
95
|
+
note: CONTRAST_PAIRS "แถบเลื่อนของ ScrollArea" (ScrollArea scrollbar)
|
|
96
|
+
checkedBy: automated
|
|
97
|
+
|
|
98
|
+
- kind: definitions
|
|
99
|
+
for: all
|
|
100
|
+
context: anatomy
|
|
101
|
+
items:
|
|
102
|
+
- term: ScrollArea
|
|
103
|
+
definition: >-
|
|
104
|
+
The box (viewport plus a built-in vertical scrollbar). Size, border and radius come
|
|
105
|
+
from `className`.
|
|
106
|
+
- term: ScrollBar
|
|
107
|
+
definition: >-
|
|
108
|
+
An extra scrollbar. Takes `orientation`.
|
|
109
|
+
|
|
110
|
+
- kind: section
|
|
111
|
+
for: all
|
|
112
|
+
title: Open decisions
|
|
113
|
+
freeform:
|
|
114
|
+
- title: TODO
|
|
115
|
+
body: >-
|
|
116
|
+
Not yet checked that the area takes focus in every browser when it contains no
|
|
117
|
+
button or link.
|
|
118
|
+
|
|
119
|
+
sourceFiles:
|
|
120
|
+
- platform: react
|
|
121
|
+
file: ./ScrollArea.tsx
|
|
122
|
+
|
|
123
|
+
imports:
|
|
124
|
+
- platform: react
|
|
125
|
+
code: >-
|
|
126
|
+
import { ScrollArea, ScrollBar } from "@designil/labdsnov"
|
|
127
|
+
package: "@designil/labdsnov"
|
|
128
|
+
|
|
129
|
+
traits:
|
|
130
|
+
- traitType: variant
|
|
131
|
+
kind: enum
|
|
132
|
+
id: orientation
|
|
133
|
+
name: ScrollBar orientation
|
|
134
|
+
description: >-
|
|
135
|
+
The `orientation` prop of `ScrollBar`.
|
|
136
|
+
values:
|
|
137
|
+
- id: vertical
|
|
138
|
+
description: >-
|
|
139
|
+
Vertical (already built into ScrollArea).
|
|
140
|
+
- id: horizontal
|
|
141
|
+
description: >-
|
|
142
|
+
Horizontal; add it yourself when content is too wide.
|
|
143
|
+
|
|
144
|
+
alternatives:
|
|
145
|
+
- to: table
|
|
146
|
+
|
|
147
|
+
refs:
|
|
148
|
+
- href: ./ScrollArea.md
|
|
149
|
+
rel: relates-to
|
|
150
|
+
role: Thai usage doc
|
|
151
|
+
- href: ./ScrollArea.stories.tsx
|
|
152
|
+
rel: demo
|
|
153
|
+
role: CSF stories
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# ScrollArea (พื้นที่เลื่อน)
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
กล่องขนาดคงที่ที่เนื้อหาเลื่อนได้ มีแถบเลื่อนบางที่หน้าตาเหมือนกันทุกระบบปฏิบัติการ
|
|
6
|
+
|
|
7
|
+
## Import and usage
|
|
8
|
+
|
|
9
|
+
**ตั้งค่าครั้งเดียวในแอป** (ใช้ร่วมกันทุกคอมโพเนนต์):
|
|
10
|
+
|
|
11
|
+
1. ติดตั้ง `@designil/labdsnov` (`pnpm add @designil/labdsnov`) พร้อม `react` และ `react-dom` 19
|
|
12
|
+
2. import สไตล์ครั้งเดียวที่ root layout: `import "@designil/labdsnov/styles.css"`
|
|
13
|
+
3. กำหนดตัวแปร `--font-heading` (แอปใช้ IBM Plex Sans Thai) และใส่ class `dark` ที่ `<html>` เมื่อต้องการโหมดมืด
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { ScrollArea } from "@designil/labdsnov"
|
|
17
|
+
|
|
18
|
+
;<ScrollArea className="h-72 w-80 rounded-2xl border">
|
|
19
|
+
<div className="p-4">…</div>
|
|
20
|
+
</ScrollArea>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
- **ต้องกำหนดขนาด** (`h-…` หรือ `w-…`) ด้วย `className` ไม่อย่างนั้นกล่องจะสูงตามเนื้อหาและไม่เลื่อน
|
|
24
|
+
- ใส่ระยะขอบ (`p-4`) ที่เนื้อหาข้างใน ไม่ใช่ที่ `ScrollArea`
|
|
25
|
+
- เนื้อหากว้างเกิน: เพิ่ม `<ScrollBar orientation="horizontal" />` ไว้ข้างใน
|
|
26
|
+
|
|
27
|
+
## When to use
|
|
28
|
+
|
|
29
|
+
- รายการยาวในพื้นที่จำกัด เช่น รายการเคลื่อนไหวใน `Card` หรือ `Popover`
|
|
30
|
+
- แถวของการ์ดที่เลื่อนแนวนอน
|
|
31
|
+
|
|
32
|
+
## When not to use
|
|
33
|
+
|
|
34
|
+
- **เนื้อหาหลักของหน้า**: ให้หน้าเลื่อนตามปกติ
|
|
35
|
+
- **ตารางข้อมูล**: ใช้ `Table` (เลื่อนแนวนอนเองอยู่แล้ว)
|
|
36
|
+
- **รายการตัวเลือก**: `Select` / `Combobox` / `DropdownMenu` เลื่อนเองอยู่แล้ว
|
|
37
|
+
|
|
38
|
+
## Props and variants
|
|
39
|
+
|
|
40
|
+
ไม่มี variant หรือ size
|
|
41
|
+
|
|
42
|
+
| Prop | ใช้กับ | ความหมาย |
|
|
43
|
+
| ------------- | ------------ | -------------------------------------------- |
|
|
44
|
+
| `className` | `ScrollArea` | ขนาด กรอบ มุมโค้ง |
|
|
45
|
+
| `orientation` | `ScrollBar` | `vertical` (ค่าเริ่มต้น มีให้แล้ว) หรือ `horizontal` |
|
|
46
|
+
|
|
47
|
+
- แถบเลื่อนกว้าง 10px ตัวจับสีเทาเข้ม (contrast 3:1)
|
|
48
|
+
- **คีย์บอร์ด**: Tab เข้าไปในพื้นที่ (มีวงแหวน focus ด้านใน) แล้วเลื่อนด้วยลูกศร TODO: ยังไม่ได้ตรวจว่าพื้นที่รับโฟกัสได้ในทุกเบราว์เซอร์เมื่อไม่มีปุ่มหรือลิงก์ข้างใน
|
|
49
|
+
|
|
50
|
+
## Tokens used
|
|
51
|
+
|
|
52
|
+
ค่าทั้งหมดมาจาก `src/styles/theme.css`
|
|
53
|
+
|
|
54
|
+
### Component tokens
|
|
55
|
+
|
|
56
|
+
token เฉพาะของคอมโพเนนต์นี้ ชี้ไปที่ semantic token ด้านล่าง เปลี่ยนที่นี่เพื่อปรับเฉพาะคอมโพเนนต์นี้ (โหมดมืด "–" = ใช้ค่าเดียวกับโหมดสว่าง)
|
|
57
|
+
|
|
58
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
59
|
+
| --------------------- | ------------------ | ------ | --------------------------------------------- |
|
|
60
|
+
| `--focus-ring` | `--ring` | – | วงแหวน focus จากคีย์บอร์ดของทุกคอมโพเนนต์ (ทึบ 2px) |
|
|
61
|
+
| `--scroll-area-thumb` | `--control-border` | – | แถบเลื่อน |
|
|
62
|
+
|
|
63
|
+
### Semantic tokens
|
|
64
|
+
|
|
65
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
66
|
+
| ------------------ | ------------------------ | ------------------------- | --------------------------- |
|
|
67
|
+
| `--ring` | `oklch(0.45 0.03 106.9)` | `oklch(0.8 0.02 106.9)` | วงแหวน focus |
|
|
68
|
+
| `--control-border` | `oklch(0.6 0.02 106.9)` | `oklch(0.55 0.015 106.9)` | ผ่าน token ของคอมโพเนนต์ด้านบน |
|
|
69
|
+
|
|
70
|
+
## Example
|
|
71
|
+
|
|
72
|
+
จาก story `Horizontal` ใน `ScrollArea.stories.tsx`:
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
<ScrollArea className="w-96 rounded-2xl border whitespace-nowrap">
|
|
76
|
+
<div className="flex w-max gap-3 p-4">
|
|
77
|
+
{funds.map((name) => (
|
|
78
|
+
<div
|
|
79
|
+
key={name}
|
|
80
|
+
className="flex h-24 w-40 items-end rounded-2xl bg-muted p-3 text-sm font-medium"
|
|
81
|
+
>
|
|
82
|
+
{name}
|
|
83
|
+
</div>
|
|
84
|
+
))}
|
|
85
|
+
</div>
|
|
86
|
+
<ScrollBar orientation="horizontal" />
|
|
87
|
+
</ScrollArea>
|
|
88
|
+
```
|