@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,196 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: navigation-menu
|
|
3
|
+
name: NavigationMenu
|
|
4
|
+
description: >-
|
|
5
|
+
The site's main menu bar, with direct links and triggers that open panels of sub-links.
|
|
6
|
+
All panels share one container that resizes and slides between them. Wraps Base UI's
|
|
7
|
+
`NavigationMenu`.
|
|
8
|
+
metadata:
|
|
9
|
+
status: {status: stable}
|
|
10
|
+
since: 1.0.0
|
|
11
|
+
tags: [navigation]
|
|
12
|
+
|
|
13
|
+
sections:
|
|
14
|
+
- kind: guidelines
|
|
15
|
+
for: all
|
|
16
|
+
framing: when-to-use
|
|
17
|
+
items:
|
|
18
|
+
- level: should
|
|
19
|
+
statement: >-
|
|
20
|
+
Use as the main menu on wide screens when there are categories with sub-links, e.g.
|
|
21
|
+
บัญชีของฉัน / ลงทุน / เอกสาร (my account / invest / documents).
|
|
22
|
+
- level: must-not
|
|
23
|
+
statement: >-
|
|
24
|
+
Don't use for actions on an item (edit / delete); use <dsds:dropdown-menu>.
|
|
25
|
+
alternatives:
|
|
26
|
+
- to: dropdown-menu
|
|
27
|
+
checkedBy: manual
|
|
28
|
+
- level: must-not
|
|
29
|
+
statement: >-
|
|
30
|
+
Don't use to switch views within one page; use <dsds:tabs>.
|
|
31
|
+
alternatives:
|
|
32
|
+
- to: tabs
|
|
33
|
+
checkedBy: manual
|
|
34
|
+
- level: should-not
|
|
35
|
+
statement: >-
|
|
36
|
+
Don't use to show where the current page sits in a deep structure; use
|
|
37
|
+
<dsds:breadcrumb>.
|
|
38
|
+
alternatives:
|
|
39
|
+
- to: breadcrumb
|
|
40
|
+
- level: should-not
|
|
41
|
+
statement: >-
|
|
42
|
+
Don't use as the mobile menu (not designed yet, see Open decisions).
|
|
43
|
+
|
|
44
|
+
- kind: guidelines
|
|
45
|
+
for: all
|
|
46
|
+
items:
|
|
47
|
+
- id: top-link-style
|
|
48
|
+
level: must
|
|
49
|
+
statement: >-
|
|
50
|
+
A top-level link with no panel gets `className={navigationMenuTriggerStyle()}` so
|
|
51
|
+
it looks like the triggers.
|
|
52
|
+
checkedBy: manual
|
|
53
|
+
- id: next-link-render
|
|
54
|
+
level: must
|
|
55
|
+
statement: >-
|
|
56
|
+
Next.js links use `<NavigationMenuLink render={<Link href="…" />}>`.
|
|
57
|
+
checkedBy: manual
|
|
58
|
+
- id: active-page
|
|
59
|
+
level: must
|
|
60
|
+
statement: >-
|
|
61
|
+
The current page's link gets `active` (faint grey background), both at the top
|
|
62
|
+
level and inside panels.
|
|
63
|
+
checkedBy: manual
|
|
64
|
+
- id: content-width
|
|
65
|
+
level: should
|
|
66
|
+
statement: >-
|
|
67
|
+
`NavigationMenuContent` has no width of its own; set it on the child, e.g.
|
|
68
|
+
`<ul className="grid w-64 gap-1">`.
|
|
69
|
+
checkedBy: manual
|
|
70
|
+
- id: trigger-not-link
|
|
71
|
+
level: should
|
|
72
|
+
statement: >-
|
|
73
|
+
`NavigationMenuTrigger` only opens a panel; it doesn't navigate. If the category
|
|
74
|
+
has an overview page, make it the first link in the panel.
|
|
75
|
+
checkedBy: manual
|
|
76
|
+
- id: few-top-items
|
|
77
|
+
level: should
|
|
78
|
+
statement: >-
|
|
79
|
+
Keep the top level to about 5–6 items, each named in 1–2 words.
|
|
80
|
+
checkedBy: manual
|
|
81
|
+
|
|
82
|
+
- kind: guidelines
|
|
83
|
+
for: all
|
|
84
|
+
title: Accessibility
|
|
85
|
+
tags: [accessibility]
|
|
86
|
+
items:
|
|
87
|
+
- id: nav-label
|
|
88
|
+
level: must
|
|
89
|
+
statement: >-
|
|
90
|
+
Give `NavigationMenu` a Thai `aria-label` (e.g. "เมนูหลัก", main menu) when the
|
|
91
|
+
page has more than one navigation menu.
|
|
92
|
+
evidence:
|
|
93
|
+
- href: https://www.w3.org/WAI/ARIA/apg/practices/landmark-regions/
|
|
94
|
+
role: WAI-ARIA APG Landmark Regions
|
|
95
|
+
checkedBy: manual
|
|
96
|
+
- id: keyboard-panel
|
|
97
|
+
level: must
|
|
98
|
+
statement: >-
|
|
99
|
+
Tab to a trigger, Enter/Space opens its panel (`aria-expanded="true"`), Escape
|
|
100
|
+
closes it.
|
|
101
|
+
checks:
|
|
102
|
+
- href: ./NavigationMenu.stories.tsx#OpenPanel
|
|
103
|
+
role: test
|
|
104
|
+
checkedBy: automated
|
|
105
|
+
- id: aria-current
|
|
106
|
+
level: should
|
|
107
|
+
statement: >-
|
|
108
|
+
An `active` link should also be announced as `aria-current="page"` (check with a
|
|
109
|
+
screen reader before relying on it).
|
|
110
|
+
checkedBy: manual
|
|
111
|
+
|
|
112
|
+
- kind: definitions
|
|
113
|
+
for: all
|
|
114
|
+
context: anatomy
|
|
115
|
+
items:
|
|
116
|
+
- term: NavigationMenu
|
|
117
|
+
definition: >-
|
|
118
|
+
The `<nav>`. Takes `align` (`start` default, `center`, `end`) and `value` /
|
|
119
|
+
`onValueChange`.
|
|
120
|
+
- term: NavigationMenuList / NavigationMenuItem
|
|
121
|
+
definition: >-
|
|
122
|
+
The top-level row and its items.
|
|
123
|
+
- term: NavigationMenuTrigger
|
|
124
|
+
definition: >-
|
|
125
|
+
Opens a panel. Its arrow rotates when open.
|
|
126
|
+
- term: NavigationMenuContent
|
|
127
|
+
definition: >-
|
|
128
|
+
A panel of sub-links.
|
|
129
|
+
- term: NavigationMenuLink
|
|
130
|
+
definition: >-
|
|
131
|
+
A link. Takes `active` and `render`.
|
|
132
|
+
- term: NavigationMenuIndicator
|
|
133
|
+
definition: >-
|
|
134
|
+
A small arrow under the open trigger (optional).
|
|
135
|
+
- term: navigationMenuTriggerStyle()
|
|
136
|
+
definition: >-
|
|
137
|
+
The trigger classes, for direct top-level links.
|
|
138
|
+
|
|
139
|
+
- kind: section
|
|
140
|
+
for: all
|
|
141
|
+
title: Open decisions
|
|
142
|
+
freeform:
|
|
143
|
+
- title: TODO
|
|
144
|
+
body: >-
|
|
145
|
+
The mobile menu (e.g. inside a Drawer) isn't designed yet, and arrow-key movement
|
|
146
|
+
between triggers hasn't been checked.
|
|
147
|
+
|
|
148
|
+
sourceFiles:
|
|
149
|
+
- platform: react
|
|
150
|
+
file: ./NavigationMenu.tsx
|
|
151
|
+
|
|
152
|
+
imports:
|
|
153
|
+
- platform: react
|
|
154
|
+
code: >-
|
|
155
|
+
import { NavigationMenu, NavigationMenuContent, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, navigationMenuTriggerStyle } from "@designil/labdsnov"
|
|
156
|
+
package: "@designil/labdsnov"
|
|
157
|
+
|
|
158
|
+
traits:
|
|
159
|
+
- traitType: variant
|
|
160
|
+
kind: enum
|
|
161
|
+
id: align
|
|
162
|
+
description: >-
|
|
163
|
+
How a panel lines up with its trigger.
|
|
164
|
+
values:
|
|
165
|
+
- id: start
|
|
166
|
+
description: >-
|
|
167
|
+
Aligned to the trigger's left edge (default).
|
|
168
|
+
- id: center
|
|
169
|
+
description: >-
|
|
170
|
+
Centred on the trigger.
|
|
171
|
+
- id: end
|
|
172
|
+
description: >-
|
|
173
|
+
Aligned to the trigger's right edge.
|
|
174
|
+
- traitType: state
|
|
175
|
+
kind: boolean
|
|
176
|
+
id: active
|
|
177
|
+
description: >-
|
|
178
|
+
The current page's link. Faint grey background.
|
|
179
|
+
- traitType: state
|
|
180
|
+
kind: boolean
|
|
181
|
+
id: open
|
|
182
|
+
description: >-
|
|
183
|
+
A panel is open.
|
|
184
|
+
|
|
185
|
+
alternatives:
|
|
186
|
+
- to: breadcrumb
|
|
187
|
+
- to: tabs
|
|
188
|
+
- to: dropdown-menu
|
|
189
|
+
|
|
190
|
+
refs:
|
|
191
|
+
- href: ./NavigationMenu.md
|
|
192
|
+
rel: relates-to
|
|
193
|
+
role: Thai usage doc
|
|
194
|
+
- href: ./NavigationMenu.stories.tsx
|
|
195
|
+
rel: demo
|
|
196
|
+
role: CSF stories
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# NavigationMenu (เมนูนำทาง)
|
|
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
|
+
NavigationMenu,
|
|
18
|
+
NavigationMenuContent,
|
|
19
|
+
NavigationMenuItem,
|
|
20
|
+
NavigationMenuLink,
|
|
21
|
+
NavigationMenuList,
|
|
22
|
+
NavigationMenuTrigger,
|
|
23
|
+
navigationMenuTriggerStyle,
|
|
24
|
+
} from "@designil/labdsnov"
|
|
25
|
+
|
|
26
|
+
;<NavigationMenu aria-label="เมนูหลัก">
|
|
27
|
+
<NavigationMenuList>
|
|
28
|
+
<NavigationMenuItem>
|
|
29
|
+
<NavigationMenuLink href="/" className={navigationMenuTriggerStyle()}>
|
|
30
|
+
หน้าแรก
|
|
31
|
+
</NavigationMenuLink>
|
|
32
|
+
</NavigationMenuItem>
|
|
33
|
+
<NavigationMenuItem>
|
|
34
|
+
<NavigationMenuTrigger>บัญชีของฉัน</NavigationMenuTrigger>
|
|
35
|
+
<NavigationMenuContent>
|
|
36
|
+
<NavigationMenuLink href="/transactions">ธุรกรรม</NavigationMenuLink>
|
|
37
|
+
</NavigationMenuContent>
|
|
38
|
+
</NavigationMenuItem>
|
|
39
|
+
</NavigationMenuList>
|
|
40
|
+
</NavigationMenu>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
- ลิงก์ระดับบนที่ไม่มีแผงย่อย ใส่ `className={navigationMenuTriggerStyle()}` ให้หน้าตาเหมือนปุ่มเปิดเมนู
|
|
44
|
+
- ใส่ `aria-label` ให้เมนูเมื่อมีเมนูนำทางหลายชุดในหน้า
|
|
45
|
+
- ลิงก์ของ Next.js ใช้ `render={<Link href="…" />}`
|
|
46
|
+
|
|
47
|
+
## When to use
|
|
48
|
+
|
|
49
|
+
- เมนูหลักบนจอกว้าง ที่มีหมวดหมู่และลิงก์ย่อย เช่น บัญชีของฉัน / ลงทุน / เอกสาร
|
|
50
|
+
|
|
51
|
+
## When not to use
|
|
52
|
+
|
|
53
|
+
| สถานการณ์ | ใช้แทน |
|
|
54
|
+
| ------------------------- | ------------------------------------------ |
|
|
55
|
+
| เมนูบนมือถือ | TODO: ยังไม่ได้ออกแบบเมนูบนมือถือ (เช่น `Drawer`) |
|
|
56
|
+
| คำสั่งของรายการ (แก้ไข / ลบ) | `DropdownMenu` |
|
|
57
|
+
| สลับมุมมองในหน้าเดียวกัน | `Tabs` |
|
|
58
|
+
| บอกตำแหน่งของหน้าปัจจุบัน | `Breadcrumb` |
|
|
59
|
+
|
|
60
|
+
## Props and variants
|
|
61
|
+
|
|
62
|
+
| ส่วน / Prop | ความหมาย |
|
|
63
|
+
| ------------------------------------------ | ----------------------------------------------------------- |
|
|
64
|
+
| `NavigationMenu` `align` | การจัดแนวแผงย่อยตามปุ่ม: `start` (ค่าเริ่มต้น), `center`, `end` |
|
|
65
|
+
| `NavigationMenu` `value` / `onValueChange` | ควบคุมว่าแผงไหนเปิด |
|
|
66
|
+
| `NavigationMenuTrigger` | ปุ่มเปิดแผงย่อย มีลูกศรที่หมุนเมื่อเปิด |
|
|
67
|
+
| `NavigationMenuContent` | แผงลิงก์ย่อย กำหนดความกว้างเอง เช่น `<ul className="grid w-80">` |
|
|
68
|
+
| `NavigationMenuLink` `active` | หน้าปัจจุบัน: พื้นเทาจาง |
|
|
69
|
+
| `NavigationMenuIndicator` | ลูกศรเล็กใต้ปุ่มที่เปิด (ไม่บังคับ) |
|
|
70
|
+
|
|
71
|
+
### พฤติกรรมที่มีให้แล้ว
|
|
72
|
+
|
|
73
|
+
- เปิดแผงเมื่อชี้เมาส์หรือคลิก แผงทุกอันใช้กล่องเดียวกันที่เปลี่ยนขนาดและเลื่อนระหว่างแผง
|
|
74
|
+
- คีย์บอร์ด: Tab ไปที่ปุ่ม Enter/Space เปิด Escape ปิด TODO: ยังไม่ได้ตรวจการใช้ลูกศรระหว่างปุ่ม
|
|
75
|
+
|
|
76
|
+
## Tokens used
|
|
77
|
+
|
|
78
|
+
ค่าทั้งหมดมาจาก `src/styles/theme.css`
|
|
79
|
+
|
|
80
|
+
### Component tokens
|
|
81
|
+
|
|
82
|
+
token เฉพาะของคอมโพเนนต์นี้ ชี้ไปที่ semantic token ด้านล่าง เปลี่ยนที่นี่เพื่อปรับเฉพาะคอมโพเนนต์นี้ (โหมดมืด "–" = ใช้ค่าเดียวกับโหมดสว่าง)
|
|
83
|
+
|
|
84
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
85
|
+
| -------------- | -------- | ------ | --------------------------------------------- |
|
|
86
|
+
| `--focus-ring` | `--ring` | – | วงแหวน focus จากคีย์บอร์ดของทุกคอมโพเนนต์ (ทึบ 2px) |
|
|
87
|
+
|
|
88
|
+
### Semantic tokens
|
|
89
|
+
|
|
90
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
91
|
+
| ---------------------- | -------------------------- | -------------------------- | -------------------------------------------- |
|
|
92
|
+
| `--muted` | `oklch(0.966 0.005 106.5)` | `oklch(0.286 0.016 107.4)` | hover / focus ของปุ่มและลิงก์, ลิงก์ที่ active (50%) |
|
|
93
|
+
| `--popover` | `oklch(1 0 0)` | `oklch(0.228 0.013 107.4)` | พื้นแผงย่อย |
|
|
94
|
+
| `--popover-foreground` | `oklch(0.153 0.006 107.1)` | `oklch(0.988 0.003 106.5)` | ตัวอักษรในแผง |
|
|
95
|
+
| `--foreground` | `oklch(0.153 0.006 107.1)` | `oklch(0.988 0.003 106.5)` | เส้นขอบบาง ๆ รอบแผง (5% สว่าง, 10% มืด) |
|
|
96
|
+
| `--border` | `oklch(0.93 0.007 106.5)` | `oklch(1 0 0 / 10%)` | ลูกศร indicator |
|
|
97
|
+
| `--ring` | `oklch(0.45 0.03 106.9)` | `oklch(0.8 0.02 106.9)` | วงแหวน focus |
|
|
98
|
+
|
|
99
|
+
## Example
|
|
100
|
+
|
|
101
|
+
จาก story `Playground` ใน `NavigationMenu.stories.tsx` (บางส่วน):
|
|
102
|
+
|
|
103
|
+
```tsx
|
|
104
|
+
<NavigationMenu aria-label="เมนูหลัก">
|
|
105
|
+
<NavigationMenuList>
|
|
106
|
+
<NavigationMenuItem>
|
|
107
|
+
<NavigationMenuLink href="#home" className={navigationMenuTriggerStyle()}>
|
|
108
|
+
หน้าแรก
|
|
109
|
+
</NavigationMenuLink>
|
|
110
|
+
</NavigationMenuItem>
|
|
111
|
+
<NavigationMenuItem>
|
|
112
|
+
<NavigationMenuTrigger>ลงทุน</NavigationMenuTrigger>
|
|
113
|
+
<NavigationMenuContent>
|
|
114
|
+
<ul className="grid w-64 gap-1">
|
|
115
|
+
<li>
|
|
116
|
+
<NavigationMenuLink href="#options">
|
|
117
|
+
ตัวเลือกการลงทุน
|
|
118
|
+
</NavigationMenuLink>
|
|
119
|
+
</li>
|
|
120
|
+
<li>
|
|
121
|
+
<NavigationMenuLink href="#switch">เปลี่ยนแผน</NavigationMenuLink>
|
|
122
|
+
</li>
|
|
123
|
+
</ul>
|
|
124
|
+
</NavigationMenuContent>
|
|
125
|
+
</NavigationMenuItem>
|
|
126
|
+
</NavigationMenuList>
|
|
127
|
+
</NavigationMenu>
|
|
128
|
+
```
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: pagination
|
|
3
|
+
name: Pagination
|
|
4
|
+
description: >-
|
|
5
|
+
Page-number links for a long list split across pages, such as past transactions. They
|
|
6
|
+
are plain `<a>` elements styled with `buttonVariants()`, so they're announced as links
|
|
7
|
+
(shadcn's are announced as buttons).
|
|
8
|
+
metadata:
|
|
9
|
+
status: {status: stable}
|
|
10
|
+
since: 1.0.0
|
|
11
|
+
tags: [navigation]
|
|
12
|
+
|
|
13
|
+
sections:
|
|
14
|
+
- kind: guidelines
|
|
15
|
+
for: all
|
|
16
|
+
framing: when-to-use
|
|
17
|
+
items:
|
|
18
|
+
- level: should
|
|
19
|
+
statement: >-
|
|
20
|
+
Use for lists too long for one page where the user may need to return to a page,
|
|
21
|
+
such as a transactions table.
|
|
22
|
+
- level: should-not
|
|
23
|
+
statement: >-
|
|
24
|
+
Don't paginate short lists (up to about 25 rows); show everything.
|
|
25
|
+
- level: must-not
|
|
26
|
+
statement: >-
|
|
27
|
+
Don't use for form steps; use "ถัดไป" / "ย้อนกลับ" (next / back) buttons
|
|
28
|
+
(<dsds:button>).
|
|
29
|
+
alternatives:
|
|
30
|
+
- to: button
|
|
31
|
+
checkedBy: manual
|
|
32
|
+
|
|
33
|
+
- kind: guidelines
|
|
34
|
+
for: all
|
|
35
|
+
items:
|
|
36
|
+
- id: every-page-has-url
|
|
37
|
+
level: must
|
|
38
|
+
statement: >-
|
|
39
|
+
Every link has its page's `href` (`?page=3`) so the user can go back or share the
|
|
40
|
+
link. Never use `onClick` alone without an `href`.
|
|
41
|
+
checkedBy: manual
|
|
42
|
+
- id: app-computes-pages
|
|
43
|
+
level: must
|
|
44
|
+
statement: >-
|
|
45
|
+
The app decides which page numbers to show; Pagination is only the look. Show the
|
|
46
|
+
first page, the last page, the current page and its neighbours, and put a
|
|
47
|
+
`PaginationEllipsis` where pages are skipped.
|
|
48
|
+
example:
|
|
49
|
+
ref:
|
|
50
|
+
href: ./Pagination.stories.tsx#Playground
|
|
51
|
+
rel: demo
|
|
52
|
+
checkedBy: manual
|
|
53
|
+
- id: current-page-active
|
|
54
|
+
level: must
|
|
55
|
+
statement: >-
|
|
56
|
+
Mark the current page with `isActive` (outline button and `aria-current="page"`).
|
|
57
|
+
Only one page can be active.
|
|
58
|
+
checks:
|
|
59
|
+
- href: ./Pagination.stories.tsx#Playground
|
|
60
|
+
role: test
|
|
61
|
+
note: play function checks aria-current on page 2
|
|
62
|
+
checkedBy: automated
|
|
63
|
+
- id: hide-edge-links
|
|
64
|
+
level: must
|
|
65
|
+
statement: >-
|
|
66
|
+
Hide `PaginationPrevious` on the first page and `PaginationNext` on the last page
|
|
67
|
+
yourself; there's no disabled state yet. A link to the page you're already on
|
|
68
|
+
confuses people.
|
|
69
|
+
checkedBy: manual
|
|
70
|
+
- id: prev-next-text
|
|
71
|
+
level: may
|
|
72
|
+
statement: >-
|
|
73
|
+
Change the "ก่อนหน้า" / "ถัดไป" (previous / next) text with `text`. Below 640px only
|
|
74
|
+
the arrow shows.
|
|
75
|
+
- id: no-button-render
|
|
76
|
+
level: must-not
|
|
77
|
+
statement: >-
|
|
78
|
+
Don't turn PaginationLink into `Button render={<a />}`: it would be announced as a
|
|
79
|
+
button.
|
|
80
|
+
refs:
|
|
81
|
+
- to: shared-composition#link-looks-like-button
|
|
82
|
+
rel: relates-to
|
|
83
|
+
checkedBy: manual
|
|
84
|
+
|
|
85
|
+
- kind: guidelines
|
|
86
|
+
for: all
|
|
87
|
+
title: Accessibility
|
|
88
|
+
tags: [accessibility]
|
|
89
|
+
items:
|
|
90
|
+
- id: nav-name
|
|
91
|
+
level: must
|
|
92
|
+
statement: >-
|
|
93
|
+
`Pagination` is a `<nav aria-label="การแบ่งหน้า">` (pagination). The previous/next
|
|
94
|
+
links are named "ไปหน้าก่อนหน้า" / "ไปหน้าถัดไป" (go to previous / next page), which
|
|
95
|
+
still read out when the visible text is hidden on narrow screens.
|
|
96
|
+
checks:
|
|
97
|
+
- href: ./Pagination.stories.tsx#Playground
|
|
98
|
+
role: test
|
|
99
|
+
note: play function finds the link named "ไปหน้าถัดไป"
|
|
100
|
+
checkedBy: automated
|
|
101
|
+
- id: target-36
|
|
102
|
+
level: should
|
|
103
|
+
statement: >-
|
|
104
|
+
Page numbers are 36px `icon` buttons. Don't shrink them to `icon-xs`, because they
|
|
105
|
+
sit right next to each other.
|
|
106
|
+
refines:
|
|
107
|
+
- to: shared-a11y#target-size
|
|
108
|
+
checkedBy: manual
|
|
109
|
+
- id: focus-after-change
|
|
110
|
+
level: should
|
|
111
|
+
statement: >-
|
|
112
|
+
If the page changes without a full reload, move focus to the list's heading or
|
|
113
|
+
table instead of leaving it on the page number.
|
|
114
|
+
checkedBy: manual
|
|
115
|
+
|
|
116
|
+
- kind: definitions
|
|
117
|
+
for: all
|
|
118
|
+
context: anatomy
|
|
119
|
+
items:
|
|
120
|
+
- term: Pagination
|
|
121
|
+
definition: >-
|
|
122
|
+
The `<nav>`, centred.
|
|
123
|
+
- term: PaginationContent / PaginationItem
|
|
124
|
+
definition: >-
|
|
125
|
+
`<ul>` / `<li>`.
|
|
126
|
+
- term: PaginationLink
|
|
127
|
+
definition: >-
|
|
128
|
+
A page-number link styled as a ghost `icon` button. Takes `href`, `isActive`,
|
|
129
|
+
`size`.
|
|
130
|
+
- term: PaginationPrevious / PaginationNext
|
|
131
|
+
definition: >-
|
|
132
|
+
"ก่อนหน้า" / "ถัดไป" (previous / next) links with an arrow. Take `text`.
|
|
133
|
+
- term: PaginationEllipsis
|
|
134
|
+
definition: >-
|
|
135
|
+
"…" between page numbers.
|
|
136
|
+
|
|
137
|
+
- kind: section
|
|
138
|
+
for: all
|
|
139
|
+
title: Open decisions
|
|
140
|
+
freeform:
|
|
141
|
+
- title: TODO
|
|
142
|
+
body: >-
|
|
143
|
+
Previous/next links have no disabled state yet, and a "โหลดเพิ่ม" (load more)
|
|
144
|
+
button for continuous feeds hasn't been decided.
|
|
145
|
+
|
|
146
|
+
sourceFiles:
|
|
147
|
+
- platform: react
|
|
148
|
+
file: ./Pagination.tsx
|
|
149
|
+
|
|
150
|
+
imports:
|
|
151
|
+
- platform: react
|
|
152
|
+
code: >-
|
|
153
|
+
import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious } from "@designil/labdsnov"
|
|
154
|
+
package: "@designil/labdsnov"
|
|
155
|
+
|
|
156
|
+
traits:
|
|
157
|
+
- traitType: state
|
|
158
|
+
kind: boolean
|
|
159
|
+
id: isActive
|
|
160
|
+
description: >-
|
|
161
|
+
The current page: outline button and `aria-current="page"`.
|
|
162
|
+
|
|
163
|
+
uses:
|
|
164
|
+
- to: button
|
|
165
|
+
|
|
166
|
+
refs:
|
|
167
|
+
- href: ./Pagination.md
|
|
168
|
+
rel: relates-to
|
|
169
|
+
role: Thai usage doc
|
|
170
|
+
- href: ./Pagination.stories.tsx
|
|
171
|
+
rel: demo
|
|
172
|
+
role: CSF stories
|
|
@@ -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
|
+
```
|