@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,115 @@
|
|
|
1
|
+
# Pagination (การแบ่งหน้า)
|
|
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
|
+
Pagination,
|
|
18
|
+
PaginationContent,
|
|
19
|
+
PaginationEllipsis,
|
|
20
|
+
PaginationItem,
|
|
21
|
+
PaginationLink,
|
|
22
|
+
PaginationNext,
|
|
23
|
+
PaginationPrevious,
|
|
24
|
+
} from "@designil/labdsnov"
|
|
25
|
+
|
|
26
|
+
;<Pagination>
|
|
27
|
+
<PaginationContent>
|
|
28
|
+
<PaginationItem>
|
|
29
|
+
<PaginationPrevious href="?page=1" />
|
|
30
|
+
</PaginationItem>
|
|
31
|
+
<PaginationItem>
|
|
32
|
+
<PaginationLink href="?page=2" isActive>
|
|
33
|
+
2
|
|
34
|
+
</PaginationLink>
|
|
35
|
+
</PaginationItem>
|
|
36
|
+
<PaginationItem>
|
|
37
|
+
<PaginationNext href="?page=3" />
|
|
38
|
+
</PaginationItem>
|
|
39
|
+
</PaginationContent>
|
|
40
|
+
</Pagination>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
- ทุกหน้ามี URL ของตัวเอง (`href`) ผู้ใช้กดย้อนกลับหรือแชร์ลิงก์ได้
|
|
44
|
+
- คำนวณว่าแสดงเลขหน้าไหนเองในแอป Pagination เป็นแค่หน้าตา
|
|
45
|
+
|
|
46
|
+
## When to use
|
|
47
|
+
|
|
48
|
+
- รายการที่ยาวเกินจะแสดงในหน้าเดียว และผู้ใช้อาจต้องกลับไปหน้าเดิม เช่น ตารางธุรกรรม
|
|
49
|
+
|
|
50
|
+
## When not to use
|
|
51
|
+
|
|
52
|
+
- **รายการสั้น** (ไม่เกินประมาณ 25 แถว): แสดงทั้งหมด
|
|
53
|
+
- **ฟีดที่อ่านต่อเนื่อง**: TODO: ยังไม่ได้ตัดสินใจว่าจะใช้ปุ่ม "โหลดเพิ่ม" หรือไม่
|
|
54
|
+
- **ขั้นตอนของฟอร์ม**: ใช้ปุ่ม "ถัดไป" / "ย้อนกลับ" (`Button`)
|
|
55
|
+
|
|
56
|
+
## Props and variants
|
|
57
|
+
|
|
58
|
+
| ส่วน / Prop | ความหมาย |
|
|
59
|
+
| --------------------------------------- | ---------------------------------------------------------------------------------- |
|
|
60
|
+
| `Pagination` | `<nav>` ชื่อ "การแบ่งหน้า" สำหรับโปรแกรมอ่านหน้าจอ อยู่กึ่งกลาง |
|
|
61
|
+
| `PaginationLink` `href` | ลิงก์ไปหน้านั้น หน้าตาเหมือนปุ่ม ghost ขนาด `icon` (36px) |
|
|
62
|
+
| `PaginationLink` `isActive` | หน้าปัจจุบัน: ปุ่ม outline และ `aria-current="page"` |
|
|
63
|
+
| `PaginationLink` `size` | ขนาดปุ่ม (ค่าของ `Button`) ค่าเริ่มต้น `icon` |
|
|
64
|
+
| `PaginationPrevious` / `PaginationNext` | ลิงก์ "ก่อนหน้า" / "ถัดไป" พร้อมลูกศร บนจอแคบกว่า 640px เหลือแค่ลูกศร เปลี่ยนข้อความได้ด้วย `text` |
|
|
65
|
+
| `PaginationEllipsis` | "…" ระหว่างเลขหน้า |
|
|
66
|
+
|
|
67
|
+
- TODO: ลิงก์ "ก่อนหน้า" ในหน้าแรก (และ "ถัดไป" ในหน้าสุดท้าย) ยังไม่มีสถานะปิดใช้งาน ซ่อนเองในแอป
|
|
68
|
+
- ต่างจาก shadcn: ลิงก์เป็น `<a>` ธรรมดาที่แต่งเหมือนปุ่ม โปรแกรมอ่านหน้าจอจึงอ่านว่าเป็นลิงก์ (ของ shadcn ถูกอ่านว่าเป็นปุ่ม)
|
|
69
|
+
|
|
70
|
+
## Tokens used
|
|
71
|
+
|
|
72
|
+
ใช้ token ของ `Button` (variant `ghost` และ `outline`)
|
|
73
|
+
|
|
74
|
+
ค่าทั้งหมดมาจาก `src/styles/theme.css`
|
|
75
|
+
|
|
76
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
77
|
+
| -------------- | -------------------------- | -------------------------- | -------------- |
|
|
78
|
+
| `--muted` | `oklch(0.966 0.005 106.5)` | `oklch(0.286 0.016 107.4)` | hover ของลิงก์ |
|
|
79
|
+
| `--border` | `oklch(0.93 0.007 106.5)` | `oklch(1 0 0 / 10%)` | เส้นขอบหน้าปัจจุบัน |
|
|
80
|
+
| `--background` | `oklch(1 0 0)` | `oklch(0.153 0.006 107.1)` | พื้นหน้าปัจจุบัน |
|
|
81
|
+
| `--ring` | `oklch(0.45 0.03 106.9)` | `oklch(0.8 0.02 106.9)` | วงแหวน focus |
|
|
82
|
+
|
|
83
|
+
## Example
|
|
84
|
+
|
|
85
|
+
จาก story `Playground` ใน `Pagination.stories.tsx`:
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
<Pagination>
|
|
89
|
+
<PaginationContent>
|
|
90
|
+
<PaginationItem>
|
|
91
|
+
<PaginationPrevious href="#page-1" />
|
|
92
|
+
</PaginationItem>
|
|
93
|
+
<PaginationItem>
|
|
94
|
+
<PaginationLink href="#page-1">1</PaginationLink>
|
|
95
|
+
</PaginationItem>
|
|
96
|
+
<PaginationItem>
|
|
97
|
+
<PaginationLink href="#page-2" isActive>
|
|
98
|
+
2
|
|
99
|
+
</PaginationLink>
|
|
100
|
+
</PaginationItem>
|
|
101
|
+
<PaginationItem>
|
|
102
|
+
<PaginationLink href="#page-3">3</PaginationLink>
|
|
103
|
+
</PaginationItem>
|
|
104
|
+
<PaginationItem>
|
|
105
|
+
<PaginationEllipsis />
|
|
106
|
+
</PaginationItem>
|
|
107
|
+
<PaginationItem>
|
|
108
|
+
<PaginationLink href="#page-12">12</PaginationLink>
|
|
109
|
+
</PaginationItem>
|
|
110
|
+
<PaginationItem>
|
|
111
|
+
<PaginationNext href="#page-3" />
|
|
112
|
+
</PaginationItem>
|
|
113
|
+
</PaginationContent>
|
|
114
|
+
</Pagination>
|
|
115
|
+
```
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Popover (กล่องลอย)
|
|
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
|
+
Popover,
|
|
19
|
+
PopoverContent,
|
|
20
|
+
PopoverDescription,
|
|
21
|
+
PopoverHeader,
|
|
22
|
+
PopoverTitle,
|
|
23
|
+
PopoverTrigger,
|
|
24
|
+
} from "@designil/labdsnov"
|
|
25
|
+
|
|
26
|
+
;<Popover>
|
|
27
|
+
<PopoverTrigger render={<Button variant="outline" />}>
|
|
28
|
+
ตั้งเป้าหมายการออม
|
|
29
|
+
</PopoverTrigger>
|
|
30
|
+
<PopoverContent>
|
|
31
|
+
<PopoverHeader>
|
|
32
|
+
<PopoverTitle>เป้าหมายการออม</PopoverTitle>
|
|
33
|
+
<PopoverDescription>ยอดเงินที่อยากมีเมื่อเกษียณ</PopoverDescription>
|
|
34
|
+
</PopoverHeader>
|
|
35
|
+
…
|
|
36
|
+
</PopoverContent>
|
|
37
|
+
</Popover>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
- ใส่ `PopoverTitle` เสมอ เป็นชื่อของกล่องสำหรับโปรแกรมอ่านหน้าจอ
|
|
41
|
+
|
|
42
|
+
## When to use
|
|
43
|
+
|
|
44
|
+
- รายละเอียดเพิ่มเติมหรือการตั้งค่าเล็ก ๆ ที่เกี่ยวกับปุ่มนั้น เช่น ตั้งเป้าหมาย ตัวกรองของตาราง
|
|
45
|
+
- คำอธิบายที่มีลิงก์หรือยาวเกิน `Tooltip`
|
|
46
|
+
|
|
47
|
+
## When not to use
|
|
48
|
+
|
|
49
|
+
| สถานการณ์ | ใช้แทน |
|
|
50
|
+
| ----------------------------------- | -------------- |
|
|
51
|
+
| คำอธิบายสั้นบรรทัดเดียว | `Tooltip` |
|
|
52
|
+
| รายการคำสั่ง (แก้ไข / ลบ) | `DropdownMenu` |
|
|
53
|
+
| เลือกค่าจากรายการ | `Select` |
|
|
54
|
+
| ยืนยันการตัดสินใจหรือฟอร์มที่ต้องทำให้เสร็จก่อน | `Dialog` |
|
|
55
|
+
|
|
56
|
+
## Props and variants
|
|
57
|
+
|
|
58
|
+
### PopoverContent
|
|
59
|
+
|
|
60
|
+
| Prop | ค่า | ค่าเริ่มต้น | ความหมาย |
|
|
61
|
+
| ------------ | -------------------------------- | -------- | ------------------------ |
|
|
62
|
+
| `side` | `top`, `right`, `bottom`, `left` | `bottom` | ด้านที่ลอยออกจาก trigger |
|
|
63
|
+
| `align` | `start`, `center`, `end` | `center` | การจัดแนวตาม trigger |
|
|
64
|
+
| `sideOffset` | ตัวเลข (px) | `4` | ระยะห่างจาก trigger |
|
|
65
|
+
| `className` | class | – | เช่น ความกว้าง (ปกติ 288px) |
|
|
66
|
+
|
|
67
|
+
### Popover
|
|
68
|
+
|
|
69
|
+
| Prop | ค่า | ค่าเริ่มต้น | ความหมาย |
|
|
70
|
+
| ----------------------- | ----------------- | ------- | -------------------- |
|
|
71
|
+
| `open` / `onOpenChange` | `boolean` / ฟังก์ชัน | – | ควบคุมการเปิดจากภายนอก |
|
|
72
|
+
| `defaultOpen` | `boolean` | `false` | เปิดไว้ตั้งแต่แรก |
|
|
73
|
+
|
|
74
|
+
### พฤติกรรมที่มีให้แล้ว
|
|
75
|
+
|
|
76
|
+
- คลิก trigger เพื่อเปิด/ปิด กด Escape หรือคลิกนอกกล่องเพื่อปิด แล้วโฟกัสกลับไปที่ trigger
|
|
77
|
+
- หน้าตาเหมือนกล่องของ `Dialog` (พื้น popover มุมโค้ง เงา) ระยะขอบใน 16px
|
|
78
|
+
|
|
79
|
+
## Tokens used
|
|
80
|
+
|
|
81
|
+
ค่าทั้งหมดมาจาก `src/styles/theme.css`
|
|
82
|
+
|
|
83
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
84
|
+
| ---------------------- | -------------------------- | -------------------------- | ------------------------------- |
|
|
85
|
+
| `--popover` | `oklch(1 0 0)` | `oklch(0.228 0.013 107.4)` | พื้นกล่อง |
|
|
86
|
+
| `--popover-foreground` | `oklch(0.153 0.006 107.1)` | `oklch(0.988 0.003 106.5)` | ตัวอักษร |
|
|
87
|
+
| `--muted-foreground` | `oklch(0.5 0.027 107.3)` | `oklch(0.737 0.021 106.9)` | คำอธิบาย |
|
|
88
|
+
| `--foreground` | `oklch(0.153 0.006 107.1)` | `oklch(0.988 0.003 106.5)` | เส้นขอบบาง ๆ (5% สว่าง, 10% มืด) |
|
|
89
|
+
| `--radius` | `0.625rem` | – | มุมโค้ง (`--radius × 2.2` = 22px) |
|
|
90
|
+
|
|
91
|
+
## Example
|
|
92
|
+
|
|
93
|
+
จาก story `Playground` ใน `Popover.stories.tsx`:
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
<Popover>
|
|
97
|
+
<PopoverTrigger render={<Button variant="outline" />}>
|
|
98
|
+
ตั้งเป้าหมายการออม
|
|
99
|
+
</PopoverTrigger>
|
|
100
|
+
<PopoverContent>
|
|
101
|
+
<PopoverHeader>
|
|
102
|
+
<PopoverTitle>เป้าหมายการออม</PopoverTitle>
|
|
103
|
+
<PopoverDescription>ยอดเงินที่อยากมีเมื่อเกษียณ</PopoverDescription>
|
|
104
|
+
</PopoverHeader>
|
|
105
|
+
<div className="grid gap-2">
|
|
106
|
+
<Label htmlFor="popover-goal">จำนวนเงิน (AUD)</Label>
|
|
107
|
+
<Input id="popover-goal" type="number" defaultValue={500000} />
|
|
108
|
+
</div>
|
|
109
|
+
</PopoverContent>
|
|
110
|
+
</Popover>
|
|
111
|
+
```
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Progress (แถบความคืบหน้า)
|
|
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 { Progress, ProgressLabel, ProgressValue } from "@designil/labdsnov"
|
|
17
|
+
|
|
18
|
+
;<Progress value={62}>
|
|
19
|
+
<ProgressLabel>เงินสมทบปีนี้เทียบกับเพดาน</ProgressLabel>
|
|
20
|
+
<ProgressValue />
|
|
21
|
+
</Progress>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
- `value` คือ 0–100 (เปลี่ยนช่วงได้ด้วย `min` / `max`)
|
|
25
|
+
- ถ้าไม่มี `ProgressLabel` ต้องใส่ `aria-label` ให้แถบ
|
|
26
|
+
|
|
27
|
+
## When to use
|
|
28
|
+
|
|
29
|
+
- ความคืบหน้าที่วัดได้ เช่น อัปโหลดเอกสาร ขั้นตอนการยื่นคำขอ
|
|
30
|
+
- สัดส่วนของเป้าหมาย เช่น เงินสมทบปีนี้เทียบกับเพดาน
|
|
31
|
+
|
|
32
|
+
## When not to use
|
|
33
|
+
|
|
34
|
+
- **รอโดยไม่รู้ว่านานเท่าไร**: ใช้ `Skeleton` สำหรับเนื้อหาที่โหลด (หรือ `value={null}` ถ้าต้องเป็นแถบ)
|
|
35
|
+
- **เปรียบเทียบตัวเลขหลายค่า**: ใช้ตารางหรือกราฟ หรือ `Chart`
|
|
36
|
+
|
|
37
|
+
## Props and variants
|
|
38
|
+
|
|
39
|
+
ไม่มี variant หรือ size แถบสูง 12px กว้างเต็มพื้นที่ ทรงแคปซูล
|
|
40
|
+
|
|
41
|
+
| Prop | ค่า | ค่าเริ่มต้น | ความหมาย |
|
|
42
|
+
| ------------- | -------------------------- | ----------- | ------------------------------------------------------------- |
|
|
43
|
+
| `value` | ตัวเลข หรือ `null` | – | ค่าปัจจุบัน `null` = ไม่รู้ความคืบหน้า |
|
|
44
|
+
| `min` / `max` | ตัวเลข | `0` / `100` | ช่วงของค่า |
|
|
45
|
+
| `format` | `Intl.NumberFormatOptions` | – | รูปแบบตัวเลขใน `ProgressValue` TODO: ยังไม่ได้ตรวจว่าใช้ภาษาไทยหรือไม่ |
|
|
46
|
+
| `aria-label` | ข้อความ | – | ชื่อของแถบ เมื่อไม่มี `ProgressLabel` |
|
|
47
|
+
| `className` | class | – | เช่น ความกว้าง |
|
|
48
|
+
|
|
49
|
+
- **ProgressLabel**: ชื่อของแถบ แสดงด้านซ้ายบน (14px, medium)
|
|
50
|
+
- **ProgressValue**: ตัวเลข เช่น "62%" แสดงด้านขวาบน (14px, สี muted)
|
|
51
|
+
- TODO: ยังไม่ได้กำหนดสีเมื่อเกินเป้าหรือใกล้เพดาน (เช่น สีเตือน)
|
|
52
|
+
|
|
53
|
+
## Tokens used
|
|
54
|
+
|
|
55
|
+
ค่าทั้งหมดมาจาก `src/styles/theme.css`
|
|
56
|
+
|
|
57
|
+
### Component tokens
|
|
58
|
+
|
|
59
|
+
token เฉพาะของคอมโพเนนต์นี้ ชี้ไปที่ semantic token ด้านล่าง เปลี่ยนที่นี่เพื่อปรับเฉพาะคอมโพเนนต์นี้ (โหมดมืด "–" = ใช้ค่าเดียวกับโหมดสว่าง)
|
|
60
|
+
|
|
61
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
62
|
+
| ---------------------- | ----------- | ------ | ------------ |
|
|
63
|
+
| `--progress-track` | `--muted` | – | ราง |
|
|
64
|
+
| `--progress-indicator` | `--primary` | – | แถบความคืบหน้า |
|
|
65
|
+
|
|
66
|
+
### Semantic tokens
|
|
67
|
+
|
|
68
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
69
|
+
| -------------------- | --------------------------- | --------------------------- | ----------------------- |
|
|
70
|
+
| `--muted` | `oklch(0.966 0.005 106.5)` | `oklch(0.286 0.016 107.4)` | ราง |
|
|
71
|
+
| `--primary` | `oklch(0.553 0.195 38.402)` | `oklch(0.705 0.187 47.604)` | ส่วนที่ทำแล้ว |
|
|
72
|
+
| `--muted-foreground` | `oklch(0.5 0.027 107.3)` | `oklch(0.737 0.021 106.9)` | ตัวเลข (`ProgressValue`) |
|
|
73
|
+
|
|
74
|
+
## Example
|
|
75
|
+
|
|
76
|
+
จาก story `Playground` ใน `Progress.stories.tsx`:
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
<Progress value={62} className="w-80">
|
|
80
|
+
<ProgressLabel>เงินสมทบปีนี้เทียบกับเพดาน</ProgressLabel>
|
|
81
|
+
<ProgressValue />
|
|
82
|
+
</Progress>
|
|
83
|
+
```
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# RadioGroup (ตัวเลือกแบบเลือกได้ข้อเดียว)
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
เลือกได้หนึ่งข้อจากรายการสั้น ๆ ที่เห็นทุกตัวเลือกพร้อมกัน
|
|
6
|
+
|
|
7
|
+
## Import and usage
|
|
8
|
+
|
|
9
|
+
**ตั้งค่าครั้งเดียวในแอป** (ใช้ร่วมกันทุกคอมโพเนนต์):
|
|
10
|
+
|
|
11
|
+
1. ติดตั้ง `@designil/labdsnov` (`pnpm add @designil/labdsnov`) พร้อม `react` และ `react-dom` 19
|
|
12
|
+
2. import สไตล์ครั้งเดียวที่ root layout: `import "@designil/labdsnov/styles.css"`
|
|
13
|
+
3. กำหนดตัวแปร `--font-heading` (แอปใช้ IBM Plex Sans Thai) และใส่ class `dark` ที่ `<html>` เมื่อต้องการโหมดมืด
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { Label, RadioGroup, RadioGroupItem } from "@designil/labdsnov"
|
|
17
|
+
|
|
18
|
+
;<RadioGroup defaultValue="balanced" aria-label="แผนการลงทุน">
|
|
19
|
+
<div className="flex items-center gap-2">
|
|
20
|
+
<RadioGroupItem value="balanced" id="plan-balanced" />
|
|
21
|
+
<Label htmlFor="plan-balanced">สมดุล (Balanced)</Label>
|
|
22
|
+
</div>
|
|
23
|
+
<div className="flex items-center gap-2">
|
|
24
|
+
<RadioGroupItem value="growth" id="plan-growth" />
|
|
25
|
+
<Label htmlFor="plan-growth">เติบโตสูง (High Growth)</Label>
|
|
26
|
+
</div>
|
|
27
|
+
</RadioGroup>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
- ตั้งชื่อให้ทั้งกลุ่ม: `aria-label` หรือวางใน `FieldSet` ที่มี `FieldLegend` (ดู [Field](../Field/Field.md))
|
|
31
|
+
- ตัวเลือกที่มีคำอธิบายยาว ทำเป็นการ์ดให้เลือกได้ตาม story `ChoiceCards` ของ Field
|
|
32
|
+
|
|
33
|
+
## When to use
|
|
34
|
+
|
|
35
|
+
- เลือกหนึ่งข้อจาก 2–5 ตัวเลือก ที่ผู้ใช้ควรเห็นทุกตัวเลือกก่อนตัดสินใจ เช่น แผนการลงทุน ความถี่ของใบแจ้งยอด
|
|
36
|
+
|
|
37
|
+
## When not to use
|
|
38
|
+
|
|
39
|
+
| สถานการณ์ | ใช้แทน |
|
|
40
|
+
| ---------------------- | ----------------------- |
|
|
41
|
+
| ตัวเลือกมาก (เกิน 5–7 ข้อ) | `Select` |
|
|
42
|
+
| เลือกได้หลายข้อ | `Checkbox` |
|
|
43
|
+
| เปิด/ปิดอย่างเดียว | `Switch` หรือ `Checkbox` |
|
|
44
|
+
| สลับมุมมองของเนื้อหา | `Tabs` |
|
|
45
|
+
|
|
46
|
+
TODO: ยังไม่ได้กำหนดจำนวนตัวเลือกสูงสุดก่อนเปลี่ยนไปใช้ `Select`
|
|
47
|
+
|
|
48
|
+
## Props and variants
|
|
49
|
+
|
|
50
|
+
ไม่มี variant หรือ size วงกลมขนาด 16px ตัวเลือกเรียงลงมาห่างกัน 12px
|
|
51
|
+
|
|
52
|
+
### RadioGroup
|
|
53
|
+
|
|
54
|
+
| Prop | ค่า | ค่าเริ่มต้น | ความหมาย |
|
|
55
|
+
| ------------------------- | --------------- | ------- | ----------------------------- |
|
|
56
|
+
| `defaultValue` | value ของตัวเลือก | – | ตัวเลือกที่เลือกไว้ตอนแรก |
|
|
57
|
+
| `value` / `onValueChange` | value / ฟังก์ชัน | – | ควบคุมจากภายนอก |
|
|
58
|
+
| `name` | ข้อความ | – | ชื่อที่ส่งไปกับฟอร์ม |
|
|
59
|
+
| `disabled` | `boolean` | `false` | ปิดใช้งานทั้งกลุ่ม |
|
|
60
|
+
| `aria-label` | ข้อความ | – | ชื่อของกลุ่ม เมื่อไม่มี `FieldLegend` |
|
|
61
|
+
| `className` | class | – | ปรับหน้าตาเฉพาะจุดครั้งเดียว |
|
|
62
|
+
|
|
63
|
+
### RadioGroupItem
|
|
64
|
+
|
|
65
|
+
| Prop | ค่า | ความหมาย |
|
|
66
|
+
| -------------- | --------- | ------------------------------------- |
|
|
67
|
+
| `value` | ข้อความ | **บังคับ** ค่าของตัวเลือกนี้ |
|
|
68
|
+
| `id` | ข้อความ | ผูกกับ `Label` ผ่าน `htmlFor` |
|
|
69
|
+
| `disabled` | `boolean` | ปิดใช้งานตัวเลือกนี้ จางลง 50% |
|
|
70
|
+
| `aria-invalid` | `boolean` | ข้อมูลไม่ถูกต้อง เส้นขอบสีแดงและวงแหวนแดงจาง |
|
|
71
|
+
|
|
72
|
+
### พฤติกรรมที่มีให้แล้ว
|
|
73
|
+
|
|
74
|
+
- กด Tab แล้วโฟกัสไปที่ตัวเลือกที่เลือกอยู่ ลูกศรขึ้น/ลงเลื่อนและเลือกตัวเลือกถัดไปทันที
|
|
75
|
+
|
|
76
|
+
## Tokens used
|
|
77
|
+
|
|
78
|
+
ค่าทั้งหมดมาจาก `src/styles/theme.css`
|
|
79
|
+
|
|
80
|
+
### Component tokens
|
|
81
|
+
|
|
82
|
+
token เฉพาะของคอมโพเนนต์นี้ ชี้ไปที่ semantic token ด้านล่าง เปลี่ยนที่นี่เพื่อปรับเฉพาะคอมโพเนนต์นี้ (โหมดมืด "–" = ใช้ค่าเดียวกับโหมดสว่าง)
|
|
83
|
+
|
|
84
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
85
|
+
| ---------------------- | ---------------------- | ------------------- | ----------------------------------------------- |
|
|
86
|
+
| `--control-bg` | `--background` | `--input` 50% | พื้นตอนยังไม่เลือก |
|
|
87
|
+
| `--control-checked-bg` | `--primary` | – | พื้นและเส้นขอบตอนเลือก |
|
|
88
|
+
| `--control-checked-fg` | `--primary-foreground` | – | เครื่องหมายถูก / จุด ตอนเลือก |
|
|
89
|
+
| `--focus-ring` | `--ring` | – | วงแหวน focus จากคีย์บอร์ดของทุกคอมโพเนนต์ (ทึบ 2px) |
|
|
90
|
+
| `--invalid-border` | `--destructive` | – | เส้นขอบเมื่อข้อมูลไม่ถูกต้อง และวงแหวน focus ขณะไม่ถูกต้อง |
|
|
91
|
+
| `--invalid-ring` | `--destructive` 20% | `--destructive` 40% | วงแหวนจางรอบช่องที่ไม่ถูกต้อง (ตกแต่ง) |
|
|
92
|
+
|
|
93
|
+
### Semantic tokens
|
|
94
|
+
|
|
95
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
96
|
+
| ---------------------- | --------------------------- | --------------------------- | --------------------------- |
|
|
97
|
+
| `--input` | `oklch(0.93 0.007 106.5)` | `oklch(1 0 0 / 15%)` | พื้นวงกลมที่ไม่ได้เลือก (90%) |
|
|
98
|
+
| `--primary` | `oklch(0.553 0.195 38.402)` | `oklch(0.705 0.187 47.604)` | พื้นวงกลมที่เลือก |
|
|
99
|
+
| `--primary-foreground` | `oklch(0.98 0.016 73.684)` | `oklch(0.205 0.05 40)` | จุดตรงกลาง |
|
|
100
|
+
| `--ring` | `oklch(0.45 0.03 106.9)` | `oklch(0.8 0.02 106.9)` | วงแหวน focus |
|
|
101
|
+
| `--destructive` | `oklch(0.505 0.2 27.325)` | `oklch(0.75 0.16 22.216)` | สถานะไม่ถูกต้อง |
|
|
102
|
+
| `--background` | `oklch(1 0 0)` | `oklch(0.153 0.006 107.1)` | ผ่าน token ของคอมโพเนนต์ด้านบน |
|
|
103
|
+
|
|
104
|
+
## Example
|
|
105
|
+
|
|
106
|
+
จาก story `Playground` ใน `RadioGroup.stories.tsx`:
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
<RadioGroup defaultValue="balanced" aria-label="แผนการลงทุน" className="w-72">
|
|
110
|
+
<div className="flex items-center gap-2">
|
|
111
|
+
<RadioGroupItem value="conservative" id="plan-conservative" />
|
|
112
|
+
<Label htmlFor="plan-conservative">อนุรักษ์นิยม (Conservative)</Label>
|
|
113
|
+
</div>
|
|
114
|
+
<div className="flex items-center gap-2">
|
|
115
|
+
<RadioGroupItem value="balanced" id="plan-balanced" />
|
|
116
|
+
<Label htmlFor="plan-balanced">สมดุล (Balanced)</Label>
|
|
117
|
+
</div>
|
|
118
|
+
<div className="flex items-center gap-2">
|
|
119
|
+
<RadioGroupItem value="growth" id="plan-growth" />
|
|
120
|
+
<Label htmlFor="plan-growth">เติบโตสูง (High Growth)</Label>
|
|
121
|
+
</div>
|
|
122
|
+
</RadioGroup>
|
|
123
|
+
```
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# ScrollArea (พื้นที่เลื่อน)
|
|
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 { ScrollArea } from "@designil/labdsnov"
|
|
17
|
+
|
|
18
|
+
;<ScrollArea className="h-72 w-80 rounded-2xl border">
|
|
19
|
+
<div className="p-4">…</div>
|
|
20
|
+
</ScrollArea>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
- **ต้องกำหนดขนาด** (`h-…` หรือ `w-…`) ด้วย `className` ไม่อย่างนั้นกล่องจะสูงตามเนื้อหาและไม่เลื่อน
|
|
24
|
+
- ใส่ระยะขอบ (`p-4`) ที่เนื้อหาข้างใน ไม่ใช่ที่ `ScrollArea`
|
|
25
|
+
- เนื้อหากว้างเกิน: เพิ่ม `<ScrollBar orientation="horizontal" />` ไว้ข้างใน
|
|
26
|
+
|
|
27
|
+
## When to use
|
|
28
|
+
|
|
29
|
+
- รายการยาวในพื้นที่จำกัด เช่น รายการเคลื่อนไหวใน `Card` หรือ `Popover`
|
|
30
|
+
- แถวของการ์ดที่เลื่อนแนวนอน
|
|
31
|
+
|
|
32
|
+
## When not to use
|
|
33
|
+
|
|
34
|
+
- **เนื้อหาหลักของหน้า**: ให้หน้าเลื่อนตามปกติ
|
|
35
|
+
- **ตารางข้อมูล**: ใช้ `Table` (เลื่อนแนวนอนเองอยู่แล้ว)
|
|
36
|
+
- **รายการตัวเลือก**: `Select` / `Combobox` / `DropdownMenu` เลื่อนเองอยู่แล้ว
|
|
37
|
+
|
|
38
|
+
## Props and variants
|
|
39
|
+
|
|
40
|
+
ไม่มี variant หรือ size
|
|
41
|
+
|
|
42
|
+
| Prop | ใช้กับ | ความหมาย |
|
|
43
|
+
| ------------- | ------------ | -------------------------------------------- |
|
|
44
|
+
| `className` | `ScrollArea` | ขนาด กรอบ มุมโค้ง |
|
|
45
|
+
| `orientation` | `ScrollBar` | `vertical` (ค่าเริ่มต้น มีให้แล้ว) หรือ `horizontal` |
|
|
46
|
+
|
|
47
|
+
- แถบเลื่อนกว้าง 10px ตัวจับสีเทาเข้ม (contrast 3:1)
|
|
48
|
+
- **คีย์บอร์ด**: Tab เข้าไปในพื้นที่ (มีวงแหวน focus ด้านใน) แล้วเลื่อนด้วยลูกศร TODO: ยังไม่ได้ตรวจว่าพื้นที่รับโฟกัสได้ในทุกเบราว์เซอร์เมื่อไม่มีปุ่มหรือลิงก์ข้างใน
|
|
49
|
+
|
|
50
|
+
## Tokens used
|
|
51
|
+
|
|
52
|
+
ค่าทั้งหมดมาจาก `src/styles/theme.css`
|
|
53
|
+
|
|
54
|
+
### Component tokens
|
|
55
|
+
|
|
56
|
+
token เฉพาะของคอมโพเนนต์นี้ ชี้ไปที่ semantic token ด้านล่าง เปลี่ยนที่นี่เพื่อปรับเฉพาะคอมโพเนนต์นี้ (โหมดมืด "–" = ใช้ค่าเดียวกับโหมดสว่าง)
|
|
57
|
+
|
|
58
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
59
|
+
| --------------------- | ------------------ | ------ | --------------------------------------------- |
|
|
60
|
+
| `--focus-ring` | `--ring` | – | วงแหวน focus จากคีย์บอร์ดของทุกคอมโพเนนต์ (ทึบ 2px) |
|
|
61
|
+
| `--scroll-area-thumb` | `--control-border` | – | แถบเลื่อน |
|
|
62
|
+
|
|
63
|
+
### Semantic tokens
|
|
64
|
+
|
|
65
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
66
|
+
| ------------------ | ------------------------ | ------------------------- | --------------------------- |
|
|
67
|
+
| `--ring` | `oklch(0.45 0.03 106.9)` | `oklch(0.8 0.02 106.9)` | วงแหวน focus |
|
|
68
|
+
| `--control-border` | `oklch(0.6 0.02 106.9)` | `oklch(0.55 0.015 106.9)` | ผ่าน token ของคอมโพเนนต์ด้านบน |
|
|
69
|
+
|
|
70
|
+
## Example
|
|
71
|
+
|
|
72
|
+
จาก story `Horizontal` ใน `ScrollArea.stories.tsx`:
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
<ScrollArea className="w-96 rounded-2xl border whitespace-nowrap">
|
|
76
|
+
<div className="flex w-max gap-3 p-4">
|
|
77
|
+
{funds.map((name) => (
|
|
78
|
+
<div
|
|
79
|
+
key={name}
|
|
80
|
+
className="flex h-24 w-40 items-end rounded-2xl bg-muted p-3 text-sm font-medium"
|
|
81
|
+
>
|
|
82
|
+
{name}
|
|
83
|
+
</div>
|
|
84
|
+
))}
|
|
85
|
+
</div>
|
|
86
|
+
<ScrollBar orientation="horizontal" />
|
|
87
|
+
</ScrollArea>
|
|
88
|
+
```
|