@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,165 @@
|
|
|
1
|
+
# Button (ปุ่ม)
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
ปุ่มให้ผู้ใช้สั่งการกระทำในหน้า เช่น ส่งฟอร์ม บันทึก หรือเปิด dialog
|
|
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, buttonVariants } from "@designil/labdsnov"
|
|
17
|
+
|
|
18
|
+
<Button type="submit">บันทึก</Button>
|
|
19
|
+
<Button variant="outline" onClick={onCancel}>ยกเลิก</Button>
|
|
20
|
+
|
|
21
|
+
// ปุ่มไอคอนอย่างเดียว ต้องมี aria-label
|
|
22
|
+
<Button size="icon" variant="ghost" aria-label="ตั้งค่า">
|
|
23
|
+
<HugeiconsIcon icon={Settings01Icon} strokeWidth={2} />
|
|
24
|
+
</Button>
|
|
25
|
+
|
|
26
|
+
// ลิงก์ไปหน้าอื่นที่หน้าตาเหมือนปุ่ม
|
|
27
|
+
import Link from "next/link"
|
|
28
|
+
|
|
29
|
+
<Link href="/register" className={buttonVariants({ variant: "outline" })}>
|
|
30
|
+
สมัครสมาชิก
|
|
31
|
+
</Link>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
ถ้าใช้ไอคอน ให้ติดตั้ง `@hugeicons/react` และ `@hugeicons/core-free-icons` ในแอปด้วย
|
|
35
|
+
|
|
36
|
+
## When to use
|
|
37
|
+
|
|
38
|
+
- การกระทำที่เกิดขึ้นในหน้าเดิม เช่น "บันทึก", "เพิ่มเงินสมทบ", "ลบ"
|
|
39
|
+
- ปุ่มส่งฟอร์ม เช่น "เข้าสู่ระบบ" (เต็มความกว้างด้วย `fullWidth`)
|
|
40
|
+
- ปุ่มที่เปิด dialog หรือเมนู
|
|
41
|
+
- ปุ่มไอคอนอย่างเดียวในแถบเครื่องมือ เช่น "ตั้งค่า"
|
|
42
|
+
|
|
43
|
+
## When not to use
|
|
44
|
+
|
|
45
|
+
- **ไปหน้าอื่น**: ใช้ลิงก์ ถ้าต้องให้หน้าตาเหมือนปุ่ม ทำได้ตาม story `AsLink`
|
|
46
|
+
- **ป้ายสถานะ**: ใช้ `Badge`
|
|
47
|
+
- **ปุ่มหลักหลายปุ่มในพื้นที่เดียว**: ใช้ `default` ปุ่มเดียว ปุ่มอื่นใช้ `outline`, `secondary` หรือ `ghost`
|
|
48
|
+
|
|
49
|
+
## Props and variants
|
|
50
|
+
|
|
51
|
+
| Prop | ค่า | ค่าเริ่มต้น | ความหมาย |
|
|
52
|
+
| ----------------------- | --------------------------- | --------- | --------------------------------------------------------------- |
|
|
53
|
+
| `variant` | ดูตารางด้านล่าง | `default` | ระดับความเด่นของปุ่ม |
|
|
54
|
+
| `size` | ดูตารางด้านล่าง | `default` | ความสูงและระยะขอบใน |
|
|
55
|
+
| `fullWidth` | `boolean` | `false` | ขยายเต็มความกว้างของพื้นที่ เช่น ปุ่มเข้าสู่ระบบ/สมัครสมาชิก |
|
|
56
|
+
| `disabled` | `boolean` | `false` | ปิดใช้งาน จางลง 50% กดและโฟกัสไม่ได้ |
|
|
57
|
+
| `focusableWhenDisabled` | `boolean` | `false` | ปิดใช้งานแต่ยังโฟกัสได้ เช่น เพื่อแสดงคำอธิบายว่าทำไมกดไม่ได้ |
|
|
58
|
+
| `type` | `button`, `submit`, `reset` | `button` | ใช้ `submit` กับปุ่มส่งฟอร์ม |
|
|
59
|
+
| `aria-label` | ข้อความ | – | **บังคับ** สำหรับปุ่มไอคอนอย่างเดียว เป็นภาษาไทย |
|
|
60
|
+
| `render` | element | – | ให้ปุ่มทำหน้าที่เป็นส่วนของคอมโพเนนต์อื่น เช่น ปุ่มเปิด/ปิด `Dialog` |
|
|
61
|
+
| `className` | class | – | ปรับหน้าตาเฉพาะจุดครั้งเดียว ชนะสไตล์ของปุ่มเสมอ ถ้าใช้ซ้ำ ให้ขอ variant ใหม่ |
|
|
62
|
+
|
|
63
|
+
### Variants
|
|
64
|
+
|
|
65
|
+
| Variant | ใช้เมื่อ | หน้าตา |
|
|
66
|
+
| ------------- | ----------------------------- | --------------------------- |
|
|
67
|
+
| `default` | การกระทำหลักของพื้นที่ (1 ปุ่มต่อพื้นที่) | พื้นสีหลัก (ส้ม) ตัวอักษรสีอ่อน |
|
|
68
|
+
| `outline` | ทางเลือกคู่กับปุ่มหลัก เช่น "ยกเลิก" | พื้นเท่ากับพื้นหลัง มีเส้นขอบ |
|
|
69
|
+
| `secondary` | การกระทำรอง | พื้นเทาอ่อน |
|
|
70
|
+
| `ghost` | ปุ่มในแถบเครื่องมือ ปุ่มไอคอน | โปร่งใส มีพื้นเมื่อ hover |
|
|
71
|
+
| `destructive` | การกระทำที่ลบหรือย้อนกลับไม่ได้ | พื้นแดงจาง ตัวอักษรแดง |
|
|
72
|
+
| `link` | การกระทำที่ดูเหมือนลิงก์ในข้อความ | ตัวอักษรสีหลัก ขีดเส้นใต้เมื่อ hover |
|
|
73
|
+
|
|
74
|
+
TODO: ยังไม่มีเกณฑ์ชัดเจนว่าการกระทำรองควรใช้ `outline` หรือ `secondary`
|
|
75
|
+
|
|
76
|
+
### Sizes
|
|
77
|
+
|
|
78
|
+
| Size | ความสูง | ใช้กับ |
|
|
79
|
+
| --------- | ------- | --------------------------------------- |
|
|
80
|
+
| `xs` | 24px | TODO: ยังไม่ได้กำหนดการใช้งาน |
|
|
81
|
+
| `sm` | 32px | TODO: ยังไม่ได้กำหนดการใช้งาน |
|
|
82
|
+
| `default` | 36px | ปุ่มทั่วไป ใช้ขนาดนี้เมื่อไม่แน่ใจ |
|
|
83
|
+
| `lg` | 40px | TODO: ยังไม่ได้กำหนดการใช้งาน |
|
|
84
|
+
| `icon-xs` | 24×24px | ปุ่มไอคอนอย่างเดียว ขนาดสอดคล้องกับ `xs` |
|
|
85
|
+
| `icon-sm` | 32×32px | ปุ่มไอคอนอย่างเดียว เช่น ปุ่ม "ปิด" ใน Dialog |
|
|
86
|
+
| `icon` | 36×36px | ปุ่มไอคอนอย่างเดียว ขนาดสอดคล้องกับ `default` |
|
|
87
|
+
| `icon-lg` | 40×40px | ปุ่มไอคอนอย่างเดียว ขนาดสอดคล้องกับ `lg` |
|
|
88
|
+
|
|
89
|
+
ทุกขนาดเป็นทรงแคปซูล ตัวอักษร 14px น้ำหนัก medium (`xs` ใช้ 12px) ไอคอน 16px (`xs`, `icon-xs` ใช้ 12px) วางไอคอนหน้าหรือหลังข้อความได้ตาม story `WithIcons`
|
|
90
|
+
|
|
91
|
+
### States
|
|
92
|
+
|
|
93
|
+
- **Hover**: พื้นเข้มขึ้นหรือมีพื้นขึ้นมา (`link` ขีดเส้นใต้)
|
|
94
|
+
- **กดค้าง**: ปุ่มเลื่อนลง 1px
|
|
95
|
+
- **Focus จากคีย์บอร์ด**: เส้นขอบและวงแหวนทึบ 2px สี `--focus-ring` ทุก variant (contrast อย่างน้อย 3:1 กับพื้นหน้า)
|
|
96
|
+
- **ปิดใช้งาน**: จางลง 50%
|
|
97
|
+
- **ข้อมูลไม่ถูกต้อง** (`aria-invalid`): เส้นขอบและวงแหวนสีแดง
|
|
98
|
+
- **เปิดอยู่** (`aria-expanded`, เช่น ปุ่มที่เปิดเมนู): `outline` และ `ghost` คงพื้นไว้
|
|
99
|
+
|
|
100
|
+
## Tokens used
|
|
101
|
+
|
|
102
|
+
ค่าทั้งหมดมาจาก `src/styles/theme.css`
|
|
103
|
+
|
|
104
|
+
### Component tokens
|
|
105
|
+
|
|
106
|
+
token เฉพาะของคอมโพเนนต์นี้ ชี้ไปที่ semantic token ด้านล่าง เปลี่ยนที่นี่เพื่อปรับเฉพาะคอมโพเนนต์นี้ (โหมดมืด "–" = ใช้ค่าเดียวกับโหมดสว่าง)
|
|
107
|
+
|
|
108
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
109
|
+
| ------------------------------- | ---------------------------------- | ---------------------- | ----------------------------------------------- |
|
|
110
|
+
| `--button-primary-bg` | `--primary` | – | พื้น `default` |
|
|
111
|
+
| `--button-primary-fg` | `--primary-foreground` | – | ตัวอักษร `default` |
|
|
112
|
+
| `--button-primary-hover-bg` | `--primary` ผสมดำ 12% | `--primary` ผสมขาว 12% | พื้น `default` ตอน hover |
|
|
113
|
+
| `--button-outline-border` | `--border` | – | เส้นขอบ `outline` |
|
|
114
|
+
| `--button-outline-bg` | `--background` | `transparent` | พื้น `outline` |
|
|
115
|
+
| `--button-outline-hover-bg` | `--muted` | `--input` | พื้น `outline` ตอน hover / เปิดเมนู |
|
|
116
|
+
| `--button-hover-fg` | `--foreground` | – | ตัวอักษร `outline` / `ghost` ตอน hover |
|
|
117
|
+
| `--button-secondary-bg` | `--secondary` | – | พื้น `secondary` |
|
|
118
|
+
| `--button-secondary-fg` | `--secondary-foreground` | – | ตัวอักษร `secondary` |
|
|
119
|
+
| `--button-secondary-hover-bg` | `--secondary` ผสม`--foreground` 5% | – | พื้น `secondary` ตอน hover |
|
|
120
|
+
| `--button-ghost-hover-bg` | `--muted` | `--muted` 50% | พื้น `ghost` ตอน hover / เปิดเมนู |
|
|
121
|
+
| `--button-destructive-bg` | `--destructive` 10% | `--destructive` 20% | พื้น `destructive` |
|
|
122
|
+
| `--button-destructive-fg` | `--destructive` | – | ตัวอักษร `destructive` |
|
|
123
|
+
| `--button-destructive-hover-bg` | `--destructive` 18% | `--destructive` 30% | พื้น `destructive` ตอน hover |
|
|
124
|
+
| `--button-link-fg` | `--primary` | – | ตัวอักษร `link` |
|
|
125
|
+
| `--focus-ring` | `--ring` | – | วงแหวน focus จากคีย์บอร์ดของทุกคอมโพเนนต์ (ทึบ 2px) |
|
|
126
|
+
| `--invalid-border` | `--destructive` | – | เส้นขอบเมื่อข้อมูลไม่ถูกต้อง และวงแหวน focus ขณะไม่ถูกต้อง |
|
|
127
|
+
| `--invalid-ring` | `--destructive` 20% | `--destructive` 40% | วงแหวนจางรอบช่องที่ไม่ถูกต้อง (ตกแต่ง) |
|
|
128
|
+
|
|
129
|
+
### Semantic tokens
|
|
130
|
+
|
|
131
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
132
|
+
| ------------------------ | ---------------------------- | ---------------------------- | ------------------------------------------- |
|
|
133
|
+
| `--primary` | `oklch(0.553 0.195 38.402)` | `oklch(0.705 0.187 47.604)` | พื้น `default`, ตัวอักษร `link` |
|
|
134
|
+
| `--primary-foreground` | `oklch(0.98 0.016 73.684)` | `oklch(0.205 0.05 40)` | ตัวอักษร `default` |
|
|
135
|
+
| `--secondary` | `oklch(0.967 0.001 286.375)` | `oklch(0.274 0.006 286.033)` | พื้น `secondary` |
|
|
136
|
+
| `--secondary-foreground` | `oklch(0.21 0.006 285.885)` | `oklch(0.985 0 0)` | ตัวอักษร `secondary` |
|
|
137
|
+
| `--background` | `oklch(1 0 0)` | `oklch(0.153 0.006 107.1)` | พื้น `outline` (โหมดสว่าง) |
|
|
138
|
+
| `--border` | `oklch(0.93 0.007 106.5)` | `oklch(1 0 0 / 10%)` | เส้นขอบ `outline` |
|
|
139
|
+
| `--muted` | `oklch(0.966 0.005 106.5)` | `oklch(0.286 0.016 107.4)` | hover ของ `outline`, `ghost` |
|
|
140
|
+
| `--foreground` | `oklch(0.153 0.006 107.1)` | `oklch(0.988 0.003 106.5)` | ตัวอักษรตอน hover, ผสมสี hover ของ `secondary` |
|
|
141
|
+
| `--input` | `oklch(0.93 0.007 106.5)` | `oklch(1 0 0 / 15%)` | hover ของ `outline` (โหมดมืด) |
|
|
142
|
+
| `--destructive` | `oklch(0.505 0.2 27.325)` | `oklch(0.75 0.16 22.216)` | `destructive`, สถานะไม่ถูกต้อง |
|
|
143
|
+
| `--ring` | `oklch(0.45 0.03 106.9)` | `oklch(0.8 0.02 106.9)` | เส้นขอบและวงแหวน focus |
|
|
144
|
+
| `--radius` | `0.625rem` | – | มุมโค้ง (`--radius × 2.6` = 26px ทรงแคปซูล) |
|
|
145
|
+
|
|
146
|
+
## Example
|
|
147
|
+
|
|
148
|
+
จาก story `WithIcons` ใน `Button.stories.tsx`:
|
|
149
|
+
|
|
150
|
+
```tsx
|
|
151
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
152
|
+
<Button>
|
|
153
|
+
<HugeiconsIcon icon={Add01Icon} strokeWidth={2} data-icon="inline-start" />
|
|
154
|
+
เพิ่มเงินสมทบ
|
|
155
|
+
</Button>
|
|
156
|
+
<Button variant="outline">
|
|
157
|
+
ถัดไป
|
|
158
|
+
<HugeiconsIcon
|
|
159
|
+
icon={ArrowRight01Icon}
|
|
160
|
+
strokeWidth={2}
|
|
161
|
+
data-icon="inline-end"
|
|
162
|
+
/>
|
|
163
|
+
</Button>
|
|
164
|
+
</div>
|
|
165
|
+
```
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: button-group
|
|
3
|
+
name: ButtonGroup
|
|
4
|
+
description: >-
|
|
5
|
+
Joins related command buttons (and inputs or a Select) into one bar, with square
|
|
6
|
+
inner corners and shared borders.
|
|
7
|
+
metadata:
|
|
8
|
+
status: {status: stable}
|
|
9
|
+
since: 1.0.0
|
|
10
|
+
tags: [action, layout]
|
|
11
|
+
|
|
12
|
+
sections:
|
|
13
|
+
- kind: guidelines
|
|
14
|
+
for: all
|
|
15
|
+
framing: when-to-use
|
|
16
|
+
items:
|
|
17
|
+
- level: should
|
|
18
|
+
statement: >-
|
|
19
|
+
Use for commands that belong together, e.g. download in several formats
|
|
20
|
+
(PDF / Excel), zoom in/out.
|
|
21
|
+
- level: should
|
|
22
|
+
statement: >-
|
|
23
|
+
Use for a split button: a primary button paired with a button that opens a
|
|
24
|
+
menu of more options (<dsds:dropdown-menu>).
|
|
25
|
+
example:
|
|
26
|
+
ref:
|
|
27
|
+
href: ./ButtonGroup.stories.tsx#SplitButton
|
|
28
|
+
rel: demo
|
|
29
|
+
uses:
|
|
30
|
+
- to: dropdown-menu
|
|
31
|
+
- level: should
|
|
32
|
+
statement: >-
|
|
33
|
+
Use for an input with a unit and a button attached, e.g. "AU$" + amount +
|
|
34
|
+
"เพิ่ม" (add).
|
|
35
|
+
- level: must-not
|
|
36
|
+
statement: >-
|
|
37
|
+
Never use it to pick one option that stays selected (e.g. monthly/yearly
|
|
38
|
+
view); use <dsds:toggle-group>, which shows the selected state.
|
|
39
|
+
alternatives:
|
|
40
|
+
- to: toggle-group
|
|
41
|
+
checkedBy: manual
|
|
42
|
+
- level: must-not
|
|
43
|
+
statement: >-
|
|
44
|
+
Never group the confirm/cancel buttons at the end of a form or Dialog; use
|
|
45
|
+
separate <dsds:button>s with space between them, to avoid mis-taps.
|
|
46
|
+
alternatives:
|
|
47
|
+
- to: button
|
|
48
|
+
checkedBy: manual
|
|
49
|
+
- level: should-not
|
|
50
|
+
statement: >-
|
|
51
|
+
Don't use it just to put a unit or icon in an input; use <dsds:input-group>.
|
|
52
|
+
alternatives:
|
|
53
|
+
- to: input-group
|
|
54
|
+
|
|
55
|
+
- kind: guidelines
|
|
56
|
+
for: all
|
|
57
|
+
items:
|
|
58
|
+
- id: group-label
|
|
59
|
+
level: must
|
|
60
|
+
statement: >-
|
|
61
|
+
Give `ButtonGroup` an `aria-label` saying what its buttons do together, e.g.
|
|
62
|
+
"ดาวน์โหลดรายงาน" (download report). The group has `role="group"`.
|
|
63
|
+
checks:
|
|
64
|
+
- href: ./ButtonGroup.stories.tsx#Playground
|
|
65
|
+
role: test
|
|
66
|
+
note: The play function checks the group role, its name, and the shared corners/borders
|
|
67
|
+
checkedBy: automated
|
|
68
|
+
- id: separator-for-borderless
|
|
69
|
+
level: must
|
|
70
|
+
statement: >-
|
|
71
|
+
Borderless buttons (`default`, `secondary`) must be separated with
|
|
72
|
+
`ButtonGroupSeparator`, or they merge into one block. `outline` already
|
|
73
|
+
shares its borders.
|
|
74
|
+
checkedBy: manual
|
|
75
|
+
- id: same-variant
|
|
76
|
+
level: should
|
|
77
|
+
statement: >-
|
|
78
|
+
Buttons in a group use the same variant and size, except a split button,
|
|
79
|
+
where the main button and the chevron button share a variant but the chevron
|
|
80
|
+
is `size="icon"`.
|
|
81
|
+
checkedBy: manual
|
|
82
|
+
- id: allowed-children
|
|
83
|
+
level: should
|
|
84
|
+
statement: >-
|
|
85
|
+
Allowed children: `Button`, `Input`, `Select`, `InputGroup`, `ButtonGroupText`
|
|
86
|
+
and nested `ButtonGroup`s (8px between groups). Other elements don't get the
|
|
87
|
+
shared corners and borders.
|
|
88
|
+
example:
|
|
89
|
+
ref:
|
|
90
|
+
href: ./ButtonGroup.stories.tsx#Nested
|
|
91
|
+
rel: demo
|
|
92
|
+
uses:
|
|
93
|
+
- to: button
|
|
94
|
+
- to: input
|
|
95
|
+
- to: select
|
|
96
|
+
- to: input-group
|
|
97
|
+
checkedBy: manual
|
|
98
|
+
- id: text-is-static
|
|
99
|
+
level: should
|
|
100
|
+
statement: >-
|
|
101
|
+
`ButtonGroupText` is only for text or units that can't be pressed, such as
|
|
102
|
+
"AU$". Use `render={<Label />}` when the text is the label of an input in the
|
|
103
|
+
group.
|
|
104
|
+
checkedBy: manual
|
|
105
|
+
|
|
106
|
+
- kind: guidelines
|
|
107
|
+
for: all
|
|
108
|
+
title: Accessibility
|
|
109
|
+
tags: [accessibility]
|
|
110
|
+
items:
|
|
111
|
+
- id: focus-raised
|
|
112
|
+
level: must
|
|
113
|
+
statement: >-
|
|
114
|
+
A keyboard-focused button is raised (`z-index: 10`) so neighbouring buttons
|
|
115
|
+
don't cover its focus ring. Never set `z-index` or `overflow: hidden` on the
|
|
116
|
+
group over it.
|
|
117
|
+
checks:
|
|
118
|
+
- href: ./ButtonGroup.stories.tsx#KeyboardFocus
|
|
119
|
+
role: test
|
|
120
|
+
note: The play function checks the focused button has zIndex 10
|
|
121
|
+
checkedBy: automated
|
|
122
|
+
- id: input-label
|
|
123
|
+
level: must
|
|
124
|
+
statement: >-
|
|
125
|
+
An `Input` in a group needs its own name (`aria-label`, or `ButtonGroupText`
|
|
126
|
+
with `render={<Label htmlFor="…" />}`). The "AU$" next to it isn't the
|
|
127
|
+
input's name.
|
|
128
|
+
evidence:
|
|
129
|
+
- href: https://www.w3.org/WAI/WCAG22/Understanding/labels-or-instructions.html
|
|
130
|
+
role: WCAG 2.2 SC 3.3.2 (A)
|
|
131
|
+
checkedBy: manual
|
|
132
|
+
- id: text-contrast
|
|
133
|
+
level: must
|
|
134
|
+
statement: >-
|
|
135
|
+
Text in `ButtonGroupText` passes 17.76:1 light, 13.79:1 dark.
|
|
136
|
+
checks:
|
|
137
|
+
- href: ../../../scripts/tokens.mjs
|
|
138
|
+
role: test
|
|
139
|
+
note: CONTRAST_PAIRS "ข้อความใน ButtonGroup" (text in ButtonGroup)
|
|
140
|
+
checkedBy: automated
|
|
141
|
+
|
|
142
|
+
- kind: definitions
|
|
143
|
+
for: all
|
|
144
|
+
context: anatomy
|
|
145
|
+
items:
|
|
146
|
+
- term: ButtonGroup
|
|
147
|
+
definition: >-
|
|
148
|
+
The frame, `role="group"`. Takes `orientation`.
|
|
149
|
+
- term: ButtonGroupText
|
|
150
|
+
definition: >-
|
|
151
|
+
Text or a unit that can't be pressed; tinted background with a border
|
|
152
|
+
(`render` changes the element).
|
|
153
|
+
- term: ButtonGroupSeparator
|
|
154
|
+
definition: >-
|
|
155
|
+
A line between borderless buttons. `orientation` defaults to `vertical`.
|
|
156
|
+
|
|
157
|
+
sourceFiles:
|
|
158
|
+
- platform: react
|
|
159
|
+
file: ./ButtonGroup.tsx
|
|
160
|
+
|
|
161
|
+
imports:
|
|
162
|
+
- platform: react
|
|
163
|
+
code: >-
|
|
164
|
+
import { ButtonGroup, ButtonGroupSeparator, ButtonGroupText } from "@designil/labdsnov"
|
|
165
|
+
package: "@designil/labdsnov"
|
|
166
|
+
|
|
167
|
+
traits:
|
|
168
|
+
- traitType: variant
|
|
169
|
+
kind: enum
|
|
170
|
+
id: orientation
|
|
171
|
+
description: >-
|
|
172
|
+
Direction of the group.
|
|
173
|
+
values:
|
|
174
|
+
- id: horizontal
|
|
175
|
+
description: >-
|
|
176
|
+
One row; left/right inner corners are square.
|
|
177
|
+
- id: vertical
|
|
178
|
+
description: >-
|
|
179
|
+
One column; top/bottom inner corners are square.
|
|
180
|
+
|
|
181
|
+
uses:
|
|
182
|
+
- to: button
|
|
183
|
+
alternatives:
|
|
184
|
+
- to: toggle-group
|
|
185
|
+
- to: input-group
|
|
186
|
+
|
|
187
|
+
refs:
|
|
188
|
+
- href: ./ButtonGroup.md
|
|
189
|
+
rel: relates-to
|
|
190
|
+
role: Usage doc in Thai
|
|
191
|
+
- href: ./ButtonGroup.stories.tsx
|
|
192
|
+
rel: demo
|
|
193
|
+
role: CSF stories
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# ButtonGroup (กลุ่มปุ่ม)
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
รวมปุ่มคำสั่งที่เกี่ยวข้องกัน (และช่องกรอกหรือ Select) ให้เป็นแถบเดียว มุมด้านในเป็นเหลี่ยมและใช้เส้นขอบร่วมกัน
|
|
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, ButtonGroup } from "@designil/labdsnov"
|
|
17
|
+
|
|
18
|
+
;<ButtonGroup aria-label="ดาวน์โหลดรายงาน">
|
|
19
|
+
<Button variant="outline">PDF</Button>
|
|
20
|
+
<Button variant="outline">Excel</Button>
|
|
21
|
+
</ButtonGroup>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
- ใส่ `aria-label` ที่กลุ่ม บอกว่าปุ่มในกลุ่มทำอะไรร่วมกัน
|
|
25
|
+
- ปุ่มที่ไม่มีเส้นขอบ (`default`, `secondary`) ต้องคั่นด้วย `ButtonGroupSeparator`
|
|
26
|
+
- ใส่ได้: `Button`, `Input`, `Select`, `InputGroup`, `ButtonGroupText` และ `ButtonGroup` ซ้อน (เว้นระยะ 8px)
|
|
27
|
+
|
|
28
|
+
## When to use
|
|
29
|
+
|
|
30
|
+
- คำสั่งที่เป็นชุดเดียวกัน เช่น ดาวน์โหลดหลายรูปแบบ ขยาย/ย่อ
|
|
31
|
+
- ปุ่มหลักคู่กับปุ่มเปิดเมนูตัวเลือกเพิ่ม (split button)
|
|
32
|
+
- ช่องกรอกที่มีหน่วยและปุ่มติดกัน เช่น "AU$" + จำนวนเงิน + "เพิ่ม"
|
|
33
|
+
|
|
34
|
+
## When not to use
|
|
35
|
+
|
|
36
|
+
| สถานการณ์ | ใช้แทน |
|
|
37
|
+
| ----------------------------- | ---------------------- |
|
|
38
|
+
| เลือกหนึ่งตัวเลือกที่ค้างไว้ | `ToggleGroup` |
|
|
39
|
+
| ปุ่มยืนยัน/ยกเลิกท้ายฟอร์มหรือ Dialog | `Button` แยกกันมีระยะห่าง |
|
|
40
|
+
| หน่วยหรือไอคอนในช่องกรอกอย่างเดียว | `InputGroup` |
|
|
41
|
+
|
|
42
|
+
## Props and variants
|
|
43
|
+
|
|
44
|
+
### ButtonGroup
|
|
45
|
+
|
|
46
|
+
| Prop | ค่า | ค่าเริ่มต้น | ความหมาย |
|
|
47
|
+
| ------------- | ------------------------ | ------------ | ---------------------------- |
|
|
48
|
+
| `orientation` | `horizontal`, `vertical` | `horizontal` | แถวหรือคอลัมน์ |
|
|
49
|
+
| `aria-label` | ข้อความ | – | ชื่อของกลุ่มสำหรับโปรแกรมอ่านหน้าจอ |
|
|
50
|
+
|
|
51
|
+
### ส่วนอื่น ๆ
|
|
52
|
+
|
|
53
|
+
- `ButtonGroupText`: ข้อความหรือหน่วยที่กดไม่ได้ เช่น "AU$" พื้นจาง มีเส้นขอบ (`render` เปลี่ยน element ได้ เช่น `<Label />`)
|
|
54
|
+
- `ButtonGroupSeparator`: เส้นคั่นระหว่างปุ่มที่ไม่มีเส้นขอบ (`orientation` ค่าเริ่มต้น `vertical`)
|
|
55
|
+
|
|
56
|
+
ปุ่มที่โฟกัสจากคีย์บอร์ดยกขึ้นด้านบน วงแหวน focus จึงไม่ถูกปุ่มข้าง ๆ บัง
|
|
57
|
+
|
|
58
|
+
## Tokens used
|
|
59
|
+
|
|
60
|
+
ค่าทั้งหมดมาจาก `src/styles/theme.css`
|
|
61
|
+
|
|
62
|
+
### Component tokens
|
|
63
|
+
|
|
64
|
+
token เฉพาะของคอมโพเนนต์นี้ ชี้ไปที่ semantic token ด้านล่าง เปลี่ยนที่นี่เพื่อปรับเฉพาะคอมโพเนนต์นี้ (โหมดมืด "–" = ใช้ค่าเดียวกับโหมดสว่าง)
|
|
65
|
+
|
|
66
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
67
|
+
| -------------------------- | -------------- | ------ | ------------------------ |
|
|
68
|
+
| `--button-group-text-bg` | `--muted` | – | พื้น `ButtonGroupText` |
|
|
69
|
+
| `--button-group-text-fg` | `--foreground` | – | ตัวอักษร `ButtonGroupText` |
|
|
70
|
+
| `--button-group-separator` | `--input` | – | เส้นคั่นระหว่างปุ่ม |
|
|
71
|
+
|
|
72
|
+
### Semantic tokens
|
|
73
|
+
|
|
74
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
75
|
+
| -------------- | -------------------------- | -------------------------- | --------------------------- |
|
|
76
|
+
| `--border` | `oklch(0.93 0.007 106.5)` | `oklch(1 0 0 / 10%)` | เส้นขอบ `ButtonGroupText` |
|
|
77
|
+
| `--foreground` | `oklch(0.153 0.006 107.1)` | `oklch(0.988 0.003 106.5)` | ผ่าน token ของคอมโพเนนต์ด้านบน |
|
|
78
|
+
| `--input` | `oklch(0.93 0.007 106.5)` | `oklch(1 0 0 / 15%)` | ผ่าน token ของคอมโพเนนต์ด้านบน |
|
|
79
|
+
| `--muted` | `oklch(0.966 0.005 106.5)` | `oklch(0.286 0.016 107.4)` | ผ่าน token ของคอมโพเนนต์ด้านบน |
|
|
80
|
+
|
|
81
|
+
## Example
|
|
82
|
+
|
|
83
|
+
จาก story `WithInput` ใน `ButtonGroup.stories.tsx`:
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
<ButtonGroup aria-label="เงินสมทบเพิ่มเติม">
|
|
87
|
+
<ButtonGroupText>AU$</ButtonGroupText>
|
|
88
|
+
<Input
|
|
89
|
+
aria-label="จำนวนเงิน"
|
|
90
|
+
type="number"
|
|
91
|
+
placeholder="0.00"
|
|
92
|
+
className="w-36"
|
|
93
|
+
/>
|
|
94
|
+
<Button>เพิ่ม</Button>
|
|
95
|
+
</ButtonGroup>
|
|
96
|
+
```
|