@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,236 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: calendar
|
|
3
|
+
name: Calendar
|
|
4
|
+
description: >-
|
|
5
|
+
A month grid for picking a date or a date range, in Thai with the Buddhist year
|
|
6
|
+
("พฤศจิกายน 2569"). Built on `react-day-picker`, with dates formatted by `Intl`
|
|
7
|
+
in the `th-TH` locale.
|
|
8
|
+
metadata:
|
|
9
|
+
status: {status: stable}
|
|
10
|
+
since: 1.0.0
|
|
11
|
+
tags: [form, date]
|
|
12
|
+
|
|
13
|
+
sections:
|
|
14
|
+
- kind: guidelines
|
|
15
|
+
for: all
|
|
16
|
+
framing: when-to-use
|
|
17
|
+
items:
|
|
18
|
+
- level: should
|
|
19
|
+
statement: >-
|
|
20
|
+
Use when the user needs to see the month around a date to choose it, e.g. an
|
|
21
|
+
appointment date.
|
|
22
|
+
- level: should
|
|
23
|
+
statement: >-
|
|
24
|
+
Use `mode="range"` to pick a date range, e.g. a statement period (with
|
|
25
|
+
`numberOfMonths={2}` on wide screens).
|
|
26
|
+
- level: may
|
|
27
|
+
statement: >-
|
|
28
|
+
Show the calendar inline on the page, e.g. inside a card (its background turns
|
|
29
|
+
transparent inside a card or popup).
|
|
30
|
+
- level: must-not
|
|
31
|
+
statement: >-
|
|
32
|
+
Don't place a bare Calendar as a date field in a form. Use <dsds:date-picker>,
|
|
33
|
+
which opens this calendar in a popup and shows the chosen value on its button.
|
|
34
|
+
alternatives:
|
|
35
|
+
- to: date-picker
|
|
36
|
+
checkedBy: manual
|
|
37
|
+
- level: should-not
|
|
38
|
+
statement: >-
|
|
39
|
+
Don't make users page month by month to reach a birth date or another date they
|
|
40
|
+
already know. Until a typed date field exists, use `captionLayout="dropdown"` with
|
|
41
|
+
`startMonth` / `endMonth`.
|
|
42
|
+
example:
|
|
43
|
+
ref:
|
|
44
|
+
href: ./Calendar.stories.tsx#Dropdowns
|
|
45
|
+
rel: demo
|
|
46
|
+
|
|
47
|
+
- kind: guidelines
|
|
48
|
+
for: all
|
|
49
|
+
items:
|
|
50
|
+
- id: buddhist-year-default
|
|
51
|
+
level: must
|
|
52
|
+
statement: >-
|
|
53
|
+
Keep the built-in Thai and Buddhist-year formatting. Never pass the `date-fns` `th`
|
|
54
|
+
`locale` or `formatters` built on `date-fns` `format()`: they give the Gregorian
|
|
55
|
+
year (2026 instead of 2569).
|
|
56
|
+
refines:
|
|
57
|
+
- to: shared-content#buddhist-year
|
|
58
|
+
checks:
|
|
59
|
+
- href: ./Calendar.stories.tsx#Playground
|
|
60
|
+
role: test
|
|
61
|
+
note: play function checks the month caption "พฤศจิกายน 2569"
|
|
62
|
+
checkedBy: automated
|
|
63
|
+
- id: disable-impossible
|
|
64
|
+
level: must
|
|
65
|
+
statement: >-
|
|
66
|
+
Disable dates that can't be chosen with `disabled` (e.g. `{ before: today }` for an
|
|
67
|
+
appointment, `{ after: today }` for a birth date) instead of validating after the
|
|
68
|
+
pick and showing an error.
|
|
69
|
+
example:
|
|
70
|
+
ref:
|
|
71
|
+
href: ./Calendar.stories.tsx#DisabledDays
|
|
72
|
+
rel: demo
|
|
73
|
+
checks:
|
|
74
|
+
- href: ./Calendar.stories.tsx#DisabledDays
|
|
75
|
+
role: test
|
|
76
|
+
checkedBy: automated
|
|
77
|
+
- id: controlled-in-client
|
|
78
|
+
level: must
|
|
79
|
+
statement: >-
|
|
80
|
+
Keep `selected` / `onSelect` in Client Component state (`"use client"`). A range
|
|
81
|
+
uses the `DateRange` type from `react-day-picker`.
|
|
82
|
+
checkedBy: manual
|
|
83
|
+
- id: month-arrows-ghost
|
|
84
|
+
level: should
|
|
85
|
+
statement: >-
|
|
86
|
+
Keep the default month arrows (`buttonVariant="ghost"`). Switch to `outline` only
|
|
87
|
+
when the calendar sits on a patterned background.
|
|
88
|
+
checkedBy: manual
|
|
89
|
+
- id: outside-days
|
|
90
|
+
level: may
|
|
91
|
+
statement: >-
|
|
92
|
+
`showOutsideDays` (default `true`) shows the previous/next month's days dimmed. Turn
|
|
93
|
+
it off when several months sit side by side, to avoid confusion.
|
|
94
|
+
|
|
95
|
+
- kind: guidelines
|
|
96
|
+
for: all
|
|
97
|
+
title: Accessibility
|
|
98
|
+
tags: [accessibility]
|
|
99
|
+
items:
|
|
100
|
+
- id: full-day-name
|
|
101
|
+
level: must
|
|
102
|
+
statement: >-
|
|
103
|
+
Each day button has a full Thai name, e.g. "วันศุกร์ที่ 13 พฤศจิกายน พ.ศ. 2569,
|
|
104
|
+
วันนี้, เลือกแล้ว" (Friday 13 November BE 2569, today, selected). Don't override
|
|
105
|
+
`labels` with a format that drops the weekday or year.
|
|
106
|
+
checks:
|
|
107
|
+
- href: ./Calendar.stories.tsx#Playground
|
|
108
|
+
role: test
|
|
109
|
+
note: play function checks the selected day's name contains "เลือกแล้ว" and the "เดือนถัดไป" (next month) button
|
|
110
|
+
checkedBy: automated
|
|
111
|
+
- id: selected-contrast
|
|
112
|
+
level: must
|
|
113
|
+
statement: >-
|
|
114
|
+
The selected day passes 4.93:1 light / 6.46:1 dark, mid-range days 17.76:1 /
|
|
115
|
+
13.79:1, and weekday names 5.97:1 / 7.30:1.
|
|
116
|
+
checks:
|
|
117
|
+
- href: ../../../scripts/tokens.mjs
|
|
118
|
+
role: test
|
|
119
|
+
note: CONTRAST_PAIRS "… ใน Calendar"
|
|
120
|
+
checkedBy: automated
|
|
121
|
+
- id: not-only-calendar
|
|
122
|
+
level: should
|
|
123
|
+
statement: >-
|
|
124
|
+
Dates the user already knows should be typeable (no typed field yet, see Open
|
|
125
|
+
decisions). Picking from the grid alone is slow for screen reader users.
|
|
126
|
+
checkedBy: manual
|
|
127
|
+
|
|
128
|
+
- kind: definitions
|
|
129
|
+
for: all
|
|
130
|
+
context: keyboard
|
|
131
|
+
items:
|
|
132
|
+
- term: Left / Right arrow
|
|
133
|
+
definition: >-
|
|
134
|
+
Previous / next day
|
|
135
|
+
- term: Up / Down arrow
|
|
136
|
+
definition: >-
|
|
137
|
+
Previous / next week
|
|
138
|
+
- term: Enter / Space
|
|
139
|
+
definition: >-
|
|
140
|
+
Select the focused day
|
|
141
|
+
- term: Tab
|
|
142
|
+
definition: >-
|
|
143
|
+
Move between the "เดือนก่อนหน้า" / "เดือนถัดไป" (previous / next month) buttons
|
|
144
|
+
and the day grid
|
|
145
|
+
|
|
146
|
+
- kind: definitions
|
|
147
|
+
for: all
|
|
148
|
+
title: States
|
|
149
|
+
context: labdsnov.states
|
|
150
|
+
items:
|
|
151
|
+
- term: Today
|
|
152
|
+
definition: >-
|
|
153
|
+
Grey background
|
|
154
|
+
- term: Selected
|
|
155
|
+
definition: >-
|
|
156
|
+
Primary (orange) background, light text
|
|
157
|
+
- term: Mid-range
|
|
158
|
+
definition: >-
|
|
159
|
+
Grey background (`--calendar-range-bg`)
|
|
160
|
+
- term: Disabled
|
|
161
|
+
definition: >-
|
|
162
|
+
Dimmed, and skipped by arrow-key navigation
|
|
163
|
+
|
|
164
|
+
- kind: section
|
|
165
|
+
for: all
|
|
166
|
+
title: Open decisions
|
|
167
|
+
freeform:
|
|
168
|
+
- title: TODO
|
|
169
|
+
body: >-
|
|
170
|
+
There's no typed date field (dd/mm/yyyy) yet for birth dates or other dates the
|
|
171
|
+
user already knows.
|
|
172
|
+
|
|
173
|
+
sourceFiles:
|
|
174
|
+
- platform: react
|
|
175
|
+
file: ./Calendar.tsx
|
|
176
|
+
|
|
177
|
+
imports:
|
|
178
|
+
- platform: react
|
|
179
|
+
code: >-
|
|
180
|
+
import { Calendar } from "@designil/labdsnov"
|
|
181
|
+
package: "@designil/labdsnov"
|
|
182
|
+
|
|
183
|
+
traits:
|
|
184
|
+
- traitType: variant
|
|
185
|
+
kind: enum
|
|
186
|
+
id: mode
|
|
187
|
+
description: >-
|
|
188
|
+
How dates are picked
|
|
189
|
+
values:
|
|
190
|
+
- id: single
|
|
191
|
+
description: >-
|
|
192
|
+
One day
|
|
193
|
+
- id: multiple
|
|
194
|
+
description: >-
|
|
195
|
+
Several separate days
|
|
196
|
+
- id: range
|
|
197
|
+
description: >-
|
|
198
|
+
A date range (`from` / `to`)
|
|
199
|
+
- traitType: variant
|
|
200
|
+
kind: enum
|
|
201
|
+
id: captionLayout
|
|
202
|
+
description: >-
|
|
203
|
+
The month header
|
|
204
|
+
values:
|
|
205
|
+
- id: label
|
|
206
|
+
description: >-
|
|
207
|
+
Month name and Buddhist year as text (default)
|
|
208
|
+
- id: dropdown
|
|
209
|
+
description: >-
|
|
210
|
+
Pick month and year from lists, with `startMonth` / `endMonth`
|
|
211
|
+
- traitType: variant
|
|
212
|
+
kind: boolean
|
|
213
|
+
id: showWeekNumber
|
|
214
|
+
description: >-
|
|
215
|
+
Show week numbers
|
|
216
|
+
- traitType: variant
|
|
217
|
+
kind: boolean
|
|
218
|
+
id: showOutsideDays
|
|
219
|
+
description: >-
|
|
220
|
+
Show the previous/next month's days dimmed (default `true`)
|
|
221
|
+
|
|
222
|
+
uses:
|
|
223
|
+
- to: button
|
|
224
|
+
alternatives:
|
|
225
|
+
- to: date-picker
|
|
226
|
+
|
|
227
|
+
refs:
|
|
228
|
+
- href: ./Calendar.md
|
|
229
|
+
rel: relates-to
|
|
230
|
+
role: Thai usage doc
|
|
231
|
+
- href: ./Calendar.stories.tsx
|
|
232
|
+
rel: demo
|
|
233
|
+
role: CSF stories
|
|
234
|
+
- href: https://daypicker.dev
|
|
235
|
+
rel: relates-to
|
|
236
|
+
role: react-day-picker docs (all props)
|
|
@@ -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,199 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: card
|
|
3
|
+
name: Card
|
|
4
|
+
description: >-
|
|
5
|
+
A raised area that groups content about one subject, e.g. a balance summary or the
|
|
6
|
+
beneficiaries, with its own header, content and buttons.
|
|
7
|
+
metadata:
|
|
8
|
+
status: {status: stable}
|
|
9
|
+
since: 1.0.0
|
|
10
|
+
tags: [layout]
|
|
11
|
+
|
|
12
|
+
sections:
|
|
13
|
+
- kind: guidelines
|
|
14
|
+
for: all
|
|
15
|
+
framing: when-to-use
|
|
16
|
+
items:
|
|
17
|
+
- level: should
|
|
18
|
+
statement: >-
|
|
19
|
+
Use to summarise one subject on a dashboard, e.g. balance, investment plan,
|
|
20
|
+
beneficiaries.
|
|
21
|
+
- level: should
|
|
22
|
+
statement: >-
|
|
23
|
+
Use for a group of content with its own heading, content and buttons.
|
|
24
|
+
- level: must-not
|
|
25
|
+
statement: >-
|
|
26
|
+
Don't use Card for investment options. Use <dsds:fund-card>.
|
|
27
|
+
alternatives:
|
|
28
|
+
- to: fund-card
|
|
29
|
+
checkedBy: manual
|
|
30
|
+
- level: must-not
|
|
31
|
+
statement: >-
|
|
32
|
+
Don't build a selectable card from Card + onClick. Use the choice cards of
|
|
33
|
+
<dsds:field> (story `ChoiceCards`), which are real radios/checkboxes.
|
|
34
|
+
alternatives:
|
|
35
|
+
- to: field
|
|
36
|
+
checkedBy: manual
|
|
37
|
+
- level: should-not
|
|
38
|
+
statement: >-
|
|
39
|
+
Don't use a card just for spacing when the content isn't one group, and don't nest
|
|
40
|
+
cards in cards: the page gets heavy.
|
|
41
|
+
- level: should-not
|
|
42
|
+
statement: >-
|
|
43
|
+
Don't use as a notice. Use <dsds:alert>.
|
|
44
|
+
alternatives:
|
|
45
|
+
- to: alert
|
|
46
|
+
|
|
47
|
+
- kind: guidelines
|
|
48
|
+
for: all
|
|
49
|
+
items:
|
|
50
|
+
- id: one-primary-in-footer
|
|
51
|
+
level: must
|
|
52
|
+
statement: >-
|
|
53
|
+
`CardFooter` has at most one primary (`default`) button, placed rightmost.
|
|
54
|
+
Secondary buttons use `outline`, to its left.
|
|
55
|
+
refines:
|
|
56
|
+
- to: button#one-primary
|
|
57
|
+
checkedBy: manual
|
|
58
|
+
- id: card-action-content
|
|
59
|
+
level: should
|
|
60
|
+
statement: >-
|
|
61
|
+
`CardAction` (top right of the header) holds only a status <dsds:badge> or an icon
|
|
62
|
+
button that opens a menu (`Button size="icon-sm" variant="ghost"` + `aria-label`).
|
|
63
|
+
example:
|
|
64
|
+
ref:
|
|
65
|
+
href: ./Card.stories.tsx#WithMenuButton
|
|
66
|
+
rel: demo
|
|
67
|
+
uses:
|
|
68
|
+
- to: badge
|
|
69
|
+
- to: dropdown-menu
|
|
70
|
+
checkedBy: manual
|
|
71
|
+
- id: size-sm-dense
|
|
72
|
+
level: should
|
|
73
|
+
statement: >-
|
|
74
|
+
Use `size="sm"` (16px padding) in card grids or sidebars, and `default` (24px) for
|
|
75
|
+
the page's main card.
|
|
76
|
+
checkedBy: manual
|
|
77
|
+
- id: separators-by-class
|
|
78
|
+
level: should
|
|
79
|
+
statement: >-
|
|
80
|
+
For a divider under the header or above the footer, put `className="border-b"` on
|
|
81
|
+
`CardHeader` or `"border-t"` on `CardFooter`; spacing adjusts itself. Don't add a
|
|
82
|
+
<dsds:separator>.
|
|
83
|
+
checkedBy: manual
|
|
84
|
+
- id: media-first-child
|
|
85
|
+
level: may
|
|
86
|
+
statement: >-
|
|
87
|
+
An image as the card's first child sits flush to the top edge and follows the
|
|
88
|
+
card's corner radius.
|
|
89
|
+
- id: money-tabular
|
|
90
|
+
level: should
|
|
91
|
+
statement: >-
|
|
92
|
+
Money in a card uses `tabular-nums` with "AU$" in front, e.g. "AU$84,215.37". The
|
|
93
|
+
caption under the number uses `text-muted-foreground`.
|
|
94
|
+
checkedBy: manual
|
|
95
|
+
|
|
96
|
+
- kind: guidelines
|
|
97
|
+
for: all
|
|
98
|
+
title: Accessibility
|
|
99
|
+
tags: [accessibility]
|
|
100
|
+
items:
|
|
101
|
+
- id: title-not-heading
|
|
102
|
+
level: must
|
|
103
|
+
statement: >-
|
|
104
|
+
`CardTitle` is a `<div>`, not a page heading. If the card is a main section that
|
|
105
|
+
belongs in the heading outline, add `role="heading"` and `aria-level` yourself, or
|
|
106
|
+
put an `h2` outside the card.
|
|
107
|
+
evidence:
|
|
108
|
+
- href: https://www.w3.org/WAI/WCAG22/Understanding/info-and-relationships.html
|
|
109
|
+
role: WCAG 2.2 SC 1.3.1 (A)
|
|
110
|
+
checkedBy: manual
|
|
111
|
+
- id: card-text-contrast
|
|
112
|
+
level: must
|
|
113
|
+
statement: >-
|
|
114
|
+
Text on a card passes 19.59:1 light / 16.38:1 dark, muted captions 5.97:1 / 7.30:1,
|
|
115
|
+
and field borders in a card 3.93:1 / 3.50:1 (close to the 3:1 bar in dark mode).
|
|
116
|
+
checks:
|
|
117
|
+
- href: ../../../scripts/tokens.mjs
|
|
118
|
+
role: test
|
|
119
|
+
note: CONTRAST_PAIRS "… ใน Card"
|
|
120
|
+
checkedBy: automated
|
|
121
|
+
- id: icon-action-label
|
|
122
|
+
level: must
|
|
123
|
+
statement: >-
|
|
124
|
+
An icon button in `CardAction` has an `aria-label` saying whose menu it is, e.g.
|
|
125
|
+
"ตัวเลือกบัญชี" (account options).
|
|
126
|
+
refines:
|
|
127
|
+
- to: shared-a11y#icon-only-label
|
|
128
|
+
checkedBy: assisted
|
|
129
|
+
|
|
130
|
+
- kind: definitions
|
|
131
|
+
for: all
|
|
132
|
+
context: anatomy
|
|
133
|
+
items:
|
|
134
|
+
- term: Card
|
|
135
|
+
definition: >-
|
|
136
|
+
The frame; takes `size`
|
|
137
|
+
- term: CardHeader
|
|
138
|
+
definition: >-
|
|
139
|
+
Header holding Title, Description and Action
|
|
140
|
+
- term: CardTitle
|
|
141
|
+
definition: >-
|
|
142
|
+
Title, 16px medium (`--font-heading`), a `<div>`
|
|
143
|
+
- term: CardDescription
|
|
144
|
+
definition: >-
|
|
145
|
+
Muted caption, e.g. "ณ วันที่ 13 พ.ย. 2569" (as at 13 Nov 2569)
|
|
146
|
+
- term: CardAction
|
|
147
|
+
definition: >-
|
|
148
|
+
Top right of the header
|
|
149
|
+
- term: CardContent
|
|
150
|
+
definition: >-
|
|
151
|
+
Content
|
|
152
|
+
- term: CardFooter
|
|
153
|
+
definition: >-
|
|
154
|
+
Buttons at the bottom
|
|
155
|
+
|
|
156
|
+
- kind: section
|
|
157
|
+
for: all
|
|
158
|
+
title: Open decisions
|
|
159
|
+
freeform:
|
|
160
|
+
- title: TODO
|
|
161
|
+
body: >-
|
|
162
|
+
Not yet decided whether `CardTitle` should let you choose a heading level (`h2`,
|
|
163
|
+
`h3`).
|
|
164
|
+
|
|
165
|
+
sourceFiles:
|
|
166
|
+
- platform: react
|
|
167
|
+
file: ./Card.tsx
|
|
168
|
+
|
|
169
|
+
imports:
|
|
170
|
+
- platform: react
|
|
171
|
+
code: >-
|
|
172
|
+
import { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@designil/labdsnov"
|
|
173
|
+
package: "@designil/labdsnov"
|
|
174
|
+
|
|
175
|
+
traits:
|
|
176
|
+
- traitType: variant
|
|
177
|
+
kind: enum
|
|
178
|
+
id: size
|
|
179
|
+
description: >-
|
|
180
|
+
Inner padding and gap between parts
|
|
181
|
+
values:
|
|
182
|
+
- id: default
|
|
183
|
+
description: >-
|
|
184
|
+
24px, the page's main card
|
|
185
|
+
- id: sm
|
|
186
|
+
description: >-
|
|
187
|
+
16px, card grids or sidebars
|
|
188
|
+
|
|
189
|
+
alternatives:
|
|
190
|
+
- to: fund-card
|
|
191
|
+
- to: alert
|
|
192
|
+
|
|
193
|
+
refs:
|
|
194
|
+
- href: ./Card.md
|
|
195
|
+
rel: relates-to
|
|
196
|
+
role: Thai usage doc
|
|
197
|
+
- href: ./Card.stories.tsx
|
|
198
|
+
rel: demo
|
|
199
|
+
role: CSF stories
|
|
@@ -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
|
+
```
|