@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,216 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: chart
|
|
3
|
+
name: Chart
|
|
4
|
+
description: >-
|
|
5
|
+
A wrapper for Recharts charts that applies the design system's colours, labels,
|
|
6
|
+
tooltip and legend. Each series' colour comes from `config` and becomes
|
|
7
|
+
`var(--color-<key>)`.
|
|
8
|
+
metadata:
|
|
9
|
+
status: {status: stable}
|
|
10
|
+
since: 1.0.0
|
|
11
|
+
tags: [data-display]
|
|
12
|
+
|
|
13
|
+
sections:
|
|
14
|
+
- kind: guidelines
|
|
15
|
+
for: all
|
|
16
|
+
framing: when-to-use
|
|
17
|
+
items:
|
|
18
|
+
- level: should
|
|
19
|
+
statement: >-
|
|
20
|
+
Use for trends over time, e.g. monthly balance (area or line chart).
|
|
21
|
+
- level: should
|
|
22
|
+
statement: >-
|
|
23
|
+
Use to compare amounts, e.g. contributions by source (bar chart).
|
|
24
|
+
- level: must-not
|
|
25
|
+
statement: >-
|
|
26
|
+
Don't chart a single number. Show it in a <dsds:card>.
|
|
27
|
+
alternatives:
|
|
28
|
+
- to: card
|
|
29
|
+
checkedBy: manual
|
|
30
|
+
- level: must-not
|
|
31
|
+
statement: >-
|
|
32
|
+
Don't chart the share of a single goal. Use <dsds:progress>.
|
|
33
|
+
alternatives:
|
|
34
|
+
- to: progress
|
|
35
|
+
checkedBy: manual
|
|
36
|
+
- level: should-not
|
|
37
|
+
statement: >-
|
|
38
|
+
Don't chart values users must read exactly (per-transaction amounts, transaction
|
|
39
|
+
dates). Use <dsds:table>.
|
|
40
|
+
alternatives:
|
|
41
|
+
- to: table
|
|
42
|
+
|
|
43
|
+
- kind: guidelines
|
|
44
|
+
for: all
|
|
45
|
+
items:
|
|
46
|
+
- id: config-required
|
|
47
|
+
level: must
|
|
48
|
+
statement: >-
|
|
49
|
+
Always pass `config` (`satisfies ChartConfig`). Each data key has a Thai `label`
|
|
50
|
+
(e.g. "เงินสมทบจากนายจ้าง", employer contributions) and a `color`. Reference
|
|
51
|
+
colours in `fill` / `stroke` as `var(--color-<key>)`, never as raw colour values.
|
|
52
|
+
checks:
|
|
53
|
+
- href: ./Chart.stories.tsx#Playground
|
|
54
|
+
role: test
|
|
55
|
+
note: play function checks the label from config appears in the legend
|
|
56
|
+
checkedBy: assisted
|
|
57
|
+
- id: chart-tokens
|
|
58
|
+
level: must
|
|
59
|
+
statement: >-
|
|
60
|
+
Series colours use `var(--chart-1)` to `var(--chart-5)` (or another token such as
|
|
61
|
+
`--primary`) so dark mode switches by itself. Other mode-specific colours use
|
|
62
|
+
`theme: { light, dark }` in config.
|
|
63
|
+
checkedBy: manual
|
|
64
|
+
- id: max-five-series
|
|
65
|
+
level: should
|
|
66
|
+
statement: >-
|
|
67
|
+
At most 5 series per chart, matching the number of contrast-checked chart tokens.
|
|
68
|
+
A 6th series has no colour guaranteed to pass 3:1.
|
|
69
|
+
checkedBy: manual
|
|
70
|
+
- id: currency-formatter
|
|
71
|
+
level: must
|
|
72
|
+
statement: >-
|
|
73
|
+
Money values in the tooltip need a `formatter` that formats AUD with
|
|
74
|
+
`Intl.NumberFormat("th-TH", { style: "currency", currency: "AUD" })`. The tooltip
|
|
75
|
+
only shows the number via `toLocaleString("th-TH")`, with no currency.
|
|
76
|
+
checkedBy: manual
|
|
77
|
+
- id: month-labels-thai
|
|
78
|
+
level: should
|
|
79
|
+
statement: >-
|
|
80
|
+
X-axis month labels use short Thai month names ("มิ.ย.", "พ.ย.") and the chart's
|
|
81
|
+
`aria-label` uses the Buddhist year.
|
|
82
|
+
refs:
|
|
83
|
+
- to: shared-content#buddhist-year
|
|
84
|
+
rel: relates-to
|
|
85
|
+
checkedBy: manual
|
|
86
|
+
- id: tooltip-indicator
|
|
87
|
+
level: may
|
|
88
|
+
statement: >-
|
|
89
|
+
`ChartTooltipContent` uses `indicator="line"` for line/area charts and `dot`
|
|
90
|
+
(default) for bar charts.
|
|
91
|
+
|
|
92
|
+
- kind: guidelines
|
|
93
|
+
for: all
|
|
94
|
+
title: Accessibility
|
|
95
|
+
tags: [accessibility]
|
|
96
|
+
items:
|
|
97
|
+
- id: img-role-summary
|
|
98
|
+
level: must
|
|
99
|
+
statement: >-
|
|
100
|
+
`ChartContainer` has `role="img"` and an `aria-label` summarising what the chart
|
|
101
|
+
shows, including the period, e.g. "ยอดเงินในบัญชี มิถุนายน ถึง พฤศจิกายน 2569"
|
|
102
|
+
(account balance, June to November 2569).
|
|
103
|
+
evidence:
|
|
104
|
+
- href: https://www.w3.org/WAI/WCAG22/Understanding/non-text-content.html
|
|
105
|
+
role: WCAG 2.2 SC 1.1.1 (A)
|
|
106
|
+
checkedBy: manual
|
|
107
|
+
- id: accessibility-layer
|
|
108
|
+
level: must
|
|
109
|
+
statement: >-
|
|
110
|
+
Recharts charts get `accessibilityLayer` so each data point can be explored by
|
|
111
|
+
keyboard.
|
|
112
|
+
checkedBy: manual
|
|
113
|
+
- id: series-contrast
|
|
114
|
+
level: must
|
|
115
|
+
statement: >-
|
|
116
|
+
`--chart-1` to `--chart-5` pass 3:1 on the page and card backgrounds in both modes.
|
|
117
|
+
The lowest is `--chart-5` on the light background (4.60:1).
|
|
118
|
+
refines:
|
|
119
|
+
- to: shared-a11y#non-text-contrast
|
|
120
|
+
checks:
|
|
121
|
+
- href: ../../../scripts/tokens.mjs
|
|
122
|
+
role: test
|
|
123
|
+
note: CONTRAST_PAIRS "สีกราฟชุดที่ …"
|
|
124
|
+
checkedBy: automated
|
|
125
|
+
- id: not-colour-only
|
|
126
|
+
level: must
|
|
127
|
+
statement: >-
|
|
128
|
+
A chart with more than one series needs a legend (`ChartLegendContent`) with labels.
|
|
129
|
+
Users shouldn't have to tell series apart by colour alone.
|
|
130
|
+
evidence:
|
|
131
|
+
- href: https://www.w3.org/WAI/WCAG22/Understanding/use-of-color.html
|
|
132
|
+
role: WCAG 2.2 SC 1.4.1 (A)
|
|
133
|
+
checkedBy: manual
|
|
134
|
+
|
|
135
|
+
- kind: definitions
|
|
136
|
+
for: all
|
|
137
|
+
context: anatomy
|
|
138
|
+
items:
|
|
139
|
+
- term: ChartContainer
|
|
140
|
+
definition: >-
|
|
141
|
+
The frame, 16:9 and full width by default. Takes `config` (required) and
|
|
142
|
+
`initialDimension` (320×200 by default, before the real size is measured).
|
|
143
|
+
- term: ChartTooltip + ChartTooltipContent
|
|
144
|
+
definition: >-
|
|
145
|
+
Tooltip; takes `indicator`, `hideLabel`, `hideIndicator`, `formatter`
|
|
146
|
+
- term: ChartLegend + ChartLegendContent
|
|
147
|
+
definition: >-
|
|
148
|
+
Legend built from `config` (`hideIcon` hides the icon)
|
|
149
|
+
|
|
150
|
+
- kind: section
|
|
151
|
+
for: all
|
|
152
|
+
title: Open decisions
|
|
153
|
+
freeform:
|
|
154
|
+
- title: TODO
|
|
155
|
+
body: >-
|
|
156
|
+
Important data should also be readable as a table or text next to the chart; the
|
|
157
|
+
format isn't decided. The tooltip doesn't show currency automatically yet.
|
|
158
|
+
|
|
159
|
+
sourceFiles:
|
|
160
|
+
- platform: react
|
|
161
|
+
file: ./Chart.tsx
|
|
162
|
+
|
|
163
|
+
imports:
|
|
164
|
+
- platform: react
|
|
165
|
+
code: >-
|
|
166
|
+
import { ChartContainer, ChartLegend, ChartLegendContent, ChartTooltip, ChartTooltipContent, type ChartConfig } from "@designil/labdsnov"
|
|
167
|
+
package: "@designil/labdsnov"
|
|
168
|
+
|
|
169
|
+
traits:
|
|
170
|
+
- traitType: variant
|
|
171
|
+
kind: enum
|
|
172
|
+
id: indicator
|
|
173
|
+
description: >-
|
|
174
|
+
The colour marker before each value in `ChartTooltipContent`
|
|
175
|
+
values:
|
|
176
|
+
- id: dot
|
|
177
|
+
description: >-
|
|
178
|
+
A colour dot (default), suits bar charts
|
|
179
|
+
- id: line
|
|
180
|
+
description: >-
|
|
181
|
+
A vertical line, suits line and area charts
|
|
182
|
+
- id: dashed
|
|
183
|
+
description: >-
|
|
184
|
+
A dashed line
|
|
185
|
+
- traitType: variant
|
|
186
|
+
kind: boolean
|
|
187
|
+
id: hideLabel
|
|
188
|
+
description: >-
|
|
189
|
+
Hide the tooltip heading (e.g. the month name)
|
|
190
|
+
- traitType: variant
|
|
191
|
+
kind: boolean
|
|
192
|
+
id: hideIndicator
|
|
193
|
+
description: >-
|
|
194
|
+
Hide the colour marker in the tooltip
|
|
195
|
+
|
|
196
|
+
combos:
|
|
197
|
+
- subject: hideIndicator
|
|
198
|
+
level: should-not
|
|
199
|
+
items: [indicator.dashed, indicator.line]
|
|
200
|
+
note: >-
|
|
201
|
+
With the marker hidden, `indicator` has no effect.
|
|
202
|
+
|
|
203
|
+
alternatives:
|
|
204
|
+
- to: table
|
|
205
|
+
- to: progress
|
|
206
|
+
|
|
207
|
+
refs:
|
|
208
|
+
- href: ./Chart.md
|
|
209
|
+
rel: relates-to
|
|
210
|
+
role: Thai usage doc
|
|
211
|
+
- href: ./Chart.stories.tsx
|
|
212
|
+
rel: demo
|
|
213
|
+
role: CSF stories
|
|
214
|
+
- href: https://recharts.org
|
|
215
|
+
rel: relates-to
|
|
216
|
+
role: Recharts docs
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Chart (กราฟ)
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
กรอบสำหรับกราฟของ Recharts ที่ใส่สี ป้ายชื่อ tooltip และคำอธิบายสัญลักษณ์ตามระบบดีไซน์
|
|
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
|
+
ใช้ไลบรารี `recharts` (ติดตั้งมากับ `@designil/labdsnov` แล้ว) และ import ชนิดกราฟจาก `recharts` เอง
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
"use client"
|
|
19
|
+
|
|
20
|
+
import { Bar, BarChart, XAxis } from "recharts"
|
|
21
|
+
import { ChartContainer, ChartTooltip, ChartTooltipContent, type ChartConfig } from "@designil/labdsnov"
|
|
22
|
+
|
|
23
|
+
const config = {
|
|
24
|
+
employer: { label: "เงินสมทบจากนายจ้าง", color: "var(--chart-3)" },
|
|
25
|
+
} satisfies ChartConfig
|
|
26
|
+
|
|
27
|
+
<ChartContainer config={config} role="img" aria-label="เงินสมทบรายเดือน มิถุนายน ถึง พฤศจิกายน 2569">
|
|
28
|
+
<BarChart accessibilityLayer data={data}>
|
|
29
|
+
<XAxis dataKey="month" />
|
|
30
|
+
<ChartTooltip content={<ChartTooltipContent />} />
|
|
31
|
+
<Bar dataKey="employer" fill="var(--color-employer)" />
|
|
32
|
+
</BarChart>
|
|
33
|
+
</ChartContainer>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
- **`config`**: แต่ละ key ของข้อมูลมี `label` (ภาษาไทย) และ `color` สีจะกลายเป็น `var(--color-<key>)` ให้ใช้ใน `fill` / `stroke`
|
|
37
|
+
- ใช้ token สีกราฟ (`--chart-1` ถึง `--chart-5`) หรือ token อื่น เพื่อให้โหมดมืดเปลี่ยนตามเอง (หรือใช้ `theme: { light, dark }`)
|
|
38
|
+
- **การเข้าถึง**: ใส่ `role="img"` และ `aria-label` ที่สรุปกราฟ และ `accessibilityLayer` ให้ Recharts ใช้คีย์บอร์ดดูข้อมูลได้ TODO: ข้อมูลสำคัญควรมีตารางหรือข้อความให้อ่านด้วย ยังไม่ได้ตัดสินใจรูปแบบ
|
|
39
|
+
|
|
40
|
+
## When to use
|
|
41
|
+
|
|
42
|
+
- แนวโน้มตามเวลา เช่น ยอดเงินรายเดือน (กราฟพื้นที่หรือเส้น)
|
|
43
|
+
- เปรียบเทียบจำนวน เช่น เงินสมทบแยกตามแหล่ง (กราฟแท่ง)
|
|
44
|
+
|
|
45
|
+
## When not to use
|
|
46
|
+
|
|
47
|
+
- **ตัวเลขเดียว**: แสดงตัวเลขใน `Card`
|
|
48
|
+
- **สัดส่วนของเป้าหมายเดียว**: ใช้ `Progress`
|
|
49
|
+
- **ค่าที่ต้องอ่านแม่นยำ**: ใช้ `Table`
|
|
50
|
+
|
|
51
|
+
## Props and variants
|
|
52
|
+
|
|
53
|
+
### ChartContainer
|
|
54
|
+
|
|
55
|
+
| Prop | ค่า | ความหมาย |
|
|
56
|
+
| ------------------ | ------------------- | --------------------------------- |
|
|
57
|
+
| `config` | `ChartConfig` | **บังคับ** ป้ายชื่อและสีของแต่ละ key |
|
|
58
|
+
| `className` | class | ขนาด ปกติอัตราส่วน 16:9 กว้างเต็มพื้นที่ |
|
|
59
|
+
| `initialDimension` | `{ width, height }` | ขนาดก่อนวัดพื้นที่จริง (ค่าเริ่มต้น 320×200) |
|
|
60
|
+
|
|
61
|
+
### ChartTooltipContent
|
|
62
|
+
|
|
63
|
+
| Prop | ค่า | ค่าเริ่มต้น | ความหมาย |
|
|
64
|
+
| --------------- | ----------------------- | ------- | --------------------------- |
|
|
65
|
+
| `indicator` | `dot`, `line`, `dashed` | `dot` | สัญลักษณ์สีหน้าแต่ละค่า |
|
|
66
|
+
| `hideLabel` | `boolean` | `false` | ซ่อนหัวข้อ (เช่น ชื่อเดือน) |
|
|
67
|
+
| `hideIndicator` | `boolean` | `false` | ซ่อนสัญลักษณ์สี |
|
|
68
|
+
| `formatter` | ฟังก์ชัน | – | จัดรูปแบบค่าเอง เช่น สกุลเงิน AUD |
|
|
69
|
+
|
|
70
|
+
ตัวเลขใน tooltip ใช้รูปแบบภาษาไทย (`toLocaleString("th-TH")`) TODO: ยังไม่ได้แสดงสกุลเงินให้อัตโนมัติ ใช้ `formatter`
|
|
71
|
+
|
|
72
|
+
### ChartLegendContent
|
|
73
|
+
|
|
74
|
+
คำอธิบายสัญลักษณ์จาก `config` ใช้กับ `<ChartLegend content={<ChartLegendContent />} />` (`hideIcon` ซ่อนไอคอน)
|
|
75
|
+
|
|
76
|
+
## Tokens used
|
|
77
|
+
|
|
78
|
+
ค่าทั้งหมดมาจาก `src/styles/theme.css`
|
|
79
|
+
|
|
80
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
81
|
+
| ---------------------- | --------------------------- | --------------------------- | -------------------------- |
|
|
82
|
+
| `--chart-1` | `oklch(0.553 0.195 38.402)` | `oklch(0.705 0.187 47.604)` | สีกราฟชุดที่ 1: ส้ม (สีหลัก) |
|
|
83
|
+
| `--chart-2` | `oklch(0.52 0.1 190)` | `oklch(0.72 0.11 190)` | สีกราฟชุดที่ 2: เขียวอมฟ้า |
|
|
84
|
+
| `--chart-3` | `oklch(0.5 0.17 262)` | `oklch(0.7 0.14 262)` | สีกราฟชุดที่ 3: น้ำเงิน |
|
|
85
|
+
| `--chart-4` | `oklch(0.52 0.19 330)` | `oklch(0.72 0.17 330)` | สีกราฟชุดที่ 4: ชมพูม่วง |
|
|
86
|
+
| `--chart-5` | `oklch(0.55 0.15 135)` | `oklch(0.78 0.17 135)` | สีกราฟชุดที่ 5: เขียว |
|
|
87
|
+
| `--muted-foreground` | `oklch(0.5 0.027 107.3)` | `oklch(0.737 0.021 106.9)` | ตัวอักษรแกน, ชื่อใน tooltip |
|
|
88
|
+
| `--border` | `oklch(0.93 0.007 106.5)` | `oklch(1 0 0 / 10%)` | เส้นตาราง (50%), เส้น cursor |
|
|
89
|
+
| `--muted` | `oklch(0.966 0.005 106.5)` | `oklch(0.286 0.016 107.4)` | cursor ของกราฟแท่ง |
|
|
90
|
+
| `--popover` | `oklch(1 0 0)` | `oklch(0.228 0.013 107.4)` | พื้น tooltip |
|
|
91
|
+
| `--popover-foreground` | `oklch(0.153 0.006 107.1)` | `oklch(0.988 0.003 106.5)` | ตัวอักษร tooltip |
|
|
92
|
+
|
|
93
|
+
`--chart-1` ถึง `--chart-5` เป็นสีต่างโทนกัน (ส้มสีหลัก, เขียวอมฟ้า, น้ำเงิน, ชมพูม่วง, เขียว) แต่ละสีมี contrast อย่างน้อย 3:1 กับพื้นหน้าและพื้น `Card` ทั้งสองโหมด ใช้ตามลำดับ TODO: ยังไม่ได้ตรวจว่าแยกสีได้สำหรับผู้ที่มองเห็นสีผิดปกติ ควรมีป้ายชื่อหรือ legend เสมอ
|
|
94
|
+
|
|
95
|
+
## Example
|
|
96
|
+
|
|
97
|
+
จาก story `BalanceArea` ใน `Chart.stories.tsx`:
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
const balanceConfig = {
|
|
101
|
+
balance: { label: "ยอดเงิน (AUD)", color: "var(--primary)" },
|
|
102
|
+
} satisfies ChartConfig
|
|
103
|
+
|
|
104
|
+
<ChartContainer config={balanceConfig} role="img" aria-label="ยอดเงินในบัญชี มิถุนายน ถึง พฤศจิกายน 2569">
|
|
105
|
+
<AreaChart accessibilityLayer data={balance}>
|
|
106
|
+
<CartesianGrid vertical={false} />
|
|
107
|
+
<XAxis dataKey="month" tickLine={false} axisLine={false} tickMargin={8} />
|
|
108
|
+
<ChartTooltip content={<ChartTooltipContent indicator="line" />} />
|
|
109
|
+
<Area dataKey="balance" type="natural" fill="var(--color-balance)" fillOpacity={0.2} stroke="var(--color-balance)" />
|
|
110
|
+
</AreaChart>
|
|
111
|
+
</ChartContainer>
|
|
112
|
+
```
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: checkbox
|
|
3
|
+
name: Checkbox
|
|
4
|
+
description: >-
|
|
5
|
+
A box that turns one option on or off, or lets users pick several options from a list.
|
|
6
|
+
The box is 16px with a hit area larger than the box. Wraps Base UI's `Checkbox`.
|
|
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 accept terms or confirm a single statement that takes effect when the form
|
|
20
|
+
is submitted.
|
|
21
|
+
- level: should
|
|
22
|
+
statement: >-
|
|
23
|
+
Use to pick several options from a list, e.g. the channels for receiving documents.
|
|
24
|
+
- level: should
|
|
25
|
+
statement: >-
|
|
26
|
+
Use `indeterminate` for a "select all" with only some items selected (a dash
|
|
27
|
+
instead of a tick).
|
|
28
|
+
- level: must-not
|
|
29
|
+
statement: >-
|
|
30
|
+
Don't use when only one of several options can be picked. Use <dsds:radio-group>.
|
|
31
|
+
alternatives:
|
|
32
|
+
- to: radio-group
|
|
33
|
+
checkedBy: manual
|
|
34
|
+
- level: must-not
|
|
35
|
+
statement: >-
|
|
36
|
+
Don't use for a setting that takes effect immediately without saving. Use
|
|
37
|
+
<dsds:switch>.
|
|
38
|
+
alternatives:
|
|
39
|
+
- to: switch
|
|
40
|
+
checkedBy: manual
|
|
41
|
+
- level: must-not
|
|
42
|
+
statement: >-
|
|
43
|
+
Don't use a Checkbox to trigger an action such as "ลบรายการที่เลือก" (delete
|
|
44
|
+
selected). Use <dsds:button>.
|
|
45
|
+
alternatives:
|
|
46
|
+
- to: button
|
|
47
|
+
checkedBy: manual
|
|
48
|
+
|
|
49
|
+
- kind: guidelines
|
|
50
|
+
for: all
|
|
51
|
+
items:
|
|
52
|
+
- id: label-bound
|
|
53
|
+
level: must
|
|
54
|
+
statement: >-
|
|
55
|
+
Always bind a <dsds:label> with `id` / `htmlFor` so clicking the text ticks the
|
|
56
|
+
box. In forms use `Field orientation="horizontal"` so the Checkbox sits before the
|
|
57
|
+
text.
|
|
58
|
+
checks:
|
|
59
|
+
- href: ./Checkbox.stories.tsx#Toggle
|
|
60
|
+
role: test
|
|
61
|
+
note: play function checks that clicking the Label text toggles the value
|
|
62
|
+
uses:
|
|
63
|
+
- to: label
|
|
64
|
+
- to: field
|
|
65
|
+
checkedBy: automated
|
|
66
|
+
- id: label-is-positive
|
|
67
|
+
level: should
|
|
68
|
+
statement: >-
|
|
69
|
+
Phrase the label as a statement that's true when ticked ("รับใบแจ้งยอดทางอีเมล",
|
|
70
|
+
receive statements by email), not a negative ("ไม่ต้องการรับ…", don't want…), which
|
|
71
|
+
reads backwards when ticked.
|
|
72
|
+
checkedBy: manual
|
|
73
|
+
- id: required-consent
|
|
74
|
+
level: should
|
|
75
|
+
statement: >-
|
|
76
|
+
Required consent uses `required` plus a `FieldError` when unticked. Don't disable
|
|
77
|
+
the submit button until it's ticked: users can't tell why they can't press it.
|
|
78
|
+
uses:
|
|
79
|
+
- to: field
|
|
80
|
+
checkedBy: manual
|
|
81
|
+
- id: no-default-consent
|
|
82
|
+
level: must-not
|
|
83
|
+
statement: >-
|
|
84
|
+
Never pre-tick consent (terms, marketing, data sharing) with `defaultChecked`.
|
|
85
|
+
checkedBy: manual
|
|
86
|
+
|
|
87
|
+
- kind: guidelines
|
|
88
|
+
for: all
|
|
89
|
+
title: Accessibility
|
|
90
|
+
tags: [accessibility]
|
|
91
|
+
items:
|
|
92
|
+
- id: space-toggles
|
|
93
|
+
level: must
|
|
94
|
+
statement: >-
|
|
95
|
+
Tab to the box and press Space to tick it (`aria-checked` follows). Indeterminate
|
|
96
|
+
is announced as `aria-checked="mixed"`.
|
|
97
|
+
evidence:
|
|
98
|
+
- href: https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/
|
|
99
|
+
role: WAI-ARIA APG Checkbox pattern
|
|
100
|
+
checks:
|
|
101
|
+
- href: ./Checkbox.stories.tsx#Keyboard
|
|
102
|
+
role: test
|
|
103
|
+
checkedBy: automated
|
|
104
|
+
- id: border-contrast
|
|
105
|
+
level: must
|
|
106
|
+
statement: >-
|
|
107
|
+
The unticked border (`--control-border`) passes 3.93:1 light / 3.44:1 dark, and the
|
|
108
|
+
ticked box 5.23:1 / 6.99:1. Don't change the border to `--border` (a decorative
|
|
109
|
+
colour that fails 3:1).
|
|
110
|
+
refines:
|
|
111
|
+
- to: shared-a11y#non-text-contrast
|
|
112
|
+
checks:
|
|
113
|
+
- href: ../../../scripts/tokens.mjs
|
|
114
|
+
role: test
|
|
115
|
+
note: CONTRAST_PAIRS "ขอบ Checkbox / Radio …" and "Checkbox / Radio ที่เลือกแล้ว"
|
|
116
|
+
checkedBy: automated
|
|
117
|
+
- id: hit-area
|
|
118
|
+
level: must
|
|
119
|
+
statement: >-
|
|
120
|
+
The hit area is at least 24×24px even though the box is 16px. Don't set
|
|
121
|
+
`overflow: hidden` on a wrapper that would clip it.
|
|
122
|
+
refines:
|
|
123
|
+
- to: shared-a11y#target-size
|
|
124
|
+
checkedBy: manual
|
|
125
|
+
- refs:
|
|
126
|
+
- to: shared-a11y#invalid-has-message
|
|
127
|
+
rel: same-as
|
|
128
|
+
|
|
129
|
+
- kind: definitions
|
|
130
|
+
for: all
|
|
131
|
+
title: States
|
|
132
|
+
context: labdsnov.states
|
|
133
|
+
items:
|
|
134
|
+
- term: Unticked
|
|
135
|
+
definition: >-
|
|
136
|
+
Box with a `--control-border` border
|
|
137
|
+
- term: Ticked / indeterminate
|
|
138
|
+
definition: >-
|
|
139
|
+
Primary (orange) box with a light tick or dash
|
|
140
|
+
- term: aria-invalid
|
|
141
|
+
definition: >-
|
|
142
|
+
Red border and faint red ring
|
|
143
|
+
- term: Disabled
|
|
144
|
+
definition: >-
|
|
145
|
+
Dimmed to 50%
|
|
146
|
+
|
|
147
|
+
sourceFiles:
|
|
148
|
+
- platform: react
|
|
149
|
+
file: ./Checkbox.tsx
|
|
150
|
+
|
|
151
|
+
imports:
|
|
152
|
+
- platform: react
|
|
153
|
+
code: >-
|
|
154
|
+
import { Checkbox } from "@designil/labdsnov"
|
|
155
|
+
package: "@designil/labdsnov"
|
|
156
|
+
|
|
157
|
+
traits:
|
|
158
|
+
- traitType: state
|
|
159
|
+
kind: boolean
|
|
160
|
+
id: checked
|
|
161
|
+
description: >-
|
|
162
|
+
Ticked (`checked` / `defaultChecked`)
|
|
163
|
+
- traitType: state
|
|
164
|
+
kind: boolean
|
|
165
|
+
id: indeterminate
|
|
166
|
+
description: >-
|
|
167
|
+
Partly selected; shows a dash instead of a tick
|
|
168
|
+
- traitType: state
|
|
169
|
+
kind: boolean
|
|
170
|
+
id: disabled
|
|
171
|
+
description: >-
|
|
172
|
+
Disabled, dimmed to 50%
|
|
173
|
+
- traitType: state
|
|
174
|
+
kind: boolean
|
|
175
|
+
id: required
|
|
176
|
+
description: >-
|
|
177
|
+
Must be ticked before the form is submitted
|
|
178
|
+
- traitType: state
|
|
179
|
+
kind: boolean
|
|
180
|
+
id: aria-invalid
|
|
181
|
+
name: Invalid
|
|
182
|
+
description: >-
|
|
183
|
+
Invalid value; red border and faint red ring
|
|
184
|
+
|
|
185
|
+
combos:
|
|
186
|
+
- subject: indeterminate
|
|
187
|
+
level: should-not
|
|
188
|
+
items: [checked]
|
|
189
|
+
note: >-
|
|
190
|
+
indeterminate overrides how checked is shown, so setting both makes the visible state
|
|
191
|
+
differ from the submitted value.
|
|
192
|
+
|
|
193
|
+
uses:
|
|
194
|
+
- to: label
|
|
195
|
+
alternatives:
|
|
196
|
+
- to: radio-group
|
|
197
|
+
- to: switch
|
|
198
|
+
|
|
199
|
+
refs:
|
|
200
|
+
- href: ./Checkbox.md
|
|
201
|
+
rel: relates-to
|
|
202
|
+
role: Thai usage doc
|
|
203
|
+
- href: ./Checkbox.stories.tsx
|
|
204
|
+
rel: demo
|
|
205
|
+
role: CSF stories
|
|
206
|
+
- href: https://www.figma.com/design/QsKWb3A53lIh4QBDnAkGHh/labdsnov?node-id=12-51
|
|
207
|
+
rel: design
|
|
208
|
+
role: Checkbox in Figma
|
|
209
|
+
- href: ../../../figma/Checkbox.figma.ts
|
|
210
|
+
rel: source
|
|
211
|
+
role: Code Connect template
|
|
212
|
+
|
|
213
|
+
$extensions:
|
|
214
|
+
com.figma:
|
|
215
|
+
nodeId: "12:51"
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Checkbox (ช่องทำเครื่องหมาย)
|
|
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 { Checkbox, Label } from "@designil/labdsnov"
|
|
17
|
+
|
|
18
|
+
;<div className="flex items-center gap-2">
|
|
19
|
+
<Checkbox id="terms" />
|
|
20
|
+
<Label htmlFor="terms">ยอมรับข้อกำหนดและเงื่อนไข</Label>
|
|
21
|
+
</div>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
- ผูกกับ `Label` ด้วย `id` / `htmlFor` เสมอ คลิกที่ข้อความแล้วติ๊กได้
|
|
25
|
+
- ในฟอร์ม ใช้คู่กับ `Field orientation="horizontal"` (ดู [Field](../Field/Field.md))
|
|
26
|
+
|
|
27
|
+
## When to use
|
|
28
|
+
|
|
29
|
+
- ยอมรับเงื่อนไข หรือยืนยันข้อความหนึ่งข้อ ที่มีผลเมื่อกดส่งฟอร์ม
|
|
30
|
+
- เลือกได้หลายข้อจากรายการ เช่น ช่องทางที่ต้องการรับเอกสาร
|
|
31
|
+
- "เลือกทั้งหมด" ที่เลือกไว้บางรายการ: ใช้สถานะ `indeterminate` (ขีดแทนเครื่องหมายถูก)
|
|
32
|
+
|
|
33
|
+
## When not to use
|
|
34
|
+
|
|
35
|
+
| สถานการณ์ | ใช้แทน |
|
|
36
|
+
| ---------------------------- | ------------ |
|
|
37
|
+
| เลือกได้ข้อเดียวจากหลายข้อ | `RadioGroup` |
|
|
38
|
+
| การตั้งค่าที่มีผลทันทีโดยไม่ต้องกดบันทึก | `Switch` |
|
|
39
|
+
| การกระทำ เช่น "ลบรายการที่เลือก" | `Button` |
|
|
40
|
+
|
|
41
|
+
## Props and variants
|
|
42
|
+
|
|
43
|
+
ไม่มี variant หรือ size กล่องขนาด 16px แต่พื้นที่กดกว้างกว่ากล่องเล็กน้อย
|
|
44
|
+
|
|
45
|
+
| Prop | ค่า | ค่าเริ่มต้น | ความหมาย |
|
|
46
|
+
| ----------------------------- | ----------------- | ------- | ------------------------------------- |
|
|
47
|
+
| `checked` / `onCheckedChange` | `boolean` / ฟังก์ชัน | – | ควบคุมจากภายนอก |
|
|
48
|
+
| `defaultChecked` | `boolean` | `false` | ติ๊กไว้ตั้งแต่แรก |
|
|
49
|
+
| `indeterminate` | `boolean` | `false` | เลือกไว้บางส่วน แสดงขีดแทนเครื่องหมายถูก |
|
|
50
|
+
| `disabled` | `boolean` | `false` | ปิดใช้งาน จางลง 50% |
|
|
51
|
+
| `required` | `boolean` | `false` | ต้องติ๊กก่อนส่งฟอร์ม |
|
|
52
|
+
| `name` / `value` | ข้อความ | – | ชื่อและค่าที่ส่งไปกับฟอร์ม |
|
|
53
|
+
| `aria-invalid` | `boolean` | – | ข้อมูลไม่ถูกต้อง เส้นขอบสีแดงและวงแหวนแดงจาง |
|
|
54
|
+
| `className` | class | – | ปรับหน้าตาเฉพาะจุดครั้งเดียว |
|
|
55
|
+
|
|
56
|
+
### States
|
|
57
|
+
|
|
58
|
+
- **ไม่ได้ติ๊ก**: กล่องมีเส้นขอบ (contrast 3:1)
|
|
59
|
+
- **ติ๊กแล้ว / บางส่วน**: กล่องสีหลัก (ส้ม) เครื่องหมายสีอ่อน
|
|
60
|
+
- **Focus จากคีย์บอร์ด**: วงแหวนทึบสี `--focus-ring` กด Space เพื่อติ๊ก
|
|
61
|
+
|
|
62
|
+
## Tokens used
|
|
63
|
+
|
|
64
|
+
ค่าทั้งหมดมาจาก `src/styles/theme.css`
|
|
65
|
+
|
|
66
|
+
### Component tokens
|
|
67
|
+
|
|
68
|
+
token เฉพาะของคอมโพเนนต์นี้ ชี้ไปที่ semantic token ด้านล่าง เปลี่ยนที่นี่เพื่อปรับเฉพาะคอมโพเนนต์นี้ (โหมดมืด "–" = ใช้ค่าเดียวกับโหมดสว่าง)
|
|
69
|
+
|
|
70
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
71
|
+
| ---------------------- | ---------------------- | ------------------- | ----------------------------------------------- |
|
|
72
|
+
| `--control-bg` | `--background` | `--input` 50% | พื้นตอนยังไม่เลือก |
|
|
73
|
+
| `--control-checked-bg` | `--primary` | – | พื้นและเส้นขอบตอนเลือก |
|
|
74
|
+
| `--control-checked-fg` | `--primary-foreground` | – | เครื่องหมายถูก / จุด ตอนเลือก |
|
|
75
|
+
| `--focus-ring` | `--ring` | – | วงแหวน focus จากคีย์บอร์ดของทุกคอมโพเนนต์ (ทึบ 2px) |
|
|
76
|
+
| `--invalid-border` | `--destructive` | – | เส้นขอบเมื่อข้อมูลไม่ถูกต้อง และวงแหวน focus ขณะไม่ถูกต้อง |
|
|
77
|
+
| `--invalid-ring` | `--destructive` 20% | `--destructive` 40% | วงแหวนจางรอบช่องที่ไม่ถูกต้อง (ตกแต่ง) |
|
|
78
|
+
|
|
79
|
+
### Semantic tokens
|
|
80
|
+
|
|
81
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
82
|
+
| ---------------------- | --------------------------- | --------------------------- | --------------------------- |
|
|
83
|
+
| `--input` | `oklch(0.93 0.007 106.5)` | `oklch(1 0 0 / 15%)` | พื้นกล่องที่ไม่ได้ติ๊ก (90%) |
|
|
84
|
+
| `--primary` | `oklch(0.553 0.195 38.402)` | `oklch(0.705 0.187 47.604)` | พื้นและเส้นขอบเมื่อติ๊ก |
|
|
85
|
+
| `--primary-foreground` | `oklch(0.98 0.016 73.684)` | `oklch(0.205 0.05 40)` | เครื่องหมายถูกและขีด |
|
|
86
|
+
| `--ring` | `oklch(0.45 0.03 106.9)` | `oklch(0.8 0.02 106.9)` | วงแหวน focus |
|
|
87
|
+
| `--destructive` | `oklch(0.505 0.2 27.325)` | `oklch(0.75 0.16 22.216)` | สถานะไม่ถูกต้อง |
|
|
88
|
+
| `--background` | `oklch(1 0 0)` | `oklch(0.153 0.006 107.1)` | ผ่าน token ของคอมโพเนนต์ด้านบน |
|
|
89
|
+
|
|
90
|
+
## Example
|
|
91
|
+
|
|
92
|
+
จาก story `States` ใน `Checkbox.stories.tsx` (บางส่วน):
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
<div className="grid gap-3">
|
|
96
|
+
<div className="flex items-center gap-2">
|
|
97
|
+
<Checkbox id="cb-on" defaultChecked />
|
|
98
|
+
<Label htmlFor="cb-on">เลือกแล้ว</Label>
|
|
99
|
+
</div>
|
|
100
|
+
<div className="flex items-center gap-2">
|
|
101
|
+
<Checkbox id="cb-some" indeterminate />
|
|
102
|
+
<Label htmlFor="cb-some">เลือกบางรายการ</Label>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
```
|