@designil/labdsnov 0.0.0-stage → 1.0.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 +133 -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 +96 -0
- package/docs/ComponentTokens.md +191 -0
- package/docs/Contributing.md +97 -0
- package/docs/GettingStarted.md +106 -0
- package/docs/Radius.md +25 -0
- package/docs/Typography.md +38 -0
- package/package.json +79 -3
- package/src/components/Accordion/Accordion.md +102 -0
- package/src/components/Alert/Alert.md +90 -0
- package/src/components/AlertDialog/AlertDialog.md +131 -0
- package/src/components/Avatar/Avatar.md +77 -0
- package/src/components/Badge/Badge.md +124 -0
- package/src/components/Breadcrumb/Breadcrumb.md +110 -0
- package/src/components/Button/Button.md +165 -0
- package/src/components/ButtonGroup/ButtonGroup.md +96 -0
- package/src/components/Calendar/Calendar.md +111 -0
- package/src/components/Card/Card.md +99 -0
- package/src/components/Chart/Chart.md +112 -0
- package/src/components/Checkbox/Checkbox.md +105 -0
- package/src/components/Collapsible/Collapsible.md +86 -0
- package/src/components/Combobox/Combobox.md +143 -0
- package/src/components/DatePicker/DatePicker.md +82 -0
- package/src/components/Dialog/Dialog.md +193 -0
- package/src/components/Drawer/Drawer.md +125 -0
- package/src/components/DropdownMenu/DropdownMenu.md +151 -0
- package/src/components/Empty/Empty.md +90 -0
- package/src/components/Field/Field.md +139 -0
- package/src/components/FundCard/FundCard.md +93 -0
- package/src/components/HoverCard/HoverCard.md +100 -0
- package/src/components/Input/Input.md +115 -0
- package/src/components/InputGroup/InputGroup.md +115 -0
- package/src/components/InputOTP/InputOTP.md +105 -0
- package/src/components/Kbd/Kbd.md +85 -0
- package/src/components/Label/Label.md +75 -0
- package/src/components/NavigationMenu/NavigationMenu.md +128 -0
- package/src/components/Pagination/Pagination.md +115 -0
- package/src/components/Popover/Popover.md +111 -0
- package/src/components/Progress/Progress.md +83 -0
- package/src/components/RadioGroup/RadioGroup.md +123 -0
- package/src/components/ScrollArea/ScrollArea.md +88 -0
- package/src/components/Select/Select.md +170 -0
- package/src/components/Separator/Separator.md +68 -0
- package/src/components/Skeleton/Skeleton.md +68 -0
- package/src/components/Slider/Slider.md +107 -0
- package/src/components/Spinner/Spinner.md +64 -0
- package/src/components/Switch/Switch.md +101 -0
- package/src/components/Table/Table.md +117 -0
- package/src/components/Tabs/Tabs.md +173 -0
- package/src/components/Textarea/Textarea.md +89 -0
- package/src/components/Toaster/Toaster.md +107 -0
- package/src/components/Toggle/Toggle.md +103 -0
- package/src/components/ToggleGroup/ToggleGroup.md +95 -0
- package/src/components/Tooltip/Tooltip.md +104 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Calendar (ปฏิทิน)
|
|
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
|
+
ใช้ไลบรารี `react-day-picker` และ `date-fns` (ติดตั้งมากับ `@designil/labdsnov` แล้ว)
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
"use client"
|
|
19
|
+
|
|
20
|
+
import { useState } from "react"
|
|
21
|
+
import { Calendar } from "@designil/labdsnov"
|
|
22
|
+
|
|
23
|
+
const [date, setDate] = useState<Date>()
|
|
24
|
+
|
|
25
|
+
<Calendar mode="single" selected={date} onSelect={setDate} />
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- ภาษาไทยเป็นค่าเริ่มต้น: ชื่อเดือนและวันเป็นภาษาไทย ปีเป็น พ.ศ. (พฤศจิกายน 2569) เหมือน `FundCard`
|
|
29
|
+
- ในฟอร์ม ส่วนใหญ่ควรใช้ `DatePicker` ซึ่งเปิดปฏิทินนี้ในกล่องลอย
|
|
30
|
+
|
|
31
|
+
## When to use
|
|
32
|
+
|
|
33
|
+
- เลือกวันที่ที่ผู้ใช้ต้องเห็นบริบทของเดือน เช่น วันนัดหมาย
|
|
34
|
+
- เลือกช่วงวันที่ (`mode="range"`) เช่น ช่วงของใบแจ้งยอด
|
|
35
|
+
- แสดงปฏิทินในหน้าโดยตรง เช่น ในการ์ด
|
|
36
|
+
|
|
37
|
+
## When not to use
|
|
38
|
+
|
|
39
|
+
- **วันที่ในช่องฟอร์ม**: ใช้ `DatePicker`
|
|
40
|
+
- **วันเกิดหรือวันที่ที่รู้แน่นอน**: พิมพ์ง่ายกว่าเลือก TODO: ยังไม่มีช่องกรอกวันที่แบบพิมพ์ (วว/ดด/ปปปป) ระหว่างนี้ใช้ `captionLayout="dropdown"`
|
|
41
|
+
|
|
42
|
+
## Props and variants
|
|
43
|
+
|
|
44
|
+
| Prop | ค่า | ค่าเริ่มต้น | ความหมาย |
|
|
45
|
+
| ----------------------- | ----------------------------------- | ------- | ------------------------------------------------------------------- |
|
|
46
|
+
| `mode` | `single`, `multiple`, `range` | – | เลือกวันเดียว หลายวัน หรือช่วง |
|
|
47
|
+
| `selected` / `onSelect` | `Date` / ช่วง / ฟังก์ชัน | – | วันที่เลือกและฟังก์ชันเมื่อเลือก |
|
|
48
|
+
| `defaultMonth` | `Date` | เดือนนี้ | เดือนที่แสดงตอนแรก |
|
|
49
|
+
| `captionLayout` | `label`, `dropdown` | `label` | `dropdown` = เลือกเดือนและปีจากรายการ (ใช้กับ `startMonth` / `endMonth`) |
|
|
50
|
+
| `numberOfMonths` | ตัวเลข | `1` | แสดงหลายเดือน (เรียงแนวนอนบนจอ 768px ขึ้นไป) |
|
|
51
|
+
| `disabled` | วันที่ / เงื่อนไข เช่น `{ before: date }` | – | วันที่เลือกไม่ได้ |
|
|
52
|
+
| `showOutsideDays` | `boolean` | `true` | แสดงวันของเดือนก่อน/ถัดไปแบบจาง |
|
|
53
|
+
| `showWeekNumber` | `boolean` | `false` | แสดงเลขสัปดาห์ |
|
|
54
|
+
| `buttonVariant` | variant ของ `Button` | `ghost` | หน้าตาปุ่มเลื่อนเดือน |
|
|
55
|
+
| `locale` | locale ของ react-day-picker | ไทย | เปลี่ยนภาษา (ปียังเป็น พ.ศ. จนกว่าจะเปลี่ยน `formatters`) |
|
|
56
|
+
|
|
57
|
+
### พฤติกรรมที่มีให้แล้ว
|
|
58
|
+
|
|
59
|
+
- คีย์บอร์ด: ลูกศรเลื่อนวัน Enter/Space เลือก ปุ่ม "เดือนก่อนหน้า" / "เดือนถัดไป"
|
|
60
|
+
- โปรแกรมอ่านหน้าจออ่านวันเต็ม เช่น "วันศุกร์ที่ 13 พฤศจิกายน พ.ศ. 2569, วันนี้, เลือกแล้ว"
|
|
61
|
+
- วันนี้มีพื้นเทา วันที่เลือกเป็นสีหลัก (ส้ม) ช่วงตรงกลางพื้นเทา
|
|
62
|
+
- ในการ์ดหรือกล่องลอย พื้นหลังของปฏิทินโปร่งใส
|
|
63
|
+
|
|
64
|
+
## Tokens used
|
|
65
|
+
|
|
66
|
+
ค่าทั้งหมดมาจาก `src/styles/theme.css`
|
|
67
|
+
|
|
68
|
+
### Component tokens
|
|
69
|
+
|
|
70
|
+
token เฉพาะของคอมโพเนนต์นี้ ชี้ไปที่ semantic token ด้านล่าง เปลี่ยนที่นี่เพื่อปรับเฉพาะคอมโพเนนต์นี้ (โหมดมืด "–" = ใช้ค่าเดียวกับโหมดสว่าง)
|
|
71
|
+
|
|
72
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
73
|
+
| ---------------------------- | ---------------------- | ------ | --------------------------------------------- |
|
|
74
|
+
| `--calendar-label-fg` | `--muted-foreground` | – | ชื่อวันในสัปดาห์, เลขสัปดาห์ |
|
|
75
|
+
| `--calendar-range-bg` | `--muted` | – | พื้นวันกลางช่วง |
|
|
76
|
+
| `--calendar-today-bg` | `--muted` | – | พื้นวันนี้ |
|
|
77
|
+
| `--calendar-day-selected-bg` | `--primary` | – | พื้นวันที่เลือก (และต้น/ปลายช่วง) |
|
|
78
|
+
| `--calendar-day-selected-fg` | `--primary-foreground` | – | ตัวอักษรวันที่เลือก |
|
|
79
|
+
| `--focus-ring` | `--ring` | – | วงแหวน focus จากคีย์บอร์ดของทุกคอมโพเนนต์ (ทึบ 2px) |
|
|
80
|
+
|
|
81
|
+
### Semantic tokens
|
|
82
|
+
|
|
83
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
84
|
+
| ---------------------- | --------------------------- | --------------------------- | ------------------------------------ |
|
|
85
|
+
| `--background` | `oklch(1 0 0)` | `oklch(0.153 0.006 107.1)` | พื้นปฏิทิน |
|
|
86
|
+
| `--primary` | `oklch(0.553 0.195 38.402)` | `oklch(0.705 0.187 47.604)` | วันที่เลือก, ต้นและท้ายช่วง |
|
|
87
|
+
| `--primary-foreground` | `oklch(0.98 0.016 73.684)` | `oklch(0.205 0.05 40)` | ตัวเลขวันที่เลือก |
|
|
88
|
+
| `--muted` | `oklch(0.966 0.005 106.5)` | `oklch(0.286 0.016 107.4)` | วันนี้, ตรงกลางช่วง |
|
|
89
|
+
| `--muted-foreground` | `oklch(0.5 0.027 107.3)` | `oklch(0.737 0.021 106.9)` | ชื่อวัน, วันนอกเดือน, วันที่เลือกไม่ได้ |
|
|
90
|
+
| `--ring` | `oklch(0.45 0.03 106.9)` | `oklch(0.8 0.02 106.9)` | วงแหวน focus ของวัน |
|
|
91
|
+
| `--radius` | `0.625rem` | – | มุมโค้งของวัน (`--radius × 2.6` = 26px) |
|
|
92
|
+
|
|
93
|
+
## Example
|
|
94
|
+
|
|
95
|
+
จาก story `Range` ใน `Calendar.stories.tsx`:
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
const [range, setRange] = useState<DateRange | undefined>({
|
|
99
|
+
from: new Date(2026, 9, 20),
|
|
100
|
+
to: new Date(2026, 10, 5),
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
<Calendar
|
|
104
|
+
mode="range"
|
|
105
|
+
numberOfMonths={2}
|
|
106
|
+
defaultMonth={new Date(2026, 9, 1)}
|
|
107
|
+
selected={range}
|
|
108
|
+
onSelect={setRange}
|
|
109
|
+
className="rounded-3xl border"
|
|
110
|
+
/>
|
|
111
|
+
```
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Card (การ์ด)
|
|
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 {
|
|
17
|
+
Card,
|
|
18
|
+
CardContent,
|
|
19
|
+
CardDescription,
|
|
20
|
+
CardHeader,
|
|
21
|
+
CardTitle,
|
|
22
|
+
} from "@designil/labdsnov"
|
|
23
|
+
|
|
24
|
+
;<Card>
|
|
25
|
+
<CardHeader>
|
|
26
|
+
<CardTitle>ยอดเงินในบัญชี</CardTitle>
|
|
27
|
+
<CardDescription>ณ วันที่ 13 พ.ย. 2569</CardDescription>
|
|
28
|
+
</CardHeader>
|
|
29
|
+
<CardContent>AU$84,215.37</CardContent>
|
|
30
|
+
</Card>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## When to use
|
|
34
|
+
|
|
35
|
+
- สรุปข้อมูลหนึ่งเรื่องบนหน้าแดชบอร์ด เช่น ยอดเงิน แผนการลงทุน ผู้รับผลประโยชน์
|
|
36
|
+
- กลุ่มเนื้อหาที่มีหัวข้อ เนื้อหา และปุ่มของตัวเอง
|
|
37
|
+
|
|
38
|
+
## When not to use
|
|
39
|
+
|
|
40
|
+
- **ตัวเลือกการลงทุน**: ใช้ `FundCard`
|
|
41
|
+
- **การ์ดที่กดเลือกได้**: ใช้การ์ดตัวเลือกของ `Field` (story `ChoiceCards`)
|
|
42
|
+
- **จัดระยะห่างอย่างเดียว ไม่มีความหมายว่าเป็นกลุ่ม**: ใช้ระยะห่างธรรมดา การ์ดซ้อนการ์ดทำให้หน้าดูหนัก
|
|
43
|
+
- **ข้อความแจ้งเตือน**: ใช้ `Alert`
|
|
44
|
+
|
|
45
|
+
## Anatomy
|
|
46
|
+
|
|
47
|
+
- **Card**
|
|
48
|
+
- **CardHeader** → **CardTitle** + **CardDescription** + **CardAction** (มุมขวาบน)
|
|
49
|
+
- **CardContent**
|
|
50
|
+
- **CardFooter**: ปุ่มด้านล่าง
|
|
51
|
+
|
|
52
|
+
## Props and variants
|
|
53
|
+
|
|
54
|
+
| Prop | ค่า | ค่าเริ่มต้น | ความหมาย |
|
|
55
|
+
| ----------- | --------------- | --------- | ----------------------------------------- |
|
|
56
|
+
| `size` | `default`, `sm` | `default` | ระยะขอบในและระยะห่างระหว่างส่วน: 24px / 16px |
|
|
57
|
+
| `className` | class | – | เช่น ความกว้าง |
|
|
58
|
+
|
|
59
|
+
- **CardTitle**: ตัวอักษรหัวข้อ 16px medium (`--font-heading`) เป็น `<div>` ไม่ใช่หัวข้อของหน้า TODO: ยังไม่ได้ตัดสินใจว่าควรให้เลือกระดับหัวข้อ (`h2`, `h3`) ได้หรือไม่
|
|
60
|
+
- **CardAction**: ปุ่มไอคอนหรือ `Badge` มุมขวาบนของหัวการ์ด ปุ่มไอคอนต้องมี `aria-label`
|
|
61
|
+
- ใส่ class `border-b` ที่ `CardHeader` หรือ `border-t` ที่ `CardFooter` เพื่อให้มีเส้นคั่นพร้อมระยะห่างที่ถูกต้อง
|
|
62
|
+
- รูปที่เป็นลูกตัวแรกของการ์ดจะชิดขอบบนและมุมโค้งตามการ์ด
|
|
63
|
+
|
|
64
|
+
## Tokens used
|
|
65
|
+
|
|
66
|
+
ค่าทั้งหมดมาจาก `src/styles/theme.css`
|
|
67
|
+
|
|
68
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
69
|
+
| -------------------- | -------------------------------- | -------------------------- | ------------------------------- |
|
|
70
|
+
| `--card` | `oklch(1 0 0)` | `oklch(0.228 0.013 107.4)` | พื้นการ์ด |
|
|
71
|
+
| `--card-foreground` | `oklch(0.153 0.006 107.1)` | `oklch(0.988 0.003 106.5)` | ตัวอักษร |
|
|
72
|
+
| `--muted-foreground` | `oklch(0.5 0.027 107.3)` | `oklch(0.737 0.021 106.9)` | คำอธิบาย |
|
|
73
|
+
| `--foreground` | `oklch(0.153 0.006 107.1)` | `oklch(0.988 0.003 106.5)` | เส้นขอบบาง ๆ (5% สว่าง, 10% มืด) |
|
|
74
|
+
| `--radius` | `0.625rem` | – | มุมโค้ง (`--radius × 2.6` = 26px) |
|
|
75
|
+
| `--font-heading` | กำหนดโดยแอป (IBM Plex Sans Thai) | – | หัวข้อการ์ด |
|
|
76
|
+
|
|
77
|
+
## Example
|
|
78
|
+
|
|
79
|
+
จาก story `Playground` ใน `Card.stories.tsx`:
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
<Card className="w-96">
|
|
83
|
+
<CardHeader>
|
|
84
|
+
<CardTitle>ยอดเงินในบัญชี</CardTitle>
|
|
85
|
+
<CardDescription>ณ วันที่ 13 พ.ย. 2569</CardDescription>
|
|
86
|
+
<CardAction>
|
|
87
|
+
<Badge variant="success">ใช้งานอยู่</Badge>
|
|
88
|
+
</CardAction>
|
|
89
|
+
</CardHeader>
|
|
90
|
+
<CardContent>
|
|
91
|
+
<p className="text-2xl font-semibold tabular-nums">AU$84,215.37</p>
|
|
92
|
+
<p className="text-muted-foreground">แผนสมดุล (Balanced)</p>
|
|
93
|
+
</CardContent>
|
|
94
|
+
<CardFooter className="gap-2">
|
|
95
|
+
<Button variant="outline">ดูธุรกรรม</Button>
|
|
96
|
+
<Button>เพิ่มเงินสมทบ</Button>
|
|
97
|
+
</CardFooter>
|
|
98
|
+
</Card>
|
|
99
|
+
```
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Chart (กราฟ)
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
กรอบสำหรับกราฟของ Recharts ที่ใส่สี ป้ายชื่อ tooltip และคำอธิบายสัญลักษณ์ตามระบบดีไซน์
|
|
6
|
+
|
|
7
|
+
## Import and usage
|
|
8
|
+
|
|
9
|
+
**ตั้งค่าครั้งเดียวในแอป** (ใช้ร่วมกันทุกคอมโพเนนต์):
|
|
10
|
+
|
|
11
|
+
1. ติดตั้ง `@designil/labdsnov` (`pnpm add @designil/labdsnov`) พร้อม `react` และ `react-dom` 19
|
|
12
|
+
2. import สไตล์ครั้งเดียวที่ root layout: `import "@designil/labdsnov/styles.css"`
|
|
13
|
+
3. กำหนดตัวแปร `--font-heading` (แอปใช้ IBM Plex Sans Thai) และใส่ class `dark` ที่ `<html>` เมื่อต้องการโหมดมืด
|
|
14
|
+
|
|
15
|
+
ใช้ไลบรารี `recharts` (ติดตั้งมากับ `@designil/labdsnov` แล้ว) และ import ชนิดกราฟจาก `recharts` เอง
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
"use client"
|
|
19
|
+
|
|
20
|
+
import { Bar, BarChart, XAxis } from "recharts"
|
|
21
|
+
import { ChartContainer, ChartTooltip, ChartTooltipContent, type ChartConfig } from "@designil/labdsnov"
|
|
22
|
+
|
|
23
|
+
const config = {
|
|
24
|
+
employer: { label: "เงินสมทบจากนายจ้าง", color: "var(--chart-3)" },
|
|
25
|
+
} satisfies ChartConfig
|
|
26
|
+
|
|
27
|
+
<ChartContainer config={config} role="img" aria-label="เงินสมทบรายเดือน มิถุนายน ถึง พฤศจิกายน 2569">
|
|
28
|
+
<BarChart accessibilityLayer data={data}>
|
|
29
|
+
<XAxis dataKey="month" />
|
|
30
|
+
<ChartTooltip content={<ChartTooltipContent />} />
|
|
31
|
+
<Bar dataKey="employer" fill="var(--color-employer)" />
|
|
32
|
+
</BarChart>
|
|
33
|
+
</ChartContainer>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
- **`config`**: แต่ละ key ของข้อมูลมี `label` (ภาษาไทย) และ `color` สีจะกลายเป็น `var(--color-<key>)` ให้ใช้ใน `fill` / `stroke`
|
|
37
|
+
- ใช้ token สีกราฟ (`--chart-1` ถึง `--chart-5`) หรือ token อื่น เพื่อให้โหมดมืดเปลี่ยนตามเอง (หรือใช้ `theme: { light, dark }`)
|
|
38
|
+
- **การเข้าถึง**: ใส่ `role="img"` และ `aria-label` ที่สรุปกราฟ และ `accessibilityLayer` ให้ Recharts ใช้คีย์บอร์ดดูข้อมูลได้ TODO: ข้อมูลสำคัญควรมีตารางหรือข้อความให้อ่านด้วย ยังไม่ได้ตัดสินใจรูปแบบ
|
|
39
|
+
|
|
40
|
+
## When to use
|
|
41
|
+
|
|
42
|
+
- แนวโน้มตามเวลา เช่น ยอดเงินรายเดือน (กราฟพื้นที่หรือเส้น)
|
|
43
|
+
- เปรียบเทียบจำนวน เช่น เงินสมทบแยกตามแหล่ง (กราฟแท่ง)
|
|
44
|
+
|
|
45
|
+
## When not to use
|
|
46
|
+
|
|
47
|
+
- **ตัวเลขเดียว**: แสดงตัวเลขใน `Card`
|
|
48
|
+
- **สัดส่วนของเป้าหมายเดียว**: ใช้ `Progress`
|
|
49
|
+
- **ค่าที่ต้องอ่านแม่นยำ**: ใช้ `Table`
|
|
50
|
+
|
|
51
|
+
## Props and variants
|
|
52
|
+
|
|
53
|
+
### ChartContainer
|
|
54
|
+
|
|
55
|
+
| Prop | ค่า | ความหมาย |
|
|
56
|
+
| ------------------ | ------------------- | --------------------------------- |
|
|
57
|
+
| `config` | `ChartConfig` | **บังคับ** ป้ายชื่อและสีของแต่ละ key |
|
|
58
|
+
| `className` | class | ขนาด ปกติอัตราส่วน 16:9 กว้างเต็มพื้นที่ |
|
|
59
|
+
| `initialDimension` | `{ width, height }` | ขนาดก่อนวัดพื้นที่จริง (ค่าเริ่มต้น 320×200) |
|
|
60
|
+
|
|
61
|
+
### ChartTooltipContent
|
|
62
|
+
|
|
63
|
+
| Prop | ค่า | ค่าเริ่มต้น | ความหมาย |
|
|
64
|
+
| --------------- | ----------------------- | ------- | --------------------------- |
|
|
65
|
+
| `indicator` | `dot`, `line`, `dashed` | `dot` | สัญลักษณ์สีหน้าแต่ละค่า |
|
|
66
|
+
| `hideLabel` | `boolean` | `false` | ซ่อนหัวข้อ (เช่น ชื่อเดือน) |
|
|
67
|
+
| `hideIndicator` | `boolean` | `false` | ซ่อนสัญลักษณ์สี |
|
|
68
|
+
| `formatter` | ฟังก์ชัน | – | จัดรูปแบบค่าเอง เช่น สกุลเงิน AUD |
|
|
69
|
+
|
|
70
|
+
ตัวเลขใน tooltip ใช้รูปแบบภาษาไทย (`toLocaleString("th-TH")`) TODO: ยังไม่ได้แสดงสกุลเงินให้อัตโนมัติ ใช้ `formatter`
|
|
71
|
+
|
|
72
|
+
### ChartLegendContent
|
|
73
|
+
|
|
74
|
+
คำอธิบายสัญลักษณ์จาก `config` ใช้กับ `<ChartLegend content={<ChartLegendContent />} />` (`hideIcon` ซ่อนไอคอน)
|
|
75
|
+
|
|
76
|
+
## Tokens used
|
|
77
|
+
|
|
78
|
+
ค่าทั้งหมดมาจาก `src/styles/theme.css`
|
|
79
|
+
|
|
80
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
81
|
+
| ---------------------- | --------------------------- | --------------------------- | -------------------------- |
|
|
82
|
+
| `--chart-1` | `oklch(0.553 0.195 38.402)` | `oklch(0.705 0.187 47.604)` | สีกราฟชุดที่ 1: ส้ม (สีหลัก) |
|
|
83
|
+
| `--chart-2` | `oklch(0.52 0.1 190)` | `oklch(0.72 0.11 190)` | สีกราฟชุดที่ 2: เขียวอมฟ้า |
|
|
84
|
+
| `--chart-3` | `oklch(0.5 0.17 262)` | `oklch(0.7 0.14 262)` | สีกราฟชุดที่ 3: น้ำเงิน |
|
|
85
|
+
| `--chart-4` | `oklch(0.52 0.19 330)` | `oklch(0.72 0.17 330)` | สีกราฟชุดที่ 4: ชมพูม่วง |
|
|
86
|
+
| `--chart-5` | `oklch(0.55 0.15 135)` | `oklch(0.78 0.17 135)` | สีกราฟชุดที่ 5: เขียว |
|
|
87
|
+
| `--muted-foreground` | `oklch(0.5 0.027 107.3)` | `oklch(0.737 0.021 106.9)` | ตัวอักษรแกน, ชื่อใน tooltip |
|
|
88
|
+
| `--border` | `oklch(0.93 0.007 106.5)` | `oklch(1 0 0 / 10%)` | เส้นตาราง (50%), เส้น cursor |
|
|
89
|
+
| `--muted` | `oklch(0.966 0.005 106.5)` | `oklch(0.286 0.016 107.4)` | cursor ของกราฟแท่ง |
|
|
90
|
+
| `--popover` | `oklch(1 0 0)` | `oklch(0.228 0.013 107.4)` | พื้น tooltip |
|
|
91
|
+
| `--popover-foreground` | `oklch(0.153 0.006 107.1)` | `oklch(0.988 0.003 106.5)` | ตัวอักษร tooltip |
|
|
92
|
+
|
|
93
|
+
`--chart-1` ถึง `--chart-5` เป็นสีต่างโทนกัน (ส้มสีหลัก, เขียวอมฟ้า, น้ำเงิน, ชมพูม่วง, เขียว) แต่ละสีมี contrast อย่างน้อย 3:1 กับพื้นหน้าและพื้น `Card` ทั้งสองโหมด ใช้ตามลำดับ TODO: ยังไม่ได้ตรวจว่าแยกสีได้สำหรับผู้ที่มองเห็นสีผิดปกติ ควรมีป้ายชื่อหรือ legend เสมอ
|
|
94
|
+
|
|
95
|
+
## Example
|
|
96
|
+
|
|
97
|
+
จาก story `BalanceArea` ใน `Chart.stories.tsx`:
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
const balanceConfig = {
|
|
101
|
+
balance: { label: "ยอดเงิน (AUD)", color: "var(--primary)" },
|
|
102
|
+
} satisfies ChartConfig
|
|
103
|
+
|
|
104
|
+
<ChartContainer config={balanceConfig} role="img" aria-label="ยอดเงินในบัญชี มิถุนายน ถึง พฤศจิกายน 2569">
|
|
105
|
+
<AreaChart accessibilityLayer data={balance}>
|
|
106
|
+
<CartesianGrid vertical={false} />
|
|
107
|
+
<XAxis dataKey="month" tickLine={false} axisLine={false} tickMargin={8} />
|
|
108
|
+
<ChartTooltip content={<ChartTooltipContent indicator="line" />} />
|
|
109
|
+
<Area dataKey="balance" type="natural" fill="var(--color-balance)" fillOpacity={0.2} stroke="var(--color-balance)" />
|
|
110
|
+
</AreaChart>
|
|
111
|
+
</ChartContainer>
|
|
112
|
+
```
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Checkbox (ช่องทำเครื่องหมาย)
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
ช่องเลือกเปิด/ปิดหนึ่งข้อ หรือเลือกได้หลายข้อจากรายการ
|
|
6
|
+
|
|
7
|
+
## Import and usage
|
|
8
|
+
|
|
9
|
+
**ตั้งค่าครั้งเดียวในแอป** (ใช้ร่วมกันทุกคอมโพเนนต์):
|
|
10
|
+
|
|
11
|
+
1. ติดตั้ง `@designil/labdsnov` (`pnpm add @designil/labdsnov`) พร้อม `react` และ `react-dom` 19
|
|
12
|
+
2. import สไตล์ครั้งเดียวที่ root layout: `import "@designil/labdsnov/styles.css"`
|
|
13
|
+
3. กำหนดตัวแปร `--font-heading` (แอปใช้ IBM Plex Sans Thai) และใส่ class `dark` ที่ `<html>` เมื่อต้องการโหมดมืด
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { Checkbox, Label } from "@designil/labdsnov"
|
|
17
|
+
|
|
18
|
+
;<div className="flex items-center gap-2">
|
|
19
|
+
<Checkbox id="terms" />
|
|
20
|
+
<Label htmlFor="terms">ยอมรับข้อกำหนดและเงื่อนไข</Label>
|
|
21
|
+
</div>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
- ผูกกับ `Label` ด้วย `id` / `htmlFor` เสมอ คลิกที่ข้อความแล้วติ๊กได้
|
|
25
|
+
- ในฟอร์ม ใช้คู่กับ `Field orientation="horizontal"` (ดู [Field](../Field/Field.md))
|
|
26
|
+
|
|
27
|
+
## When to use
|
|
28
|
+
|
|
29
|
+
- ยอมรับเงื่อนไข หรือยืนยันข้อความหนึ่งข้อ ที่มีผลเมื่อกดส่งฟอร์ม
|
|
30
|
+
- เลือกได้หลายข้อจากรายการ เช่น ช่องทางที่ต้องการรับเอกสาร
|
|
31
|
+
- "เลือกทั้งหมด" ที่เลือกไว้บางรายการ: ใช้สถานะ `indeterminate` (ขีดแทนเครื่องหมายถูก)
|
|
32
|
+
|
|
33
|
+
## When not to use
|
|
34
|
+
|
|
35
|
+
| สถานการณ์ | ใช้แทน |
|
|
36
|
+
| ---------------------------- | ------------ |
|
|
37
|
+
| เลือกได้ข้อเดียวจากหลายข้อ | `RadioGroup` |
|
|
38
|
+
| การตั้งค่าที่มีผลทันทีโดยไม่ต้องกดบันทึก | `Switch` |
|
|
39
|
+
| การกระทำ เช่น "ลบรายการที่เลือก" | `Button` |
|
|
40
|
+
|
|
41
|
+
## Props and variants
|
|
42
|
+
|
|
43
|
+
ไม่มี variant หรือ size กล่องขนาด 16px แต่พื้นที่กดกว้างกว่ากล่องเล็กน้อย
|
|
44
|
+
|
|
45
|
+
| Prop | ค่า | ค่าเริ่มต้น | ความหมาย |
|
|
46
|
+
| ----------------------------- | ----------------- | ------- | ------------------------------------- |
|
|
47
|
+
| `checked` / `onCheckedChange` | `boolean` / ฟังก์ชัน | – | ควบคุมจากภายนอก |
|
|
48
|
+
| `defaultChecked` | `boolean` | `false` | ติ๊กไว้ตั้งแต่แรก |
|
|
49
|
+
| `indeterminate` | `boolean` | `false` | เลือกไว้บางส่วน แสดงขีดแทนเครื่องหมายถูก |
|
|
50
|
+
| `disabled` | `boolean` | `false` | ปิดใช้งาน จางลง 50% |
|
|
51
|
+
| `required` | `boolean` | `false` | ต้องติ๊กก่อนส่งฟอร์ม |
|
|
52
|
+
| `name` / `value` | ข้อความ | – | ชื่อและค่าที่ส่งไปกับฟอร์ม |
|
|
53
|
+
| `aria-invalid` | `boolean` | – | ข้อมูลไม่ถูกต้อง เส้นขอบสีแดงและวงแหวนแดงจาง |
|
|
54
|
+
| `className` | class | – | ปรับหน้าตาเฉพาะจุดครั้งเดียว |
|
|
55
|
+
|
|
56
|
+
### States
|
|
57
|
+
|
|
58
|
+
- **ไม่ได้ติ๊ก**: กล่องมีเส้นขอบ (contrast 3:1)
|
|
59
|
+
- **ติ๊กแล้ว / บางส่วน**: กล่องสีหลัก (ส้ม) เครื่องหมายสีอ่อน
|
|
60
|
+
- **Focus จากคีย์บอร์ด**: วงแหวนทึบสี `--focus-ring` กด Space เพื่อติ๊ก
|
|
61
|
+
|
|
62
|
+
## Tokens used
|
|
63
|
+
|
|
64
|
+
ค่าทั้งหมดมาจาก `src/styles/theme.css`
|
|
65
|
+
|
|
66
|
+
### Component tokens
|
|
67
|
+
|
|
68
|
+
token เฉพาะของคอมโพเนนต์นี้ ชี้ไปที่ semantic token ด้านล่าง เปลี่ยนที่นี่เพื่อปรับเฉพาะคอมโพเนนต์นี้ (โหมดมืด "–" = ใช้ค่าเดียวกับโหมดสว่าง)
|
|
69
|
+
|
|
70
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
71
|
+
| ---------------------- | ---------------------- | ------------------- | ----------------------------------------------- |
|
|
72
|
+
| `--control-bg` | `--background` | `--input` 50% | พื้นตอนยังไม่เลือก |
|
|
73
|
+
| `--control-checked-bg` | `--primary` | – | พื้นและเส้นขอบตอนเลือก |
|
|
74
|
+
| `--control-checked-fg` | `--primary-foreground` | – | เครื่องหมายถูก / จุด ตอนเลือก |
|
|
75
|
+
| `--focus-ring` | `--ring` | – | วงแหวน focus จากคีย์บอร์ดของทุกคอมโพเนนต์ (ทึบ 2px) |
|
|
76
|
+
| `--invalid-border` | `--destructive` | – | เส้นขอบเมื่อข้อมูลไม่ถูกต้อง และวงแหวน focus ขณะไม่ถูกต้อง |
|
|
77
|
+
| `--invalid-ring` | `--destructive` 20% | `--destructive` 40% | วงแหวนจางรอบช่องที่ไม่ถูกต้อง (ตกแต่ง) |
|
|
78
|
+
|
|
79
|
+
### Semantic tokens
|
|
80
|
+
|
|
81
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
82
|
+
| ---------------------- | --------------------------- | --------------------------- | --------------------------- |
|
|
83
|
+
| `--input` | `oklch(0.93 0.007 106.5)` | `oklch(1 0 0 / 15%)` | พื้นกล่องที่ไม่ได้ติ๊ก (90%) |
|
|
84
|
+
| `--primary` | `oklch(0.553 0.195 38.402)` | `oklch(0.705 0.187 47.604)` | พื้นและเส้นขอบเมื่อติ๊ก |
|
|
85
|
+
| `--primary-foreground` | `oklch(0.98 0.016 73.684)` | `oklch(0.205 0.05 40)` | เครื่องหมายถูกและขีด |
|
|
86
|
+
| `--ring` | `oklch(0.45 0.03 106.9)` | `oklch(0.8 0.02 106.9)` | วงแหวน focus |
|
|
87
|
+
| `--destructive` | `oklch(0.505 0.2 27.325)` | `oklch(0.75 0.16 22.216)` | สถานะไม่ถูกต้อง |
|
|
88
|
+
| `--background` | `oklch(1 0 0)` | `oklch(0.153 0.006 107.1)` | ผ่าน token ของคอมโพเนนต์ด้านบน |
|
|
89
|
+
|
|
90
|
+
## Example
|
|
91
|
+
|
|
92
|
+
จาก story `States` ใน `Checkbox.stories.tsx` (บางส่วน):
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
<div className="grid gap-3">
|
|
96
|
+
<div className="flex items-center gap-2">
|
|
97
|
+
<Checkbox id="cb-on" defaultChecked />
|
|
98
|
+
<Label htmlFor="cb-on">เลือกแล้ว</Label>
|
|
99
|
+
</div>
|
|
100
|
+
<div className="flex items-center gap-2">
|
|
101
|
+
<Checkbox id="cb-some" indeterminate />
|
|
102
|
+
<Label htmlFor="cb-some">เลือกบางรายการ</Label>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
```
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Collapsible (ส่วนพับได้)
|
|
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 {
|
|
17
|
+
Button,
|
|
18
|
+
Collapsible,
|
|
19
|
+
CollapsibleContent,
|
|
20
|
+
CollapsibleTrigger,
|
|
21
|
+
} from "@designil/labdsnov"
|
|
22
|
+
|
|
23
|
+
;<Collapsible>
|
|
24
|
+
<CollapsibleTrigger render={<Button variant="ghost" size="sm" />}>
|
|
25
|
+
ดูรายละเอียด
|
|
26
|
+
</CollapsibleTrigger>
|
|
27
|
+
<CollapsibleContent>…</CollapsibleContent>
|
|
28
|
+
</Collapsible>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
- ปุ่มไม่มีหน้าตาของตัวเอง ใช้ `render={<Button … />}`
|
|
32
|
+
- ข้อความบนปุ่มบอกว่าจะเห็นอะไร เช่น "ดูรายละเอียด" ปุ่มบอกสถานะเปิด/ปิดผ่าน `aria-expanded` เอง
|
|
33
|
+
- ไอคอนลูกศรหมุนได้ด้วย `[&[data-panel-open]_svg]:rotate-180` บนปุ่ม (ดู story)
|
|
34
|
+
|
|
35
|
+
## When to use
|
|
36
|
+
|
|
37
|
+
- รายละเอียดเสริมที่คนส่วนใหญ่ไม่ต้องอ่าน เช่น การคำนวณค่าธรรมเนียม
|
|
38
|
+
- ตัวเลือกขั้นสูงในฟอร์ม
|
|
39
|
+
|
|
40
|
+
## When not to use
|
|
41
|
+
|
|
42
|
+
| สถานการณ์ | ใช้แทน |
|
|
43
|
+
| ----------------------------- | ------------ |
|
|
44
|
+
| หลายส่วนเรียงกัน เช่น คำถามที่พบบ่อย | `Accordion` |
|
|
45
|
+
| ข้อมูลที่ผู้ใช้ต้องเห็นเพื่อตัดสินใจ | แสดงในหน้าเลย |
|
|
46
|
+
| เนื้อหาลอยทับหน้า | `Popover` |
|
|
47
|
+
|
|
48
|
+
## Props and variants
|
|
49
|
+
|
|
50
|
+
ไม่มี variant หรือ size
|
|
51
|
+
|
|
52
|
+
| Prop | ใช้กับ | ความหมาย |
|
|
53
|
+
| ----------------------- | -------------------- | ------------------------------------------------------------------- |
|
|
54
|
+
| `open` / `onOpenChange` | `Collapsible` | ควบคุมการเปิดจากภายนอก |
|
|
55
|
+
| `defaultOpen` | `Collapsible` | เปิดไว้ตั้งแต่แรก |
|
|
56
|
+
| `disabled` | `Collapsible` | ปิดใช้งานปุ่ม |
|
|
57
|
+
| `keepMounted` | `CollapsibleContent` | เก็บเนื้อหาไว้ในหน้าตอนปิด (ค้นหาด้วย Ctrl+F ได้เมื่อใช้คู่กับ `hiddenUntilFound`) |
|
|
58
|
+
|
|
59
|
+
- ความสูงของเนื้อหาเลื่อนเปิด/ปิดใน 200ms
|
|
60
|
+
- **คีย์บอร์ด**: Tab ไปที่ปุ่ม Enter หรือ Space เพื่อเปิด/ปิด
|
|
61
|
+
|
|
62
|
+
## Tokens used
|
|
63
|
+
|
|
64
|
+
ไม่มีสีของตัวเอง สีมาจาก `Button` ที่ใช้เป็นปุ่ม และเนื้อหาที่ใส่
|
|
65
|
+
|
|
66
|
+
## Example
|
|
67
|
+
|
|
68
|
+
จาก story `Playground` ใน `Collapsible.stories.tsx`:
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
<Collapsible className="w-80">
|
|
72
|
+
<div className="flex items-center justify-between gap-2">
|
|
73
|
+
<p className="text-sm font-medium">ค่าธรรมเนียมรายปี 0.85%</p>
|
|
74
|
+
<CollapsibleTrigger render={<Button variant="ghost" size="sm" />}>
|
|
75
|
+
ดูรายละเอียด
|
|
76
|
+
</CollapsibleTrigger>
|
|
77
|
+
</div>
|
|
78
|
+
<CollapsibleContent>
|
|
79
|
+
<ul className="mt-2 grid gap-1 rounded-2xl bg-muted p-3 text-sm">
|
|
80
|
+
<li>ค่าบริหารกองทุน 0.60%</li>
|
|
81
|
+
<li>ค่าดูแลบัญชี 0.20%</li>
|
|
82
|
+
<li>ค่าประกันภัย 0.05%</li>
|
|
83
|
+
</ul>
|
|
84
|
+
</CollapsibleContent>
|
|
85
|
+
</Collapsible>
|
|
86
|
+
```
|