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