@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,124 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: skeleton
|
|
3
|
+
name: Skeleton
|
|
4
|
+
description: >-
|
|
5
|
+
A softly pulsing grey box standing in for content that is loading, so the page
|
|
6
|
+
layout shows before the data arrives. 18px radius, no text of its own.
|
|
7
|
+
metadata:
|
|
8
|
+
status: {status: stable}
|
|
9
|
+
since: 1.0.0
|
|
10
|
+
tags: [feedback]
|
|
11
|
+
|
|
12
|
+
sections:
|
|
13
|
+
- kind: guidelines
|
|
14
|
+
for: all
|
|
15
|
+
framing: when-to-use
|
|
16
|
+
items:
|
|
17
|
+
- level: should
|
|
18
|
+
statement: >-
|
|
19
|
+
Use while content whose shape is known is loading, e.g. fund cards, a balance,
|
|
20
|
+
a transactions table.
|
|
21
|
+
- level: should-not
|
|
22
|
+
statement: >-
|
|
23
|
+
Don't use for work with known progress (file upload). Use <dsds:progress>.
|
|
24
|
+
alternatives:
|
|
25
|
+
- to: progress
|
|
26
|
+
- level: must-not
|
|
27
|
+
statement: >-
|
|
28
|
+
Never use while waiting for the result of a user action (pressing save).
|
|
29
|
+
Disable the button and add a <dsds:spinner>.
|
|
30
|
+
alternatives:
|
|
31
|
+
- to: spinner
|
|
32
|
+
checkedBy: manual
|
|
33
|
+
- level: should-not
|
|
34
|
+
statement: >-
|
|
35
|
+
Don't show it for very fast loads (under about 300ms): a skeleton that flashes
|
|
36
|
+
for an instant is distracting (the delay isn't defined yet, see Open decisions).
|
|
37
|
+
|
|
38
|
+
- kind: guidelines
|
|
39
|
+
for: all
|
|
40
|
+
items:
|
|
41
|
+
- id: size-required
|
|
42
|
+
level: must
|
|
43
|
+
statement: >-
|
|
44
|
+
Always set the size with `className` (`h-4 w-48`) to match the real content, so
|
|
45
|
+
the page doesn't jump when the data arrives. Skeleton has no size of its own.
|
|
46
|
+
checkedBy: manual
|
|
47
|
+
- id: mirror-layout
|
|
48
|
+
level: should
|
|
49
|
+
statement: >-
|
|
50
|
+
Shape the skeleton like the component that replaces it, e.g. FundCard: a square
|
|
51
|
+
image `rounded-3xl` + 3 lines; Avatar: `rounded-full`.
|
|
52
|
+
example:
|
|
53
|
+
ref:
|
|
54
|
+
href: ./Skeleton.stories.tsx#FundCardLoading
|
|
55
|
+
rel: demo
|
|
56
|
+
uses:
|
|
57
|
+
- to: fund-card
|
|
58
|
+
checkedBy: manual
|
|
59
|
+
- id: then-empty
|
|
60
|
+
level: must
|
|
61
|
+
statement: >-
|
|
62
|
+
When loading finishes with no data, switch to <dsds:empty>; when loading fails,
|
|
63
|
+
switch to a `destructive` <dsds:alert>. Never leave the skeleton showing.
|
|
64
|
+
checkedBy: manual
|
|
65
|
+
|
|
66
|
+
- kind: guidelines
|
|
67
|
+
for: all
|
|
68
|
+
title: Accessibility
|
|
69
|
+
tags: [accessibility]
|
|
70
|
+
items:
|
|
71
|
+
- id: status-wrapper
|
|
72
|
+
level: must
|
|
73
|
+
statement: >-
|
|
74
|
+
Wrap each group of skeletons in `role="status"` with an `aria-label` saying what
|
|
75
|
+
is loading ("กำลังโหลดตัวเลือกการลงทุน" (loading investment options)), because
|
|
76
|
+
Skeleton has no text to read. One wrapper per section, not per box.
|
|
77
|
+
evidence:
|
|
78
|
+
- href: https://www.w3.org/WAI/WCAG22/Understanding/status-messages.html
|
|
79
|
+
role: WCAG 2.2 SC 4.1.3 (AA)
|
|
80
|
+
checks:
|
|
81
|
+
- href: ./Skeleton.stories.tsx#Playground
|
|
82
|
+
role: test
|
|
83
|
+
- href: ./Skeleton.stories.tsx#FundCardLoading
|
|
84
|
+
role: test
|
|
85
|
+
checkedBy: automated
|
|
86
|
+
- id: reduced-motion
|
|
87
|
+
level: should
|
|
88
|
+
statement: >-
|
|
89
|
+
The pulse is a gentle animation. Don't add extra animation (e.g. a moving
|
|
90
|
+
shimmer) that doesn't stop under `prefers-reduced-motion`.
|
|
91
|
+
evidence:
|
|
92
|
+
- href: https://www.w3.org/WAI/WCAG22/Understanding/animation-from-interactions.html
|
|
93
|
+
role: WCAG 2.2 SC 2.3.3 (AAA)
|
|
94
|
+
checkedBy: manual
|
|
95
|
+
|
|
96
|
+
- kind: section
|
|
97
|
+
for: all
|
|
98
|
+
title: Open decisions
|
|
99
|
+
freeform:
|
|
100
|
+
- title: TODO
|
|
101
|
+
body: >-
|
|
102
|
+
No delay before showing a skeleton has been defined yet.
|
|
103
|
+
|
|
104
|
+
sourceFiles:
|
|
105
|
+
- platform: react
|
|
106
|
+
file: ./Skeleton.tsx
|
|
107
|
+
|
|
108
|
+
imports:
|
|
109
|
+
- platform: react
|
|
110
|
+
code: >-
|
|
111
|
+
import { Skeleton } from "@designil/labdsnov"
|
|
112
|
+
package: "@designil/labdsnov"
|
|
113
|
+
|
|
114
|
+
alternatives:
|
|
115
|
+
- to: progress
|
|
116
|
+
- to: spinner
|
|
117
|
+
|
|
118
|
+
refs:
|
|
119
|
+
- href: ./Skeleton.md
|
|
120
|
+
rel: relates-to
|
|
121
|
+
role: Thai usage doc
|
|
122
|
+
- href: ./Skeleton.stories.tsx
|
|
123
|
+
rel: demo
|
|
124
|
+
role: CSF stories
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Skeleton (โครงร่างระหว่างโหลด)
|
|
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 { Skeleton } from "@designil/labdsnov"
|
|
17
|
+
|
|
18
|
+
;<div role="status" aria-label="กำลังโหลดยอดเงิน">
|
|
19
|
+
<Skeleton className="h-4 w-48" />
|
|
20
|
+
</div>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
- กำหนดขนาดด้วย `className` ให้เท่ากับเนื้อหาจริง หน้าจะไม่กระโดดเมื่อข้อมูลมาถึง
|
|
24
|
+
- ครอบกลุ่ม skeleton ด้วย `role="status"` และ `aria-label` ที่บอกว่ากำลังโหลดอะไร เพราะ Skeleton ไม่มีข้อความให้โปรแกรมอ่านหน้าจออ่าน
|
|
25
|
+
|
|
26
|
+
## When to use
|
|
27
|
+
|
|
28
|
+
- เนื้อหาที่รู้รูปร่างล่วงหน้ากำลังโหลด เช่น การ์ดกองทุน ยอดเงิน ตารางธุรกรรม
|
|
29
|
+
|
|
30
|
+
## When not to use
|
|
31
|
+
|
|
32
|
+
- **การทำงานที่รู้ความคืบหน้า** (อัปโหลดไฟล์): ใช้ `Progress`
|
|
33
|
+
- **การกระทำของผู้ใช้ที่รอผล** (กดบันทึก): ปิดปุ่มและใส่ `Spinner` (ดู [Spinner](../Spinner/Spinner.md))
|
|
34
|
+
- **โหลดเร็วมาก** (ต่ำกว่าประมาณ 300ms): skeleton กะพริบแวบเดียวดูรบกวน TODO: ยังไม่ได้กำหนดเวลาหน่วงก่อนแสดง
|
|
35
|
+
|
|
36
|
+
## Props and variants
|
|
37
|
+
|
|
38
|
+
ไม่มี variant หรือ size มุมโค้ง 18px ปรับรูปร่างด้วย `className` เช่น `rounded-full` สำหรับรูปโปรไฟล์
|
|
39
|
+
|
|
40
|
+
| Prop | ค่า | ความหมาย |
|
|
41
|
+
| ----------- | ----- | ----------------------------- |
|
|
42
|
+
| `className` | class | **ต้องใส่** ขนาด เช่น `h-4 w-48` |
|
|
43
|
+
|
|
44
|
+
## Tokens used
|
|
45
|
+
|
|
46
|
+
ค่าทั้งหมดมาจาก `src/styles/theme.css`
|
|
47
|
+
|
|
48
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
49
|
+
| ---------- | -------------------------- | -------------------------- | ------------------------------- |
|
|
50
|
+
| `--muted` | `oklch(0.966 0.005 106.5)` | `oklch(0.286 0.016 107.4)` | สีกล่อง |
|
|
51
|
+
| `--radius` | `0.625rem` | – | มุมโค้ง (`--radius × 1.8` = 18px) |
|
|
52
|
+
|
|
53
|
+
## Example
|
|
54
|
+
|
|
55
|
+
จาก story `FundCardLoading` ใน `Skeleton.stories.tsx`:
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
<div
|
|
59
|
+
className="flex w-64 flex-col gap-3"
|
|
60
|
+
role="status"
|
|
61
|
+
aria-label="กำลังโหลดตัวเลือกการลงทุน"
|
|
62
|
+
>
|
|
63
|
+
<Skeleton className="aspect-square w-full rounded-3xl" />
|
|
64
|
+
<Skeleton className="h-3 w-32" />
|
|
65
|
+
<Skeleton className="h-4 w-48" />
|
|
66
|
+
<Skeleton className="h-5 w-24" />
|
|
67
|
+
</div>
|
|
68
|
+
```
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: slider
|
|
3
|
+
name: Slider
|
|
4
|
+
description: >-
|
|
5
|
+
Picks a number (or a range) within set bounds, by dragging or with the arrow keys.
|
|
6
|
+
8px track, 24×16px thumb. Wraps Base UI `Slider`; numbers are formatted `th-TH`.
|
|
7
|
+
metadata:
|
|
8
|
+
status: {status: stable}
|
|
9
|
+
since: 1.0.0
|
|
10
|
+
tags: [form]
|
|
11
|
+
|
|
12
|
+
sections:
|
|
13
|
+
- kind: guidelines
|
|
14
|
+
for: all
|
|
15
|
+
framing: when-to-use
|
|
16
|
+
items:
|
|
17
|
+
- level: should
|
|
18
|
+
statement: >-
|
|
19
|
+
Use for values that needn't be exact and whose effect the user wants to see
|
|
20
|
+
right away, e.g. a 0–15% extra contribution rate in a calculator.
|
|
21
|
+
- level: should
|
|
22
|
+
statement: >-
|
|
23
|
+
Use two values to pick a range, e.g. age 30–60.
|
|
24
|
+
example:
|
|
25
|
+
ref:
|
|
26
|
+
href: ./Slider.stories.tsx#Range
|
|
27
|
+
rel: demo
|
|
28
|
+
- level: must-not
|
|
29
|
+
statement: >-
|
|
30
|
+
Never use for an amount of money that must be typed exactly. Use
|
|
31
|
+
`Input type="number"` or <dsds:input-group> ("AU$").
|
|
32
|
+
alternatives:
|
|
33
|
+
- to: input
|
|
34
|
+
- to: input-group
|
|
35
|
+
checkedBy: manual
|
|
36
|
+
- level: should-not
|
|
37
|
+
statement: >-
|
|
38
|
+
Don't use for a few named options. Use <dsds:radio-group> or
|
|
39
|
+
<dsds:toggle-group>.
|
|
40
|
+
alternatives:
|
|
41
|
+
- to: radio-group
|
|
42
|
+
- to: toggle-group
|
|
43
|
+
- level: must-not
|
|
44
|
+
statement: >-
|
|
45
|
+
Never use to show progress that can't be changed. Use <dsds:progress>.
|
|
46
|
+
alternatives:
|
|
47
|
+
- to: progress
|
|
48
|
+
checkedBy: manual
|
|
49
|
+
|
|
50
|
+
- kind: guidelines
|
|
51
|
+
for: all
|
|
52
|
+
items:
|
|
53
|
+
- id: show-value
|
|
54
|
+
level: must
|
|
55
|
+
statement: >-
|
|
56
|
+
Always show the chosen value as a number nearby (e.g. in the label
|
|
57
|
+
"อัตราเงินสมทบเพิ่มเติม 5%" (extra contribution rate 5%)). The thumb position
|
|
58
|
+
alone can't be read precisely.
|
|
59
|
+
example:
|
|
60
|
+
ref:
|
|
61
|
+
href: ./Slider.stories.tsx#WithValue
|
|
62
|
+
rel: demo
|
|
63
|
+
checkedBy: manual
|
|
64
|
+
- id: step-meaningful
|
|
65
|
+
level: should
|
|
66
|
+
statement: >-
|
|
67
|
+
Set `step` to a meaningful unit (0.5% for a rate, 1 year for age) and
|
|
68
|
+
`largeStep` (default 10) for Page Up/Down.
|
|
69
|
+
checkedBy: manual
|
|
70
|
+
- id: min-max-labels
|
|
71
|
+
level: should
|
|
72
|
+
statement: >-
|
|
73
|
+
Show the min/max under the track when the bounds aren't clear from context
|
|
74
|
+
(e.g. "0%" and "15%").
|
|
75
|
+
checkedBy: manual
|
|
76
|
+
- id: vertical-height
|
|
77
|
+
level: may
|
|
78
|
+
statement: >-
|
|
79
|
+
`orientation="vertical"` is at least 160px tall.
|
|
80
|
+
|
|
81
|
+
- kind: guidelines
|
|
82
|
+
for: all
|
|
83
|
+
title: Accessibility
|
|
84
|
+
tags: [accessibility]
|
|
85
|
+
items:
|
|
86
|
+
- id: aria-label-fn
|
|
87
|
+
level: must
|
|
88
|
+
statement: >-
|
|
89
|
+
Name every thumb with `getAriaLabel` (`() => "อัตราเงินสมทบเพิ่มเติม"`; for a
|
|
90
|
+
range `(index) => index === 0 ? "อายุต่ำสุด" : "อายุสูงสุด"` (min age / max
|
|
91
|
+
age)), unless `aria-labelledby` points at a visible label.
|
|
92
|
+
evidence:
|
|
93
|
+
- href: https://www.w3.org/WAI/WCAG22/Understanding/name-role-value.html
|
|
94
|
+
role: WCAG 2.2 SC 4.1.2 (A)
|
|
95
|
+
checkedBy: manual
|
|
96
|
+
- id: value-text-unit
|
|
97
|
+
level: must
|
|
98
|
+
statement: >-
|
|
99
|
+
`getAriaValueText` adds the unit in Thai
|
|
100
|
+
(`(formatted) => \`${formatted}% ของเงินเดือน\`` (of salary)); otherwise screen
|
|
101
|
+
readers read only the number.
|
|
102
|
+
checks:
|
|
103
|
+
- href: ./Slider.stories.tsx#Keyboard
|
|
104
|
+
role: test
|
|
105
|
+
note: play function checks aria-valuetext "5% ของเงินเดือน" and arrows/End
|
|
106
|
+
checkedBy: automated
|
|
107
|
+
- id: drag-alternative
|
|
108
|
+
level: must
|
|
109
|
+
statement: >-
|
|
110
|
+
The value can be changed by keyboard (arrows, Page Up/Down, Home/End) and by
|
|
111
|
+
clicking the track without dragging. Never disable clicking the track.
|
|
112
|
+
evidence:
|
|
113
|
+
- href: https://www.w3.org/WAI/WCAG22/Understanding/dragging-movements.html
|
|
114
|
+
role: WCAG 2.2 SC 2.5.7 (AA)
|
|
115
|
+
checkedBy: manual
|
|
116
|
+
- id: slider-contrast
|
|
117
|
+
level: must
|
|
118
|
+
statement: >-
|
|
119
|
+
Selected range on the track 4.74:1 / 5.09:1, track border 3.93:1 / 4.05:1,
|
|
120
|
+
thumb border 5.23:1 / 6.99:1 (light / dark).
|
|
121
|
+
checks:
|
|
122
|
+
- href: ../../../scripts/tokens.mjs
|
|
123
|
+
role: test
|
|
124
|
+
note: CONTRAST_PAIRS "… Slider …"
|
|
125
|
+
checkedBy: automated
|
|
126
|
+
|
|
127
|
+
- kind: definitions
|
|
128
|
+
for: all
|
|
129
|
+
context: keyboard
|
|
130
|
+
items:
|
|
131
|
+
- term: Arrows
|
|
132
|
+
definition: >-
|
|
133
|
+
Move by `step`.
|
|
134
|
+
- term: Page Up / Page Down
|
|
135
|
+
definition: >-
|
|
136
|
+
Move by `largeStep`.
|
|
137
|
+
- term: Home / End
|
|
138
|
+
definition: >-
|
|
139
|
+
Go to the min / max.
|
|
140
|
+
|
|
141
|
+
- kind: section
|
|
142
|
+
for: all
|
|
143
|
+
title: Open decisions
|
|
144
|
+
freeform:
|
|
145
|
+
- title: TODO
|
|
146
|
+
body: >-
|
|
147
|
+
Not decided whether calculators should have a typed input next to the Slider.
|
|
148
|
+
|
|
149
|
+
sourceFiles:
|
|
150
|
+
- platform: react
|
|
151
|
+
file: ./Slider.tsx
|
|
152
|
+
|
|
153
|
+
imports:
|
|
154
|
+
- platform: react
|
|
155
|
+
code: >-
|
|
156
|
+
import { Slider } from "@designil/labdsnov"
|
|
157
|
+
package: "@designil/labdsnov"
|
|
158
|
+
|
|
159
|
+
traits:
|
|
160
|
+
- traitType: variant
|
|
161
|
+
kind: enum
|
|
162
|
+
id: orientation
|
|
163
|
+
description: >-
|
|
164
|
+
Direction of the track.
|
|
165
|
+
values:
|
|
166
|
+
- id: horizontal
|
|
167
|
+
description: >-
|
|
168
|
+
Horizontal, full width (default).
|
|
169
|
+
- id: vertical
|
|
170
|
+
description: >-
|
|
171
|
+
Vertical, at least 160px tall.
|
|
172
|
+
- traitType: variant
|
|
173
|
+
kind: boolean
|
|
174
|
+
id: range
|
|
175
|
+
description: >-
|
|
176
|
+
`value` is an array of two values, giving two thumbs.
|
|
177
|
+
- traitType: state
|
|
178
|
+
kind: boolean
|
|
179
|
+
id: disabled
|
|
180
|
+
description: >-
|
|
181
|
+
Disabled, 50% opacity.
|
|
182
|
+
|
|
183
|
+
alternatives:
|
|
184
|
+
- to: input-group
|
|
185
|
+
- to: radio-group
|
|
186
|
+
- to: progress
|
|
187
|
+
|
|
188
|
+
refs:
|
|
189
|
+
- href: ./Slider.md
|
|
190
|
+
rel: relates-to
|
|
191
|
+
role: Thai usage doc
|
|
192
|
+
- href: ./Slider.stories.tsx
|
|
193
|
+
rel: demo
|
|
194
|
+
role: CSF stories
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Slider (แถบเลื่อนเลือกค่า)
|
|
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, Slider } from "@designil/labdsnov"
|
|
17
|
+
|
|
18
|
+
<Label id="rate-label">อัตราเงินสมทบเพิ่มเติม {rate}%</Label>
|
|
19
|
+
<Slider
|
|
20
|
+
value={rate}
|
|
21
|
+
onValueChange={(v) => setRate(v as number)}
|
|
22
|
+
min={0}
|
|
23
|
+
max={15}
|
|
24
|
+
step={0.5}
|
|
25
|
+
getAriaLabel={() => "อัตราเงินสมทบเพิ่มเติม"}
|
|
26
|
+
getAriaValueText={(formatted) => `${formatted}% ของเงินเดือน`}
|
|
27
|
+
/>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
- **ตั้งชื่อเสมอ** ด้วย `getAriaLabel` และใส่ `getAriaValueText` ให้มีหน่วย (%, บาท, ปี)
|
|
31
|
+
- **แสดงค่าที่เลือกเป็นตัวเลข** ข้าง ๆ เสมอ ตำแหน่งปุ่มอย่างเดียวอ่านค่าแม่นไม่ได้
|
|
32
|
+
- ตัวเลขจัดรูปแบบภาษาไทย (`locale="th-TH"`) เปลี่ยนได้ด้วย `locale` และ `format`
|
|
33
|
+
|
|
34
|
+
## When to use
|
|
35
|
+
|
|
36
|
+
- ค่าที่ไม่ต้องแม่นยำมากและอยากเห็นผลทันที เช่น อัตราเงินสมทบ 0–15% ในเครื่องคำนวณ
|
|
37
|
+
- ช่วงค่า เช่น อายุ 30–60 ปี (`value` สองค่า)
|
|
38
|
+
|
|
39
|
+
## When not to use
|
|
40
|
+
|
|
41
|
+
| สถานการณ์ | ใช้แทน |
|
|
42
|
+
| ---------------------- | -------------------------------------- |
|
|
43
|
+
| จำนวนเงินที่ต้องพิมพ์แม่นยำ | `Input type="number"` หรือ `InputGroup` |
|
|
44
|
+
| ตัวเลือกไม่กี่ค่าที่มีชื่อ | `RadioGroup` หรือ `ToggleGroup` |
|
|
45
|
+
| แสดงความคืบหน้า (กดไม่ได้) | `Progress` |
|
|
46
|
+
|
|
47
|
+
TODO: ยังไม่ได้ตัดสินใจว่าเครื่องคำนวณควรมีช่องพิมพ์ค่าคู่กับ Slider หรือไม่
|
|
48
|
+
|
|
49
|
+
## Props and variants
|
|
50
|
+
|
|
51
|
+
| Prop | ค่า | ค่าเริ่มต้น | ความหมาย |
|
|
52
|
+
| ------------------------- | -------------------------------------- | ------------ | ----------------------------------------- |
|
|
53
|
+
| `value` / `onValueChange` | ตัวเลข หรือ array สองค่า / ฟังก์ชัน | – | ควบคุมค่าจากภายนอก |
|
|
54
|
+
| `defaultValue` | ตัวเลข หรือ array สองค่า | `min` | ค่าเริ่มต้น array = มีสองปุ่ม (ช่วง) |
|
|
55
|
+
| `min` / `max` | ตัวเลข | `0` / `100` | ขอบเขต |
|
|
56
|
+
| `step` / `largeStep` | ตัวเลข | `1` / `10` | ระยะต่อการกดลูกศร / Page Up-Down |
|
|
57
|
+
| `orientation` | `horizontal`, `vertical` | `horizontal` | แนวนอนเต็มความกว้าง หรือแนวตั้งสูงอย่างน้อย 160px |
|
|
58
|
+
| `getAriaLabel` | `(index) => ข้อความ` | – | ชื่อของแต่ละปุ่ม |
|
|
59
|
+
| `getAriaValueText` | `(formatted, value, index) => ข้อความ` | – | ข้อความที่อ่านออกเสียงสำหรับค่า |
|
|
60
|
+
| `format` / `locale` | ตัวเลือกของ `Intl.NumberFormat` / locale | – / `th-TH` | รูปแบบตัวเลข |
|
|
61
|
+
| `disabled` | `boolean` | `false` | ปิดใช้งาน จางลง 50% |
|
|
62
|
+
|
|
63
|
+
หน้าตา: รางสูง 8px มีขอบ (contrast 3:1) ช่วงที่เลือกสีหลัก ปุ่มเลื่อน 24×16px พื้นขาวขอบสีหลัก
|
|
64
|
+
|
|
65
|
+
- **คีย์บอร์ด**: ลูกศรเลื่อนทีละ `step`, Page Up/Down ทีละ `largeStep`, Home/End ไปสุดขอบ
|
|
66
|
+
- **Focus**: วงแหวนทึบสี `--focus-ring` รอบปุ่มเลื่อน เว้นระยะ 2px
|
|
67
|
+
|
|
68
|
+
## Tokens used
|
|
69
|
+
|
|
70
|
+
ค่าทั้งหมดมาจาก `src/styles/theme.css`
|
|
71
|
+
|
|
72
|
+
### Component tokens
|
|
73
|
+
|
|
74
|
+
token เฉพาะของคอมโพเนนต์นี้ ชี้ไปที่ semantic token ด้านล่าง เปลี่ยนที่นี่เพื่อปรับเฉพาะคอมโพเนนต์นี้ (โหมดมืด "–" = ใช้ค่าเดียวกับโหมดสว่าง)
|
|
75
|
+
|
|
76
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
77
|
+
| ----------------------- | ------------------ | ------ | --------------------------------------------- |
|
|
78
|
+
| `--slider-track-border` | `--control-border` | – | ขอบราง (contrast 3:1) |
|
|
79
|
+
| `--slider-track` | `--muted` | – | ราง |
|
|
80
|
+
| `--slider-range` | `--primary` | – | ช่วงที่เลือก |
|
|
81
|
+
| `--slider-thumb-border` | `--primary` | – | ขอบปุ่มเลื่อน |
|
|
82
|
+
| `--slider-thumb-bg` | `--background` | – | พื้นปุ่มเลื่อน |
|
|
83
|
+
| `--focus-ring` | `--ring` | – | วงแหวน focus จากคีย์บอร์ดของทุกคอมโพเนนต์ (ทึบ 2px) |
|
|
84
|
+
|
|
85
|
+
### Semantic tokens
|
|
86
|
+
|
|
87
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
88
|
+
| ------------------ | --------------------------- | --------------------------- | --------------------------- |
|
|
89
|
+
| `--ring` | `oklch(0.45 0.03 106.9)` | `oklch(0.8 0.02 106.9)` | วงแหวน focus |
|
|
90
|
+
| `--background` | `oklch(1 0 0)` | `oklch(0.153 0.006 107.1)` | ระยะเว้นรอบวงแหวน focus |
|
|
91
|
+
| `--control-border` | `oklch(0.6 0.02 106.9)` | `oklch(0.55 0.015 106.9)` | ผ่าน token ของคอมโพเนนต์ด้านบน |
|
|
92
|
+
| `--muted` | `oklch(0.966 0.005 106.5)` | `oklch(0.286 0.016 107.4)` | ผ่าน token ของคอมโพเนนต์ด้านบน |
|
|
93
|
+
| `--primary` | `oklch(0.553 0.195 38.402)` | `oklch(0.705 0.187 47.604)` | ผ่าน token ของคอมโพเนนต์ด้านบน |
|
|
94
|
+
|
|
95
|
+
## Example
|
|
96
|
+
|
|
97
|
+
จาก story `Range` ใน `Slider.stories.tsx`:
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
<Slider
|
|
101
|
+
defaultValue={[30, 60]}
|
|
102
|
+
min={18}
|
|
103
|
+
max={75}
|
|
104
|
+
getAriaLabel={(index) => (index === 0 ? "อายุต่ำสุด" : "อายุสูงสุด")}
|
|
105
|
+
getAriaValueText={(formatted) => `${formatted} ปี`}
|
|
106
|
+
/>
|
|
107
|
+
```
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: spinner
|
|
3
|
+
name: Spinner
|
|
4
|
+
description: >-
|
|
5
|
+
A spinning icon saying the result of an action is pending. 16px by default, takes
|
|
6
|
+
the surrounding text colour, has `role="status"` and the name "กำลังโหลด" (loading).
|
|
7
|
+
metadata:
|
|
8
|
+
status: {status: stable}
|
|
9
|
+
since: 1.0.0
|
|
10
|
+
tags: [feedback]
|
|
11
|
+
|
|
12
|
+
sections:
|
|
13
|
+
- kind: guidelines
|
|
14
|
+
for: all
|
|
15
|
+
framing: when-to-use
|
|
16
|
+
items:
|
|
17
|
+
- level: should
|
|
18
|
+
statement: >-
|
|
19
|
+
Use in a button whose result must be waited for, e.g. save, submit a request.
|
|
20
|
+
example:
|
|
21
|
+
ref:
|
|
22
|
+
href: ./Spinner.stories.tsx#InButton
|
|
23
|
+
rel: demo
|
|
24
|
+
- level: may
|
|
25
|
+
statement: >-
|
|
26
|
+
Use in small areas that are loading, e.g. inside a status badge.
|
|
27
|
+
- level: should-not
|
|
28
|
+
statement: >-
|
|
29
|
+
Don't use for content of known shape that is loading (cards, tables). Use
|
|
30
|
+
<dsds:skeleton>.
|
|
31
|
+
alternatives:
|
|
32
|
+
- to: skeleton
|
|
33
|
+
- level: should-not
|
|
34
|
+
statement: >-
|
|
35
|
+
Don't use for work with known progress (upload). Use <dsds:progress>.
|
|
36
|
+
alternatives:
|
|
37
|
+
- to: progress
|
|
38
|
+
- level: must-not
|
|
39
|
+
statement: >-
|
|
40
|
+
Never put a lone Spinner in the middle of the page with no text. Add text saying
|
|
41
|
+
what is happening.
|
|
42
|
+
checkedBy: manual
|
|
43
|
+
|
|
44
|
+
- kind: guidelines
|
|
45
|
+
for: all
|
|
46
|
+
items:
|
|
47
|
+
- id: button-pattern
|
|
48
|
+
level: must
|
|
49
|
+
statement: >-
|
|
50
|
+
A pending button: set `disabled` on the <dsds:button>, put
|
|
51
|
+
`<Spinner data-icon="inline-start" />` before the text, and change the text to
|
|
52
|
+
"กำลัง…" (…ing), e.g. "กำลังบันทึก…" (saving…). Button has no `loading` prop yet,
|
|
53
|
+
so assemble it yourself.
|
|
54
|
+
uses:
|
|
55
|
+
- to: button
|
|
56
|
+
checks:
|
|
57
|
+
- href: ./Spinner.stories.tsx#InButton
|
|
58
|
+
role: test
|
|
59
|
+
checkedBy: assisted
|
|
60
|
+
- id: inherit-colour
|
|
61
|
+
level: should
|
|
62
|
+
statement: >-
|
|
63
|
+
Don't set the Spinner's colour; it follows the surrounding text. Change the size
|
|
64
|
+
with `className` (`size-6`).
|
|
65
|
+
checkedBy: manual
|
|
66
|
+
- id: keep-width
|
|
67
|
+
level: should
|
|
68
|
+
statement: >-
|
|
69
|
+
A button switching to its pending state shouldn't change width much. Use
|
|
70
|
+
"กำลัง…" text of similar length or set a minimum width.
|
|
71
|
+
checkedBy: manual
|
|
72
|
+
|
|
73
|
+
- kind: guidelines
|
|
74
|
+
for: all
|
|
75
|
+
title: Accessibility
|
|
76
|
+
tags: [accessibility]
|
|
77
|
+
items:
|
|
78
|
+
- id: status-name
|
|
79
|
+
level: must
|
|
80
|
+
statement: >-
|
|
81
|
+
Spinner has `role="status"` and the name "กำลังโหลด". Override it with a Thai
|
|
82
|
+
`aria-label` saying what is happening ("กำลังบันทึก" (saving)).
|
|
83
|
+
evidence:
|
|
84
|
+
- href: https://www.w3.org/WAI/WCAG22/Understanding/status-messages.html
|
|
85
|
+
role: WCAG 2.2 SC 4.1.3 (AA)
|
|
86
|
+
checks:
|
|
87
|
+
- href: ./Spinner.stories.tsx#Playground
|
|
88
|
+
role: test
|
|
89
|
+
note: play function finds role status named "กำลังโหลด"
|
|
90
|
+
checkedBy: automated
|
|
91
|
+
- id: no-double-announce
|
|
92
|
+
level: should
|
|
93
|
+
statement: >-
|
|
94
|
+
In a button whose text already changed to "กำลังบันทึก…", don't also set an
|
|
95
|
+
`aria-label` with the same meaning.
|
|
96
|
+
checkedBy: manual
|
|
97
|
+
|
|
98
|
+
- kind: section
|
|
99
|
+
for: all
|
|
100
|
+
title: Open decisions
|
|
101
|
+
freeform:
|
|
102
|
+
- title: TODO
|
|
103
|
+
body: >-
|
|
104
|
+
Button has no `loading` prop that adds a Spinner and disables it automatically.
|
|
105
|
+
|
|
106
|
+
sourceFiles:
|
|
107
|
+
- platform: react
|
|
108
|
+
file: ./Spinner.tsx
|
|
109
|
+
|
|
110
|
+
imports:
|
|
111
|
+
- platform: react
|
|
112
|
+
code: >-
|
|
113
|
+
import { Spinner } from "@designil/labdsnov"
|
|
114
|
+
package: "@designil/labdsnov"
|
|
115
|
+
|
|
116
|
+
alternatives:
|
|
117
|
+
- to: skeleton
|
|
118
|
+
- to: progress
|
|
119
|
+
|
|
120
|
+
refs:
|
|
121
|
+
- href: ./Spinner.md
|
|
122
|
+
rel: relates-to
|
|
123
|
+
role: Thai usage doc
|
|
124
|
+
- href: ./Spinner.stories.tsx
|
|
125
|
+
rel: demo
|
|
126
|
+
role: CSF stories
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Spinner (ไอคอนกำลังโหลด)
|
|
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 { Button, Spinner } from "@designil/labdsnov"
|
|
17
|
+
|
|
18
|
+
;<Button disabled>
|
|
19
|
+
<Spinner data-icon="inline-start" />
|
|
20
|
+
กำลังบันทึก…
|
|
21
|
+
</Button>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
- โปรแกรมอ่านหน้าจออ่านว่า "กำลังโหลด" เปลี่ยนได้ด้วย `aria-label`
|
|
25
|
+
- สีและขนาดตามข้อความรอบ ๆ ปรับขนาดด้วย `className` เช่น `size-6`
|
|
26
|
+
|
|
27
|
+
## When to use
|
|
28
|
+
|
|
29
|
+
- ปุ่มที่กดแล้วต้องรอผล เช่น บันทึก ส่งคำขอ: ปิดปุ่ม (`disabled`) ใส่ Spinner และเปลี่ยนข้อความเป็น "กำลัง…"
|
|
30
|
+
- พื้นที่เล็ก ๆ ที่กำลังโหลด เช่น ในป้ายสถานะ
|
|
31
|
+
|
|
32
|
+
## When not to use
|
|
33
|
+
|
|
34
|
+
| สถานการณ์ | ใช้แทน |
|
|
35
|
+
| --------------------------------- | ----------------------- |
|
|
36
|
+
| เนื้อหาที่รู้รูปร่างกำลังโหลด (การ์ด ตาราง) | `Skeleton` |
|
|
37
|
+
| งานที่รู้ความคืบหน้า (อัปโหลด) | `Progress` |
|
|
38
|
+
| Spinner อย่างเดียวกลางหน้า ไม่มีข้อความ | ใส่ข้อความบอกว่ากำลังทำอะไร |
|
|
39
|
+
|
|
40
|
+
## Props and variants
|
|
41
|
+
|
|
42
|
+
ไม่มี variant หรือ size ขนาดเริ่มต้น 16px หมุนตลอด
|
|
43
|
+
|
|
44
|
+
| Prop | ค่า | ความหมาย |
|
|
45
|
+
| ------------ | ------ | ---------------------------------- |
|
|
46
|
+
| `aria-label` | ข้อความ | ค่าเริ่มต้น "กำลังโหลด" |
|
|
47
|
+
| `className` | class | ขนาดหรือสี เช่น `size-6 text-primary` |
|
|
48
|
+
|
|
49
|
+
TODO: ปุ่มยังไม่มี prop `loading` ที่ใส่ Spinner และปิดปุ่มให้อัตโนมัติ ต้องประกอบเองตามตัวอย่าง
|
|
50
|
+
|
|
51
|
+
## Tokens used
|
|
52
|
+
|
|
53
|
+
ไม่ใช้ token โดยตรง สีตามข้อความ (`currentColor`)
|
|
54
|
+
|
|
55
|
+
## Example
|
|
56
|
+
|
|
57
|
+
จาก story `InButton` ใน `Spinner.stories.tsx` (บางส่วน):
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
<Button disabled>
|
|
61
|
+
<Spinner data-icon="inline-start" />
|
|
62
|
+
กำลังบันทึก…
|
|
63
|
+
</Button>
|
|
64
|
+
```
|