@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,172 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: avatar
|
|
3
|
+
name: Avatar
|
|
4
|
+
description: >-
|
|
5
|
+
A round profile picture that shows initials instead when there's no image or it
|
|
6
|
+
fails to load. Wraps Base UI's `Avatar`.
|
|
7
|
+
metadata:
|
|
8
|
+
status: {status: stable}
|
|
9
|
+
since: 1.0.0
|
|
10
|
+
tags: [display]
|
|
11
|
+
|
|
12
|
+
sections:
|
|
13
|
+
- kind: guidelines
|
|
14
|
+
for: all
|
|
15
|
+
framing: when-to-use
|
|
16
|
+
items:
|
|
17
|
+
- level: should
|
|
18
|
+
statement: >-
|
|
19
|
+
Use to show who a member, beneficiary or staff member is, next to their name.
|
|
20
|
+
- level: must-not
|
|
21
|
+
statement: >-
|
|
22
|
+
Never use it for images that are content (fund images, documents); use a
|
|
23
|
+
plain `<img>`.
|
|
24
|
+
checkedBy: manual
|
|
25
|
+
- level: must-not
|
|
26
|
+
statement: >-
|
|
27
|
+
Never use an Avatar in place of a name: there must always be a name next to
|
|
28
|
+
it or an image `alt`.
|
|
29
|
+
checkedBy: manual
|
|
30
|
+
|
|
31
|
+
- kind: guidelines
|
|
32
|
+
for: all
|
|
33
|
+
items:
|
|
34
|
+
- id: always-fallback
|
|
35
|
+
level: must
|
|
36
|
+
statement: >-
|
|
37
|
+
Include `AvatarFallback` whenever there's an `AvatarImage`. The fallback shows
|
|
38
|
+
while loading and when the image is broken; without it the circle is empty.
|
|
39
|
+
checks:
|
|
40
|
+
- href: ./Avatar.stories.tsx#ImageFallback
|
|
41
|
+
role: test
|
|
42
|
+
note: The play function checks the initials "สจ" appear when the image fails
|
|
43
|
+
checkedBy: automated
|
|
44
|
+
- id: thai-initials
|
|
45
|
+
level: should
|
|
46
|
+
statement: >-
|
|
47
|
+
Thai initials use the first consonant of the first name and the surname, e.g.
|
|
48
|
+
"สมชาย ใจดี" → "สจ" (rules for leading vowels, tone marks and English names
|
|
49
|
+
aren't defined yet, see Open decisions).
|
|
50
|
+
checkedBy: manual
|
|
51
|
+
- id: size-by-context
|
|
52
|
+
level: should
|
|
53
|
+
statement: >-
|
|
54
|
+
`sm` (24px) in tables and dense lists, `default` (32px) next to names in
|
|
55
|
+
general, `lg` (40px) in card headers or profile pages.
|
|
56
|
+
checkedBy: manual
|
|
57
|
+
- id: group-count
|
|
58
|
+
level: should
|
|
59
|
+
statement: >-
|
|
60
|
+
A group of more than 3 people shows 2–3 Avatars followed by
|
|
61
|
+
`AvatarGroupCount` ("+2"), which sizes itself to match the Avatars in the
|
|
62
|
+
group.
|
|
63
|
+
example:
|
|
64
|
+
ref:
|
|
65
|
+
href: ./Avatar.stories.tsx#Group
|
|
66
|
+
rel: demo
|
|
67
|
+
checkedBy: manual
|
|
68
|
+
- id: badge-not-alone
|
|
69
|
+
level: must-not
|
|
70
|
+
statement: >-
|
|
71
|
+
Never use `AvatarBadge` (the primary-coloured dot in the bottom right) as the
|
|
72
|
+
only status indicator: there must be status text too, and the dot's meaning
|
|
73
|
+
isn't defined yet.
|
|
74
|
+
evidence:
|
|
75
|
+
- href: https://www.w3.org/WAI/WCAG22/Understanding/use-of-color.html
|
|
76
|
+
role: WCAG 2.2 SC 1.4.1 (A)
|
|
77
|
+
checkedBy: manual
|
|
78
|
+
|
|
79
|
+
- kind: guidelines
|
|
80
|
+
for: all
|
|
81
|
+
title: Accessibility
|
|
82
|
+
tags: [accessibility]
|
|
83
|
+
items:
|
|
84
|
+
- id: image-alt
|
|
85
|
+
level: must
|
|
86
|
+
statement: >-
|
|
87
|
+
`AvatarImage` has an `alt` with the person's full name. If the name is
|
|
88
|
+
already written next to it, use `alt=""` so the name isn't read twice.
|
|
89
|
+
evidence:
|
|
90
|
+
- href: https://www.w3.org/WAI/WCAG22/Understanding/non-text-content.html
|
|
91
|
+
role: WCAG 2.2 SC 1.1.1 (A)
|
|
92
|
+
checkedBy: manual
|
|
93
|
+
- id: group-label
|
|
94
|
+
level: must
|
|
95
|
+
statement: >-
|
|
96
|
+
`AvatarGroup` has an `aria-label` giving the total, e.g.
|
|
97
|
+
"ผู้รับผลประโยชน์ 4 คน" (4 beneficiaries), because "+2" alone doesn't say
|
|
98
|
+
what it counts.
|
|
99
|
+
checkedBy: manual
|
|
100
|
+
|
|
101
|
+
- kind: definitions
|
|
102
|
+
for: all
|
|
103
|
+
context: anatomy
|
|
104
|
+
items:
|
|
105
|
+
- term: Avatar
|
|
106
|
+
definition: >-
|
|
107
|
+
The circle. Takes `size`.
|
|
108
|
+
- term: AvatarImage
|
|
109
|
+
definition: >-
|
|
110
|
+
The image (`src`, `alt`), cropped to a circle.
|
|
111
|
+
- term: AvatarFallback
|
|
112
|
+
definition: >-
|
|
113
|
+
Initials on a grey background.
|
|
114
|
+
- term: AvatarBadge
|
|
115
|
+
definition: >-
|
|
116
|
+
A primary-coloured dot in the bottom right, with a ring in the page
|
|
117
|
+
background colour around it.
|
|
118
|
+
- term: AvatarGroup
|
|
119
|
+
definition: >-
|
|
120
|
+
Overlapping Avatars, each separated by a ring in the page background colour.
|
|
121
|
+
- term: AvatarGroupCount
|
|
122
|
+
definition: >-
|
|
123
|
+
A "+N" circle at the end of the group.
|
|
124
|
+
|
|
125
|
+
- kind: section
|
|
126
|
+
for: all
|
|
127
|
+
title: Open decisions
|
|
128
|
+
freeform:
|
|
129
|
+
- title: TODO
|
|
130
|
+
body: >-
|
|
131
|
+
Initials rules (leading vowels, tone marks, English names) and the meaning of
|
|
132
|
+
the `AvatarBadge` dot aren't defined yet.
|
|
133
|
+
|
|
134
|
+
sourceFiles:
|
|
135
|
+
- platform: react
|
|
136
|
+
file: ./Avatar.tsx
|
|
137
|
+
|
|
138
|
+
imports:
|
|
139
|
+
- platform: react
|
|
140
|
+
code: >-
|
|
141
|
+
import { Avatar, AvatarFallback, AvatarImage } from "@designil/labdsnov"
|
|
142
|
+
package: "@designil/labdsnov"
|
|
143
|
+
|
|
144
|
+
traits:
|
|
145
|
+
- traitType: variant
|
|
146
|
+
kind: enum
|
|
147
|
+
id: size
|
|
148
|
+
description: >-
|
|
149
|
+
Diameter.
|
|
150
|
+
values:
|
|
151
|
+
- id: sm
|
|
152
|
+
description: >-
|
|
153
|
+
24px
|
|
154
|
+
- id: default
|
|
155
|
+
description: >-
|
|
156
|
+
32px
|
|
157
|
+
- id: lg
|
|
158
|
+
description: >-
|
|
159
|
+
40px
|
|
160
|
+
- traitType: state
|
|
161
|
+
kind: boolean
|
|
162
|
+
id: fallback
|
|
163
|
+
description: >-
|
|
164
|
+
The image is loading or broken, so initials show instead.
|
|
165
|
+
|
|
166
|
+
refs:
|
|
167
|
+
- href: ./Avatar.md
|
|
168
|
+
rel: relates-to
|
|
169
|
+
role: Usage doc in Thai
|
|
170
|
+
- href: ./Avatar.stories.tsx
|
|
171
|
+
rel: demo
|
|
172
|
+
role: CSF stories
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Avatar (รูปโปรไฟล์)
|
|
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 { Avatar, AvatarFallback, AvatarImage } from "@designil/labdsnov"
|
|
17
|
+
|
|
18
|
+
;<Avatar>
|
|
19
|
+
<AvatarImage src={member.photoUrl} alt="สมชาย ใจดี" />
|
|
20
|
+
<AvatarFallback>สจ</AvatarFallback>
|
|
21
|
+
</Avatar>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
- ใส่ `AvatarFallback` เสมอ แสดงระหว่างโหลดรูปและเมื่อรูปเสีย
|
|
25
|
+
- อักษรย่อภาษาไทย: ตัวแรกของชื่อและนามสกุล เช่น "สมชาย ใจดี" → "สจ" TODO: ยังไม่ได้กำหนดกฎอักษรย่อ (สระ วรรณยุกต์ ชื่ออังกฤษ)
|
|
26
|
+
|
|
27
|
+
## When to use
|
|
28
|
+
|
|
29
|
+
- แสดงตัวตนของสมาชิก ผู้รับผลประโยชน์ หรือเจ้าหน้าที่ ข้างชื่อ
|
|
30
|
+
|
|
31
|
+
## When not to use
|
|
32
|
+
|
|
33
|
+
- **รูปที่เป็นเนื้อหา** (ภาพกองทุน เอกสาร): ใช้รูปปกติ
|
|
34
|
+
- **แทนชื่อ**: Avatar ไม่บอกว่าเป็นใคร ต้องมีชื่อข้าง ๆ หรือ `alt` ของรูป
|
|
35
|
+
|
|
36
|
+
## Props and variants
|
|
37
|
+
|
|
38
|
+
| Prop | ค่า | ค่าเริ่มต้น | ความหมาย |
|
|
39
|
+
| ----------- | --------------------- | --------- | ---------------------- |
|
|
40
|
+
| `size` | `sm`, `default`, `lg` | `default` | 24px / 32px / 40px |
|
|
41
|
+
| `className` | class | – | ปรับหน้าตาเฉพาะจุดครั้งเดียว |
|
|
42
|
+
|
|
43
|
+
| ส่วน | ความหมาย |
|
|
44
|
+
| ------------------ | ------------------------------------------------------------------------------- |
|
|
45
|
+
| `AvatarImage` | รูป (`src`, `alt`) ตัดเป็นวงกลม |
|
|
46
|
+
| `AvatarFallback` | อักษรย่อบนพื้นเทา |
|
|
47
|
+
| `AvatarBadge` | จุดสีหลักมุมขวาล่าง บอกสถานะ TODO: ยังไม่ได้กำหนดความหมายของจุด และต้องมีข้อความบอกสถานะด้วย |
|
|
48
|
+
| `AvatarGroup` | เรียง Avatar ซ้อนกัน |
|
|
49
|
+
| `AvatarGroupCount` | วงกลม "+2" ท้ายกลุ่ม ขนาดตาม Avatar ในกลุ่ม |
|
|
50
|
+
|
|
51
|
+
## Tokens used
|
|
52
|
+
|
|
53
|
+
ค่าทั้งหมดมาจาก `src/styles/theme.css`
|
|
54
|
+
|
|
55
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
56
|
+
| -------------------- | --------------------------- | --------------------------- | ------------------------------ |
|
|
57
|
+
| `--muted` | `oklch(0.966 0.005 106.5)` | `oklch(0.286 0.016 107.4)` | พื้นอักษรย่อ, วงกลม "+2" |
|
|
58
|
+
| `--muted-foreground` | `oklch(0.5 0.027 107.3)` | `oklch(0.737 0.021 106.9)` | อักษรย่อ |
|
|
59
|
+
| `--border` | `oklch(0.93 0.007 106.5)` | `oklch(1 0 0 / 10%)` | เส้นขอบบาง ๆ รอบรูป |
|
|
60
|
+
| `--primary` | `oklch(0.553 0.195 38.402)` | `oklch(0.705 0.187 47.604)` | จุด `AvatarBadge` |
|
|
61
|
+
| `--background` | `oklch(1 0 0)` | `oklch(0.153 0.006 107.1)` | วงแหวนรอบ Avatar ในกลุ่มและรอบจุด |
|
|
62
|
+
|
|
63
|
+
## Example
|
|
64
|
+
|
|
65
|
+
จาก story `Group` ใน `Avatar.stories.tsx`:
|
|
66
|
+
|
|
67
|
+
```tsx
|
|
68
|
+
<AvatarGroup aria-label="ผู้รับผลประโยชน์ 4 คน">
|
|
69
|
+
<Avatar>
|
|
70
|
+
<AvatarFallback>สห</AvatarFallback>
|
|
71
|
+
</Avatar>
|
|
72
|
+
<Avatar>
|
|
73
|
+
<AvatarFallback>สศ</AvatarFallback>
|
|
74
|
+
</Avatar>
|
|
75
|
+
<AvatarGroupCount>+2</AvatarGroupCount>
|
|
76
|
+
</AvatarGroup>
|
|
77
|
+
```
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: badge
|
|
3
|
+
name: Badge
|
|
4
|
+
description: >-
|
|
5
|
+
A short text label giving the status or level of the thing next to it, such as
|
|
6
|
+
an item's status or a fund's risk level. 20px high, 12px text, pill-shaped, one
|
|
7
|
+
size only.
|
|
8
|
+
metadata:
|
|
9
|
+
status: {status: stable}
|
|
10
|
+
since: 1.0.0
|
|
11
|
+
tags: [display, status]
|
|
12
|
+
|
|
13
|
+
sections:
|
|
14
|
+
- kind: guidelines
|
|
15
|
+
for: all
|
|
16
|
+
framing: when-to-use
|
|
17
|
+
items:
|
|
18
|
+
- level: should
|
|
19
|
+
statement: >-
|
|
20
|
+
Use for an item's status, e.g. succeeded / pending / failed.
|
|
21
|
+
- level: should
|
|
22
|
+
statement: >-
|
|
23
|
+
Use for a fund's risk level.
|
|
24
|
+
- level: may
|
|
25
|
+
statement: >-
|
|
26
|
+
Make it a link with `render={<a href="…" />}` when the label has a
|
|
27
|
+
destination page, e.g. "แนะนำ" (recommended) linking to the fund page.
|
|
28
|
+
example:
|
|
29
|
+
ref:
|
|
30
|
+
href: ./Badge.stories.tsx#AsLink
|
|
31
|
+
rel: demo
|
|
32
|
+
- level: must-not
|
|
33
|
+
statement: >-
|
|
34
|
+
Never use it as a button for an action (save, send, cancel). A badge isn't a
|
|
35
|
+
button and has no hover style; use <dsds:button>.
|
|
36
|
+
alternatives:
|
|
37
|
+
- to: button
|
|
38
|
+
checkedBy: manual
|
|
39
|
+
- level: must-not
|
|
40
|
+
statement: >-
|
|
41
|
+
Never put long text or sentences in it. The badge has a fixed height and the
|
|
42
|
+
text doesn't wrap, so it overflows the badge.
|
|
43
|
+
checkedBy: manual
|
|
44
|
+
- level: should-not
|
|
45
|
+
statement: >-
|
|
46
|
+
Don't use it for a message users must act on; use <dsds:alert>.
|
|
47
|
+
alternatives:
|
|
48
|
+
- to: alert
|
|
49
|
+
|
|
50
|
+
- kind: guidelines
|
|
51
|
+
for: all
|
|
52
|
+
items:
|
|
53
|
+
- id: risk-mapping
|
|
54
|
+
level: must
|
|
55
|
+
statement: >-
|
|
56
|
+
Low risk = `success`, medium = `warning`, high = `destructive`. Use this set
|
|
57
|
+
everywhere a fund's risk is shown, with the full text ("ความเสี่ยงต่ำ" low
|
|
58
|
+
risk).
|
|
59
|
+
example:
|
|
60
|
+
ref:
|
|
61
|
+
href: ./Badge.stories.tsx#RiskLevels
|
|
62
|
+
rel: demo
|
|
63
|
+
checkedBy: manual
|
|
64
|
+
- id: status-mapping
|
|
65
|
+
level: must
|
|
66
|
+
statement: >-
|
|
67
|
+
Item status: succeeded = `success`, pending = `warning`, failed =
|
|
68
|
+
`destructive`. General labels (e.g. "แนะนำ" recommended) use `outline`.
|
|
69
|
+
checkedBy: manual
|
|
70
|
+
- id: short-label
|
|
71
|
+
level: should
|
|
72
|
+
statement: >-
|
|
73
|
+
1–2 words. Icons in a badge are 12px, placed before the text.
|
|
74
|
+
checkedBy: manual
|
|
75
|
+
- id: tinted-is-quieter
|
|
76
|
+
level: should
|
|
77
|
+
statement: >-
|
|
78
|
+
Status badges (`success` / `warning` / `destructive`) use a 10% tint (20% in
|
|
79
|
+
dark mode), so they're quieter than `default` with its solid fill. Don't use
|
|
80
|
+
`default` for status: it competes with primary buttons of the same colour.
|
|
81
|
+
checkedBy: manual
|
|
82
|
+
- id: no-classname-colour
|
|
83
|
+
level: should-not
|
|
84
|
+
statement: >-
|
|
85
|
+
Don't create new badge colours with `className` (e.g. a blue badge); ask for
|
|
86
|
+
a new variant that passes `tokens:check` instead.
|
|
87
|
+
refs:
|
|
88
|
+
- to: shared-composition#classname-one-off
|
|
89
|
+
rel: relates-to
|
|
90
|
+
|
|
91
|
+
- kind: guidelines
|
|
92
|
+
for: all
|
|
93
|
+
title: Accessibility
|
|
94
|
+
tags: [accessibility]
|
|
95
|
+
items:
|
|
96
|
+
- id: text-not-colour
|
|
97
|
+
level: must
|
|
98
|
+
statement: >-
|
|
99
|
+
The meaning must be in the badge's text ("ความเสี่ยงสูง" high risk), not a
|
|
100
|
+
bare red badge.
|
|
101
|
+
evidence:
|
|
102
|
+
- href: https://www.w3.org/WAI/WCAG22/Understanding/use-of-color.html
|
|
103
|
+
role: WCAG 2.2 SC 1.4.1 (A)
|
|
104
|
+
checkedBy: manual
|
|
105
|
+
- id: badge-contrast
|
|
106
|
+
level: must
|
|
107
|
+
statement: >-
|
|
108
|
+
Every variant passes 4.5:1. The pairs closest to the limit are `destructive`
|
|
109
|
+
in a Card in dark mode (4.91:1) and `default` in light mode (4.93:1). Placing
|
|
110
|
+
a badge on any background other than the page or a card needs an extra check.
|
|
111
|
+
checks:
|
|
112
|
+
- href: ../../../scripts/tokens.mjs
|
|
113
|
+
role: test
|
|
114
|
+
note: The "Badge …" pairs in CONTRAST_PAIRS
|
|
115
|
+
checkedBy: automated
|
|
116
|
+
- id: link-focus
|
|
117
|
+
level: must
|
|
118
|
+
statement: >-
|
|
119
|
+
A badge that's a link is focusable, shows the `--focus-ring` ring, and gets
|
|
120
|
+
an underline on hover. A badge that isn't a link isn't in the Tab order.
|
|
121
|
+
refs:
|
|
122
|
+
- to: shared-a11y#focus-ring
|
|
123
|
+
rel: relates-to
|
|
124
|
+
checks:
|
|
125
|
+
- href: ./Badge.stories.tsx#AsLink
|
|
126
|
+
role: test
|
|
127
|
+
note: The play function checks it renders as an <a> with an href
|
|
128
|
+
checkedBy: assisted
|
|
129
|
+
|
|
130
|
+
- kind: section
|
|
131
|
+
for: all
|
|
132
|
+
title: Open decisions
|
|
133
|
+
freeform:
|
|
134
|
+
- title: TODO
|
|
135
|
+
body: >-
|
|
136
|
+
No defined use yet for `default` and `secondary`, whether badges may show
|
|
137
|
+
counts (e.g. number of notifications), or when a badge should have
|
|
138
|
+
`aria-invalid`.
|
|
139
|
+
|
|
140
|
+
sourceFiles:
|
|
141
|
+
- platform: react
|
|
142
|
+
file: ./Badge.tsx
|
|
143
|
+
|
|
144
|
+
imports:
|
|
145
|
+
- platform: react
|
|
146
|
+
code: >-
|
|
147
|
+
import { Badge } from "@designil/labdsnov"
|
|
148
|
+
package: "@designil/labdsnov"
|
|
149
|
+
|
|
150
|
+
traits:
|
|
151
|
+
- traitType: variant
|
|
152
|
+
kind: enum
|
|
153
|
+
id: variant
|
|
154
|
+
description: >-
|
|
155
|
+
What the label means.
|
|
156
|
+
values:
|
|
157
|
+
- id: default
|
|
158
|
+
description: >-
|
|
159
|
+
Solid primary (orange) fill, light text. No defined use yet.
|
|
160
|
+
- id: secondary
|
|
161
|
+
description: >-
|
|
162
|
+
Light grey fill, dark text. No defined use yet.
|
|
163
|
+
- id: outline
|
|
164
|
+
description: >-
|
|
165
|
+
General labels such as "แนะนำ" (recommended). Transparent with a border.
|
|
166
|
+
- id: destructive
|
|
167
|
+
description: >-
|
|
168
|
+
Failed, high risk. Faint red fill, red text.
|
|
169
|
+
- id: success
|
|
170
|
+
description: >-
|
|
171
|
+
Succeeded, low risk. Faint green fill, green text.
|
|
172
|
+
- id: warning
|
|
173
|
+
description: >-
|
|
174
|
+
Pending, medium risk. Faint amber fill, amber text.
|
|
175
|
+
- traitType: variant
|
|
176
|
+
kind: boolean
|
|
177
|
+
id: link
|
|
178
|
+
description: >-
|
|
179
|
+
The badge is a link (`render={<a />}`): underlined on hover and focusable.
|
|
180
|
+
|
|
181
|
+
alternatives:
|
|
182
|
+
- to: button
|
|
183
|
+
- to: alert
|
|
184
|
+
|
|
185
|
+
refs:
|
|
186
|
+
- href: ./Badge.md
|
|
187
|
+
rel: relates-to
|
|
188
|
+
role: Usage doc in Thai
|
|
189
|
+
- href: ./Badge.stories.tsx
|
|
190
|
+
rel: demo
|
|
191
|
+
role: CSF stories
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# Badge (ป้ายสถานะ)
|
|
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 { Badge } from "@designil/labdsnov"
|
|
17
|
+
|
|
18
|
+
<Badge variant="success">สำเร็จ</Badge>
|
|
19
|
+
|
|
20
|
+
// เป็นลิงก์
|
|
21
|
+
<Badge variant="outline" render={<a href="/funds" />}>แนะนำ</Badge>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
ถ้าใช้ไอคอน ให้ติดตั้ง `@hugeicons/react` และ `@hugeicons/core-free-icons` ในแอปด้วย
|
|
25
|
+
|
|
26
|
+
## When to use
|
|
27
|
+
|
|
28
|
+
- บอกสถานะของรายการ เช่น สำเร็จ / รอดำเนินการ / ไม่สำเร็จ
|
|
29
|
+
- บอกระดับความเสี่ยง: ต่ำ = `success`, ปานกลาง = `warning`, สูง = `destructive`
|
|
30
|
+
- ติดป้ายสั้น ๆ ให้รายการ เช่น "แนะนำ" และทำให้กดได้ (เป็นลิงก์) เมื่อมีหน้าปลายทาง
|
|
31
|
+
- ข้อความยาว 1–2 คำ ป้ายมีความสูงคงที่และข้อความไม่ขึ้นบรรทัดใหม่
|
|
32
|
+
|
|
33
|
+
## When not to use
|
|
34
|
+
|
|
35
|
+
- **สำหรับการกระทำ** เช่น บันทึก ส่ง ยกเลิก: ใช้ `Button` แทน Badge ไม่ใช่ปุ่ม และไม่มีสไตล์ hover เว้นแต่จะเป็นลิงก์
|
|
36
|
+
- **ข้อความยาวหรือประโยค**: ข้อความจะไม่ตัดบรรทัดและล้นออกนอกป้าย ใช้ข้อความปกติแทน
|
|
37
|
+
- **ใช้สีอย่างเดียวสื่อความหมาย**: ต้องมีข้อความบอกสถานะเสมอ (เช่น "ความเสี่ยงสูง" ไม่ใช่ป้ายสีแดงเปล่า ๆ)
|
|
38
|
+
- TODO: ยังไม่ได้กำหนดว่าใช้ Badge แสดงตัวเลขนับ (เช่น จำนวนแจ้งเตือน) ได้หรือไม่
|
|
39
|
+
|
|
40
|
+
## Props and variants
|
|
41
|
+
|
|
42
|
+
| Prop | ค่า | ค่าเริ่มต้น | ความหมาย |
|
|
43
|
+
| ----------- | ---------------------------- | --------- | ------------------------------------------------------------------------ |
|
|
44
|
+
| `variant` | ดูตารางด้านล่าง | `default` | ความหมายของป้าย |
|
|
45
|
+
| `children` | ข้อความ (และไอคอนได้) | – | ข้อความบนป้าย เป็นภาษาไทย |
|
|
46
|
+
| `render` | element เช่น `<a href="…" />` | – | ทำให้ป้ายเป็นลิงก์ เมื่อเป็นลิงก์จะขีดเส้นใต้ตอน hover |
|
|
47
|
+
| `className` | class | – | ปรับหน้าตาเฉพาะจุดครั้งเดียว ชนะสไตล์ของป้ายเสมอ ถ้าใช้ซ้ำหลายที่ ให้ขอ variant ใหม่แทน |
|
|
48
|
+
|
|
49
|
+
Badge มีขนาดเดียว (ไม่มี prop `size`): สูง 20px ตัวอักษร 12px น้ำหนัก medium ทรงแคปซูล ไอคอนในป้ายมีขนาด 12px
|
|
50
|
+
|
|
51
|
+
### Variants
|
|
52
|
+
|
|
53
|
+
| Variant | ใช้เมื่อ | หน้าตา |
|
|
54
|
+
| ------------- | ----------------------------------- | ------------------------------ |
|
|
55
|
+
| `default` | TODO: ยังไม่ได้กำหนดการใช้งาน | พื้นสีหลัก (ส้ม) ตัวอักษรสีอ่อน |
|
|
56
|
+
| `secondary` | TODO: ยังไม่ได้กำหนดการใช้งาน | พื้นเทาอ่อน ตัวอักษรเข้ม |
|
|
57
|
+
| `outline` | ป้ายกำกับทั่วไป เช่น "แนะนำ" (จาก story) | พื้นโปร่งใส มีเส้นขอบ |
|
|
58
|
+
| `success` | สำเร็จ, ความเสี่ยงต่ำ | พื้นเขียวจาง ตัวอักษรเขียว |
|
|
59
|
+
| `warning` | รอดำเนินการ, ความเสี่ยงปานกลาง | พื้นเหลืองอมส้มจาง ตัวอักษรเหลืองอมส้ม |
|
|
60
|
+
| `destructive` | ไม่สำเร็จ, ความเสี่ยงสูง | พื้นแดงจาง ตัวอักษรแดง |
|
|
61
|
+
|
|
62
|
+
`success` / `warning` / `destructive` ใช้พื้นสีจาง (10% ในโหมดสว่าง, 20% ในโหมดมืด) ส่วน `default` ใช้พื้นทึบ จึงเด่นกว่า
|
|
63
|
+
|
|
64
|
+
### States
|
|
65
|
+
|
|
66
|
+
- **Hover** (เฉพาะเมื่อเป็นลิงก์): ขีดเส้นใต้ สีไม่เปลี่ยน
|
|
67
|
+
- **Focus จากคีย์บอร์ด**: เส้นขอบและวงแหวนทึบสี `--focus-ring` ทุก variant
|
|
68
|
+
- **ข้อมูลไม่ถูกต้อง** (`aria-invalid`): เส้นขอบและวงแหวนสีแดง TODO: ยังไม่ชัดว่ากรณีไหนที่ป้ายควรอยู่ในสถานะนี้
|
|
69
|
+
|
|
70
|
+
## Tokens used
|
|
71
|
+
|
|
72
|
+
ค่าทั้งหมดมาจาก `src/styles/theme.css` เปลี่ยนสีของป้ายที่ token ไม่ใช่ที่ตัวคอมโพเนนต์
|
|
73
|
+
|
|
74
|
+
### Component tokens
|
|
75
|
+
|
|
76
|
+
token เฉพาะของคอมโพเนนต์นี้ ชี้ไปที่ semantic token ด้านล่าง เปลี่ยนที่นี่เพื่อปรับเฉพาะคอมโพเนนต์นี้ (โหมดมืด "–" = ใช้ค่าเดียวกับโหมดสว่าง)
|
|
77
|
+
|
|
78
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
79
|
+
| ------------------------ | ------------------------ | ------------------- | ----------------------------------------------- |
|
|
80
|
+
| `--badge-default-bg` | `--primary` | – | พื้น `default` |
|
|
81
|
+
| `--badge-default-fg` | `--primary-foreground` | – | ตัวอักษร `default` |
|
|
82
|
+
| `--badge-secondary-bg` | `--secondary` | – | พื้น `secondary` |
|
|
83
|
+
| `--badge-secondary-fg` | `--secondary-foreground` | – | ตัวอักษร `secondary` |
|
|
84
|
+
| `--badge-outline-border` | `--border` | – | เส้นขอบ `outline` |
|
|
85
|
+
| `--badge-outline-fg` | `--foreground` | – | ตัวอักษร `outline` |
|
|
86
|
+
| `--badge-destructive-bg` | `--destructive` 10% | `--destructive` 20% | พื้น `destructive` |
|
|
87
|
+
| `--badge-destructive-fg` | `--destructive` | – | ตัวอักษร `destructive` |
|
|
88
|
+
| `--badge-success-bg` | `--success` 10% | `--success` 20% | พื้น `success` |
|
|
89
|
+
| `--badge-success-fg` | `--success` | – | ตัวอักษร `success` |
|
|
90
|
+
| `--badge-warning-bg` | `--warning` 10% | `--warning` 20% | พื้น `warning` |
|
|
91
|
+
| `--badge-warning-fg` | `--warning` | – | ตัวอักษร `warning` |
|
|
92
|
+
| `--focus-ring` | `--ring` | – | วงแหวน focus จากคีย์บอร์ดของทุกคอมโพเนนต์ (ทึบ 2px) |
|
|
93
|
+
| `--invalid-border` | `--destructive` | – | เส้นขอบเมื่อข้อมูลไม่ถูกต้อง และวงแหวน focus ขณะไม่ถูกต้อง |
|
|
94
|
+
| `--invalid-ring` | `--destructive` 20% | `--destructive` 40% | วงแหวนจางรอบช่องที่ไม่ถูกต้อง (ตกแต่ง) |
|
|
95
|
+
|
|
96
|
+
### Semantic tokens
|
|
97
|
+
|
|
98
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
99
|
+
| ------------------------ | ---------------------------- | ---------------------------- | ------------------------------------------- |
|
|
100
|
+
| `--primary` | `oklch(0.553 0.195 38.402)` | `oklch(0.705 0.187 47.604)` | พื้น `default` |
|
|
101
|
+
| `--primary-foreground` | `oklch(0.98 0.016 73.684)` | `oklch(0.205 0.05 40)` | ตัวอักษร `default` |
|
|
102
|
+
| `--secondary` | `oklch(0.967 0.001 286.375)` | `oklch(0.274 0.006 286.033)` | พื้น `secondary` |
|
|
103
|
+
| `--secondary-foreground` | `oklch(0.21 0.006 285.885)` | `oklch(0.985 0 0)` | ตัวอักษร `secondary` |
|
|
104
|
+
| `--border` | `oklch(0.93 0.007 106.5)` | `oklch(1 0 0 / 10%)` | เส้นขอบ `outline` |
|
|
105
|
+
| `--foreground` | `oklch(0.153 0.006 107.1)` | `oklch(0.988 0.003 106.5)` | ตัวอักษร `outline` |
|
|
106
|
+
| `--success` | `oklch(0.49 0.12 150)` | `oklch(0.75 0.16 150)` | `success` (ตัวอักษร + พื้นจาง) |
|
|
107
|
+
| `--warning` | `oklch(0.5 0.12 60)` | `oklch(0.82 0.15 80)` | `warning` (ตัวอักษร + พื้นจาง) |
|
|
108
|
+
| `--destructive` | `oklch(0.505 0.2 27.325)` | `oklch(0.75 0.16 22.216)` | `destructive` และสถานะไม่ถูกต้อง |
|
|
109
|
+
| `--ring` | `oklch(0.45 0.03 106.9)` | `oklch(0.8 0.02 106.9)` | วงแหวน focus |
|
|
110
|
+
| `--radius` | `0.625rem` | – | ฐานของมุมโค้ง (ป้ายใช้ `--radius × 2.2` = 22px) |
|
|
111
|
+
|
|
112
|
+
ตัวอักษรบนพื้นของทุก variant ผ่าน WCAG AA (อย่างน้อย 4.5:1) ทั้งสองโหมด รวมถึงบนพื้น `Card`
|
|
113
|
+
|
|
114
|
+
## Example
|
|
115
|
+
|
|
116
|
+
จาก story `RiskLevels` ใน `Badge.stories.tsx`:
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
120
|
+
<Badge variant="success">ความเสี่ยงต่ำ</Badge>
|
|
121
|
+
<Badge variant="warning">ความเสี่ยงปานกลาง</Badge>
|
|
122
|
+
<Badge variant="destructive">ความเสี่ยงสูง</Badge>
|
|
123
|
+
</div>
|
|
124
|
+
```
|