@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.
Files changed (290) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +150 -2
  3. package/dist/components/Accordion/Accordion.d.ts +8 -0
  4. package/dist/components/Accordion/Accordion.js +82 -0
  5. package/dist/components/Accordion/Accordion.module.css.js +23 -0
  6. package/dist/components/Accordion/index.d.ts +1 -0
  7. package/dist/components/Alert/Alert.d.ts +17 -0
  8. package/dist/components/Alert/Alert.js +58 -0
  9. package/dist/components/Alert/Alert.module.css.js +17 -0
  10. package/dist/components/Alert/index.d.ts +1 -0
  11. package/dist/components/AlertDialog/AlertDialog.d.ts +29 -0
  12. package/dist/components/AlertDialog/AlertDialog.js +150 -0
  13. package/dist/components/AlertDialog/AlertDialog.module.css.js +23 -0
  14. package/dist/components/AlertDialog/index.d.ts +1 -0
  15. package/dist/components/Avatar/Avatar.d.ts +23 -0
  16. package/dist/components/Avatar/Avatar.js +84 -0
  17. package/dist/components/Avatar/Avatar.module.css.js +23 -0
  18. package/dist/components/Avatar/index.d.ts +1 -0
  19. package/dist/components/Badge/Badge.d.ts +17 -0
  20. package/dist/components/Badge/Badge.js +37 -0
  21. package/dist/components/Badge/Badge.module.css.js +19 -0
  22. package/dist/components/Badge/index.d.ts +1 -0
  23. package/dist/components/Breadcrumb/Breadcrumb.d.ts +15 -0
  24. package/dist/components/Breadcrumb/Breadcrumb.js +111 -0
  25. package/dist/components/Breadcrumb/Breadcrumb.module.css.js +19 -0
  26. package/dist/components/Breadcrumb/index.d.ts +1 -0
  27. package/dist/components/Button/Button.d.ts +39 -0
  28. package/dist/components/Button/Button.js +62 -0
  29. package/dist/components/Button/Button.module.css.js +37 -0
  30. package/dist/components/Button/index.d.ts +1 -0
  31. package/dist/components/ButtonGroup/ButtonGroup.d.ts +21 -0
  32. package/dist/components/ButtonGroup/ButtonGroup.js +59 -0
  33. package/dist/components/ButtonGroup/ButtonGroup.module.css.js +15 -0
  34. package/dist/components/ButtonGroup/index.d.ts +1 -0
  35. package/dist/components/Calendar/Calendar.d.ts +17 -0
  36. package/dist/components/Calendar/Calendar.js +154 -0
  37. package/dist/components/Calendar/Calendar.module.css.js +67 -0
  38. package/dist/components/Calendar/index.d.ts +1 -0
  39. package/dist/components/Card/Card.d.ts +20 -0
  40. package/dist/components/Card/Card.js +87 -0
  41. package/dist/components/Card/Card.module.css.js +23 -0
  42. package/dist/components/Card/index.d.ts +1 -0
  43. package/dist/components/Chart/Chart.d.ts +59 -0
  44. package/dist/components/Chart/Chart.js +199 -0
  45. package/dist/components/Chart/Chart.module.css.js +47 -0
  46. package/dist/components/Chart/index.d.ts +1 -0
  47. package/dist/components/Checkbox/Checkbox.d.ts +4 -0
  48. package/dist/components/Checkbox/Checkbox.js +44 -0
  49. package/dist/components/Checkbox/Checkbox.module.css.js +13 -0
  50. package/dist/components/Checkbox/index.d.ts +1 -0
  51. package/dist/components/Collapsible/Collapsible.d.ts +8 -0
  52. package/dist/components/Collapsible/Collapsible.js +28 -0
  53. package/dist/components/Collapsible/Collapsible.module.css.js +7 -0
  54. package/dist/components/Collapsible/index.d.ts +1 -0
  55. package/dist/components/Combobox/Combobox.d.ts +36 -0
  56. package/dist/components/Combobox/Combobox.js +296 -0
  57. package/dist/components/Combobox/Combobox.module.css.js +39 -0
  58. package/dist/components/Combobox/index.d.ts +1 -0
  59. package/dist/components/DatePicker/DatePicker.d.ts +28 -0
  60. package/dist/components/DatePicker/DatePicker.js +73 -0
  61. package/dist/components/DatePicker/DatePicker.module.css.js +9 -0
  62. package/dist/components/DatePicker/index.d.ts +1 -0
  63. package/dist/components/Dialog/Dialog.d.ts +27 -0
  64. package/dist/components/Dialog/Dialog.js +144 -0
  65. package/dist/components/Dialog/Dialog.module.css.js +29 -0
  66. package/dist/components/Dialog/index.d.ts +1 -0
  67. package/dist/components/Drawer/Drawer.d.ts +22 -0
  68. package/dist/components/Drawer/Drawer.js +166 -0
  69. package/dist/components/Drawer/Drawer.module.css.js +23 -0
  70. package/dist/components/Drawer/index.d.ts +1 -0
  71. package/dist/components/DropdownMenu/DropdownMenu.d.ts +32 -0
  72. package/dist/components/DropdownMenu/DropdownMenu.js +245 -0
  73. package/dist/components/DropdownMenu/DropdownMenu.module.css.js +33 -0
  74. package/dist/components/DropdownMenu/index.d.ts +1 -0
  75. package/dist/components/Empty/Empty.d.ts +18 -0
  76. package/dist/components/Empty/Empty.js +76 -0
  77. package/dist/components/Empty/Empty.module.css.js +21 -0
  78. package/dist/components/Empty/index.d.ts +1 -0
  79. package/dist/components/Field/Field.d.ts +53 -0
  80. package/dist/components/Field/Field.js +172 -0
  81. package/dist/components/Field/Field.module.css.js +41 -0
  82. package/dist/components/Field/index.d.ts +1 -0
  83. package/dist/components/FundCard/FundCard.d.ts +18 -0
  84. package/dist/components/FundCard/FundCard.js +66 -0
  85. package/dist/components/FundCard/FundCard.module.css.js +25 -0
  86. package/dist/components/FundCard/index.d.ts +1 -0
  87. package/dist/components/HoverCard/HoverCard.d.ts +8 -0
  88. package/dist/components/HoverCard/HoverCard.js +42 -0
  89. package/dist/components/HoverCard/HoverCard.module.css.js +9 -0
  90. package/dist/components/HoverCard/index.d.ts +1 -0
  91. package/dist/components/Input/Input.d.ts +12 -0
  92. package/dist/components/Input/Input.js +23 -0
  93. package/dist/components/Input/Input.module.css.js +11 -0
  94. package/dist/components/Input/index.d.ts +1 -0
  95. package/dist/components/InputGroup/InputGroup.d.ts +39 -0
  96. package/dist/components/InputGroup/InputGroup.js +103 -0
  97. package/dist/components/InputGroup/InputGroup.module.css.js +31 -0
  98. package/dist/components/InputGroup/index.d.ts +1 -0
  99. package/dist/components/InputOTP/InputOTP.d.ts +18 -0
  100. package/dist/components/InputOTP/InputOTP.js +72 -0
  101. package/dist/components/InputOTP/InputOTP.module.css.js +19 -0
  102. package/dist/components/InputOTP/index.d.ts +1 -0
  103. package/dist/components/Kbd/Kbd.d.ts +5 -0
  104. package/dist/components/Kbd/Kbd.js +20 -0
  105. package/dist/components/Kbd/Kbd.module.css.js +9 -0
  106. package/dist/components/Kbd/index.d.ts +1 -0
  107. package/dist/components/Label/Label.d.ts +7 -0
  108. package/dist/components/Label/Label.js +17 -0
  109. package/dist/components/Label/Label.module.css.js +9 -0
  110. package/dist/components/Label/index.d.ts +1 -0
  111. package/dist/components/NavigationMenu/NavigationMenu.d.ts +20 -0
  112. package/dist/components/NavigationMenu/NavigationMenu.js +153 -0
  113. package/dist/components/NavigationMenu/NavigationMenu.module.css.js +29 -0
  114. package/dist/components/NavigationMenu/index.d.ts +1 -0
  115. package/dist/components/Pagination/Pagination.d.ts +29 -0
  116. package/dist/components/Pagination/Pagination.js +133 -0
  117. package/dist/components/Pagination/Pagination.module.css.js +19 -0
  118. package/dist/components/Pagination/index.d.ts +1 -0
  119. package/dist/components/Popover/Popover.d.ts +10 -0
  120. package/dist/components/Popover/Popover.js +78 -0
  121. package/dist/components/Popover/Popover.module.css.js +15 -0
  122. package/dist/components/Popover/index.d.ts +1 -0
  123. package/dist/components/Progress/Progress.d.ts +12 -0
  124. package/dist/components/Progress/Progress.js +74 -0
  125. package/dist/components/Progress/Progress.module.css.js +15 -0
  126. package/dist/components/Progress/index.d.ts +1 -0
  127. package/dist/components/RadioGroup/RadioGroup.d.ts +6 -0
  128. package/dist/components/RadioGroup/RadioGroup.js +37 -0
  129. package/dist/components/RadioGroup/RadioGroup.module.css.js +13 -0
  130. package/dist/components/RadioGroup/index.d.ts +1 -0
  131. package/dist/components/ScrollArea/ScrollArea.d.ts +9 -0
  132. package/dist/components/ScrollArea/ScrollArea.js +60 -0
  133. package/dist/components/ScrollArea/ScrollArea.module.css.js +17 -0
  134. package/dist/components/ScrollArea/index.d.ts +1 -0
  135. package/dist/components/Select/Select.d.ts +23 -0
  136. package/dist/components/Select/Select.js +188 -0
  137. package/dist/components/Select/Select.module.css.js +37 -0
  138. package/dist/components/Select/index.d.ts +1 -0
  139. package/dist/components/Separator/Separator.d.ts +4 -0
  140. package/dist/components/Separator/Separator.js +22 -0
  141. package/dist/components/Separator/Separator.module.css.js +7 -0
  142. package/dist/components/Separator/index.d.ts +1 -0
  143. package/dist/components/Skeleton/Skeleton.d.ts +4 -0
  144. package/dist/components/Skeleton/Skeleton.js +16 -0
  145. package/dist/components/Skeleton/Skeleton.module.css.js +7 -0
  146. package/dist/components/Skeleton/index.d.ts +1 -0
  147. package/dist/components/Slider/Slider.d.ts +13 -0
  148. package/dist/components/Slider/Slider.js +61 -0
  149. package/dist/components/Slider/Slider.module.css.js +15 -0
  150. package/dist/components/Slider/index.d.ts +1 -0
  151. package/dist/components/Spinner/Spinner.d.ts +6 -0
  152. package/dist/components/Spinner/Spinner.js +22 -0
  153. package/dist/components/Spinner/Spinner.module.css.js +7 -0
  154. package/dist/components/Spinner/index.d.ts +1 -0
  155. package/dist/components/Switch/Switch.d.ts +13 -0
  156. package/dist/components/Switch/Switch.js +29 -0
  157. package/dist/components/Switch/Switch.module.css.js +13 -0
  158. package/dist/components/Switch/index.d.ts +1 -0
  159. package/dist/components/Table/Table.d.ts +12 -0
  160. package/dist/components/Table/Table.js +96 -0
  161. package/dist/components/Table/Table.module.css.js +23 -0
  162. package/dist/components/Table/index.d.ts +1 -0
  163. package/dist/components/Tabs/Tabs.d.ts +16 -0
  164. package/dist/components/Tabs/Tabs.js +55 -0
  165. package/dist/components/Tabs/Tabs.module.css.js +17 -0
  166. package/dist/components/Tabs/index.d.ts +1 -0
  167. package/dist/components/Textarea/Textarea.d.ts +4 -0
  168. package/dist/components/Textarea/Textarea.js +16 -0
  169. package/dist/components/Textarea/Textarea.module.css.js +7 -0
  170. package/dist/components/Textarea/index.d.ts +1 -0
  171. package/dist/components/Toaster/Toaster.d.ts +8 -0
  172. package/dist/components/Toaster/Toaster.js +85 -0
  173. package/dist/components/Toaster/Toaster.module.css.js +11 -0
  174. package/dist/components/Toaster/index.d.ts +1 -0
  175. package/dist/components/Toggle/Toggle.d.ts +26 -0
  176. package/dist/components/Toggle/Toggle.js +35 -0
  177. package/dist/components/Toggle/Toggle.module.css.js +17 -0
  178. package/dist/components/Toggle/index.d.ts +1 -0
  179. package/dist/components/ToggleGroup/ToggleGroup.d.ts +20 -0
  180. package/dist/components/ToggleGroup/ToggleGroup.js +64 -0
  181. package/dist/components/ToggleGroup/ToggleGroup.module.css.js +11 -0
  182. package/dist/components/ToggleGroup/index.d.ts +1 -0
  183. package/dist/components/Tooltip/Tooltip.d.ts +8 -0
  184. package/dist/components/Tooltip/Tooltip.js +61 -0
  185. package/dist/components/Tooltip/Tooltip.module.css.js +11 -0
  186. package/dist/components/Tooltip/index.d.ts +1 -0
  187. package/dist/index.d.ts +47 -0
  188. package/dist/index.js +265 -0
  189. package/dist/styles.css +1 -0
  190. package/docs/Accessibility.md +129 -0
  191. package/docs/Colors.md +149 -0
  192. package/docs/ComponentTokens.md +191 -0
  193. package/docs/Contributing.md +104 -0
  194. package/docs/GettingStarted.md +106 -0
  195. package/docs/Radius.md +25 -0
  196. package/docs/Typography.md +38 -0
  197. package/package.json +88 -4
  198. package/src/components/Accordion/Accordion.dsds.yaml +195 -0
  199. package/src/components/Accordion/Accordion.md +102 -0
  200. package/src/components/Alert/Alert.dsds.yaml +206 -0
  201. package/src/components/Alert/Alert.md +90 -0
  202. package/src/components/AlertDialog/AlertDialog.dsds.yaml +243 -0
  203. package/src/components/AlertDialog/AlertDialog.md +131 -0
  204. package/src/components/Avatar/Avatar.dsds.yaml +172 -0
  205. package/src/components/Avatar/Avatar.md +77 -0
  206. package/src/components/Badge/Badge.dsds.yaml +191 -0
  207. package/src/components/Badge/Badge.md +124 -0
  208. package/src/components/Breadcrumb/Breadcrumb.dsds.yaml +162 -0
  209. package/src/components/Breadcrumb/Breadcrumb.md +110 -0
  210. package/src/components/Button/Button.dsds.yaml +350 -0
  211. package/src/components/Button/Button.md +165 -0
  212. package/src/components/ButtonGroup/ButtonGroup.dsds.yaml +193 -0
  213. package/src/components/ButtonGroup/ButtonGroup.md +96 -0
  214. package/src/components/Calendar/Calendar.dsds.yaml +236 -0
  215. package/src/components/Calendar/Calendar.md +111 -0
  216. package/src/components/Card/Card.dsds.yaml +199 -0
  217. package/src/components/Card/Card.md +99 -0
  218. package/src/components/Chart/Chart.dsds.yaml +216 -0
  219. package/src/components/Chart/Chart.md +112 -0
  220. package/src/components/Checkbox/Checkbox.dsds.yaml +215 -0
  221. package/src/components/Checkbox/Checkbox.md +105 -0
  222. package/src/components/Collapsible/Collapsible.dsds.yaml +146 -0
  223. package/src/components/Collapsible/Collapsible.md +86 -0
  224. package/src/components/Combobox/Combobox.dsds.yaml +241 -0
  225. package/src/components/Combobox/Combobox.md +143 -0
  226. package/src/components/DatePicker/DatePicker.dsds.yaml +179 -0
  227. package/src/components/DatePicker/DatePicker.md +82 -0
  228. package/src/components/Dialog/Dialog.dsds.yaml +300 -0
  229. package/src/components/Dialog/Dialog.md +193 -0
  230. package/src/components/Drawer/Drawer.dsds.yaml +207 -0
  231. package/src/components/Drawer/Drawer.md +125 -0
  232. package/src/components/DropdownMenu/DropdownMenu.dsds.yaml +265 -0
  233. package/src/components/DropdownMenu/DropdownMenu.md +151 -0
  234. package/src/components/Empty/Empty.dsds.yaml +171 -0
  235. package/src/components/Empty/Empty.md +90 -0
  236. package/src/components/Field/Field.dsds.yaml +285 -0
  237. package/src/components/Field/Field.md +139 -0
  238. package/src/components/FundCard/FundCard.dsds.yaml +195 -0
  239. package/src/components/FundCard/FundCard.md +93 -0
  240. package/src/components/HoverCard/HoverCard.dsds.yaml +157 -0
  241. package/src/components/HoverCard/HoverCard.md +100 -0
  242. package/src/components/Input/Input.dsds.yaml +235 -0
  243. package/src/components/Input/Input.md +115 -0
  244. package/src/components/InputGroup/InputGroup.dsds.yaml +234 -0
  245. package/src/components/InputGroup/InputGroup.md +115 -0
  246. package/src/components/InputOTP/InputOTP.dsds.yaml +184 -0
  247. package/src/components/InputOTP/InputOTP.md +105 -0
  248. package/src/components/Kbd/Kbd.dsds.yaml +119 -0
  249. package/src/components/Kbd/Kbd.md +85 -0
  250. package/src/components/Label/Label.dsds.yaml +141 -0
  251. package/src/components/Label/Label.md +75 -0
  252. package/src/components/NavigationMenu/NavigationMenu.dsds.yaml +196 -0
  253. package/src/components/NavigationMenu/NavigationMenu.md +128 -0
  254. package/src/components/Pagination/Pagination.dsds.yaml +172 -0
  255. package/src/components/Pagination/Pagination.md +115 -0
  256. package/src/components/Popover/Popover.dsds.yaml +168 -0
  257. package/src/components/Popover/Popover.md +111 -0
  258. package/src/components/Progress/Progress.dsds.yaml +169 -0
  259. package/src/components/Progress/Progress.md +83 -0
  260. package/src/components/RadioGroup/RadioGroup.dsds.yaml +215 -0
  261. package/src/components/RadioGroup/RadioGroup.md +123 -0
  262. package/src/components/ScrollArea/ScrollArea.dsds.yaml +153 -0
  263. package/src/components/ScrollArea/ScrollArea.md +88 -0
  264. package/src/components/Select/Select.dsds.yaml +239 -0
  265. package/src/components/Select/Select.md +170 -0
  266. package/src/components/Separator/Separator.dsds.yaml +121 -0
  267. package/src/components/Separator/Separator.md +68 -0
  268. package/src/components/Skeleton/Skeleton.dsds.yaml +124 -0
  269. package/src/components/Skeleton/Skeleton.md +68 -0
  270. package/src/components/Slider/Slider.dsds.yaml +194 -0
  271. package/src/components/Slider/Slider.md +107 -0
  272. package/src/components/Spinner/Spinner.dsds.yaml +126 -0
  273. package/src/components/Spinner/Spinner.md +64 -0
  274. package/src/components/Switch/Switch.dsds.yaml +198 -0
  275. package/src/components/Switch/Switch.md +101 -0
  276. package/src/components/Table/Table.dsds.yaml +195 -0
  277. package/src/components/Table/Table.md +117 -0
  278. package/src/components/Tabs/Tabs.dsds.yaml +239 -0
  279. package/src/components/Tabs/Tabs.md +173 -0
  280. package/src/components/Textarea/Textarea.dsds.yaml +167 -0
  281. package/src/components/Textarea/Textarea.md +89 -0
  282. package/src/components/Toaster/Toaster.dsds.yaml +226 -0
  283. package/src/components/Toaster/Toaster.md +107 -0
  284. package/src/components/Toggle/Toggle.dsds.yaml +224 -0
  285. package/src/components/Toggle/Toggle.md +103 -0
  286. package/src/components/ToggleGroup/ToggleGroup.dsds.yaml +230 -0
  287. package/src/components/ToggleGroup/ToggleGroup.md +95 -0
  288. package/src/components/Tooltip/Tooltip.dsds.yaml +202 -0
  289. package/src/components/Tooltip/Tooltip.md +104 -0
  290. package/src/index.dsds.yaml +467 -0
@@ -0,0 +1,129 @@
1
+ # Accessibility (การเข้าถึง)
2
+
3
+ ## Purpose
4
+
5
+ เกณฑ์ที่ทุกคอมโพเนนต์และทุกหน้าจอต้องผ่าน: WCAG 2.2 ระดับ AA ทั้งโหมดสว่างและโหมดมืด
6
+
7
+ ## Color contrast
8
+
9
+ | สิ่งที่ตรวจ | เกณฑ์ | WCAG |
10
+ | ------------------------------------------------------------------------- | ------- | ------ |
11
+ | ตัวอักษร (รวม placeholder, ตัวอักษรบนพื้นจาง, ตอน hover) | ≥ 4.5:1 | 1.4.3 |
12
+ | ขอบช่องกรอกและตัวควบคุม, วงแหวน focus, สถานะเลือก/เปิด, ไอคอนที่มีความหมาย, สีกราฟ | ≥ 3:1 | 1.4.11 |
13
+ | เส้นตกแต่ง (ขอบ Card, เส้นคั่น), สถานะปิดใช้งาน | ไม่บังคับ | – |
14
+
15
+ - **ตรวจด้วยคำสั่ง**: `pnpm tokens:check` คำนวณ contrast ของทุกคู่ในตารางด้านล่างจาก `theme.css` (รวมสีโปร่งแสงและ `color-mix` ทับพื้นจริง) ไม่ผ่านจะจบด้วย error
16
+ - **คู่สีใหม่**: ถ้าเพิ่มคอมโพเนนต์หรือ token ที่วางตัวอักษรบนพื้นใหม่ เพิ่มคู่นั้นใน `CONTRAST_PAIRS` ใน `scripts/tokens.mjs`
17
+ - **สีที่แอปกำหนดเอง** (ผ่าน `className` หรือ override token) ต้องผ่านเกณฑ์เดียวกัน
18
+
19
+ ## Focus
20
+
21
+ - ทุกคอมโพเนนต์ที่โฟกัสได้มีวงแหวนทึบ 2px สี `--focus-ring` เมื่อโฟกัสจากคีย์บอร์ด รวมถึง variant `destructive`
22
+ - ช่องที่ข้อมูลไม่ถูกต้องและกำลังโฟกัส: วงแหวนเป็นสีแดงทึบ (`--invalid-border`) เพื่อให้ยังเห็นว่าโฟกัสอยู่
23
+ - อย่าซ่อนวงแหวนด้วย `outline-none` / `ring-0` ใน `className`
24
+
25
+ ## Invalid state
26
+
27
+ - ใส่ `aria-invalid` ที่ช่อง: เส้นขอบสีแดง (`--invalid-border`) และวงแหวนแดงจาง (`--invalid-ring`)
28
+ - สีแดงอย่างเดียวไม่พอ ต้องมีข้อความบอกว่าผิดอย่างไรใต้ช่องเสมอ (`FieldError`) และผูกด้วย `aria-describedby`
29
+
30
+ ## Other rules
31
+
32
+ - ภาษาของข้อความในคอมโพเนนต์เป็นภาษาไทย รวมถึง `aria-label` (เช่น ปุ่มปิด "ปิด")
33
+ - ปุ่มที่มีแต่ไอคอนต้องมี `aria-label`
34
+ - ลิงก์ที่หน้าตาเหมือนปุ่มเป็น `<a>` ไม่ใช่ `Button` (ดู [Button](../src/components/Button/Button.md))
35
+ - พื้นที่กดของ Checkbox / Radio / Switch ใหญ่กว่าตัวที่เห็น (อย่างน้อย 24×24px)
36
+ - TODO: ยังไม่ได้ตรวจขนาดพื้นที่กดของปุ่ม `xs` / `icon-xs` (24px) กับเกณฑ์ 2.5.8 ในทุกบริบท
37
+ - TODO: ยังไม่ได้ตรวจกับโปรแกรมอ่านหน้าจอจริง (VoiceOver, NVDA)
38
+
39
+ ## Checked pairs
40
+
41
+ ค่าเป็นอัตราส่วน contrast (เช่น 4.93 = 4.93:1) สร้างด้วย `pnpm tokens:docs`
42
+
43
+ <!-- generated:contrast -->
44
+
45
+ | คู่สี | ตัวหน้า | พื้น | เกณฑ์ | สว่าง | มืด |
46
+ | ------------------------------ | ---------------------------- | --------------------------------- | ----- | ----- | ----- |
47
+ | ตัวอักษรหลักบนพื้นหน้า | `--foreground` | `--background` | 4.5:1 | 19.59 | 18.93 |
48
+ | ตัวอักษรใน Card | `--card-foreground` | `--card` | 4.5:1 | 19.59 | 16.38 |
49
+ | ตัวอักษรในกล่องลอย | `--popover-foreground` | `--popover` | 4.5:1 | 19.59 | 16.38 |
50
+ | คำอธิบายบนพื้นหน้า | `--muted-foreground` | `--background` | 4.5:1 | 5.97 | 8.43 |
51
+ | คำอธิบายบนพื้น muted | `--muted-foreground` | `--muted` | 4.5:1 | 5.41 | 6.14 |
52
+ | คำอธิบายใน Card | `--muted-foreground` | `--card` | 4.5:1 | 5.97 | 7.30 |
53
+ | คำอธิบายในกล่องลอย | `--muted-foreground` | `--popover` | 4.5:1 | 5.97 | 7.30 |
54
+ | คำอธิบายในรายการที่ไฮไลต์ | `--muted-foreground` | `--accent` | 4.5:1 | 5.41 | 6.14 |
55
+ | placeholder ในช่องกรอก | `--field-placeholder` | `--field-bg` | 4.5:1 | 5.40 | 7.17 |
56
+ | ค่าในช่องกรอก | `--foreground` | `--field-bg` | 4.5:1 | 17.71 | 16.11 |
57
+ | เส้นขอบช่องกรอก | `--field-border` | `--background` | 3:1 | 3.93 | 4.05 |
58
+ | เส้นขอบช่องกรอกใน Card | `--field-border` | `--card` | 3:1 | 3.93 | 3.50 |
59
+ | เส้นขอบช่องกรอกในกล่องลอย | `--field-border` | `--popover` | 3:1 | 3.93 | 3.50 |
60
+ | ไอคอนในช่องกรอก | `--field-icon` | `--field-bg` | 3:1 | 5.40 | 7.17 |
61
+ | วงแหวน focus | `--focus-ring` | `--background` | 3:1 | 7.40 | 10.52 |
62
+ | วงแหวน focus ใน Card | `--focus-ring` | `--card` | 3:1 | 7.40 | 9.10 |
63
+ | วงแหวน focus ในกล่องลอย | `--focus-ring` | `--popover` | 3:1 | 7.40 | 9.10 |
64
+ | เส้นขอบเมื่อไม่ถูกต้อง | `--invalid-border` | `--background` | 3:1 | 6.52 | 8.06 |
65
+ | เส้นขอบเมื่อไม่ถูกต้องใน Card | `--invalid-border` | `--card` | 3:1 | 6.52 | 6.98 |
66
+ | Button default | `--button-primary-fg` | `--button-primary-bg` | 4.5:1 | 4.93 | 6.46 |
67
+ | Button default ตอน hover | `--button-primary-fg` | `--button-primary-hover-bg` | 4.5:1 | 6.48 | 7.44 |
68
+ | Button secondary | `--button-secondary-fg` | `--button-secondary-bg` | 4.5:1 | 16.11 | 14.26 |
69
+ | Button secondary ตอน hover | `--button-secondary-fg` | `--button-secondary-hover-bg` | 4.5:1 | 14.26 | 12.63 |
70
+ | Button outline | `--foreground` | `--button-outline-bg` | 4.5:1 | 19.59 | 18.93 |
71
+ | Button outline ตอน hover | `--button-hover-fg` | `--button-outline-hover-bg` | 4.5:1 | 17.76 | 12.71 |
72
+ | Button ghost ตอน hover | `--button-hover-fg` | `--button-ghost-hover-bg` | 4.5:1 | 17.76 | 16.63 |
73
+ | Button destructive | `--button-destructive-fg` | `--button-destructive-bg` | 4.5:1 | 5.46 | 5.92 |
74
+ | Button destructive ตอน hover | `--button-destructive-fg` | `--button-destructive-hover-bg` | 4.5:1 | 4.70 | 4.74 |
75
+ | Button link | `--button-link-fg` | `--background` | 4.5:1 | 5.23 | 6.99 |
76
+ | Badge default | `--badge-default-fg` | `--badge-default-bg` | 4.5:1 | 4.93 | 6.46 |
77
+ | Badge secondary | `--badge-secondary-fg` | `--badge-secondary-bg` | 4.5:1 | 16.11 | 14.26 |
78
+ | Badge outline | `--badge-outline-fg` | `--background` | 4.5:1 | 19.59 | 18.93 |
79
+ | Badge destructive | `--badge-destructive-fg` | `--badge-destructive-bg` | 4.5:1 | 5.46 | 5.92 |
80
+ | Badge destructive ใน Card | `--badge-destructive-fg` | `--badge-destructive-bg` | 4.5:1 | 5.46 | 4.91 |
81
+ | Badge success | `--badge-success-fg` | `--badge-success-bg` | 4.5:1 | 5.14 | 6.61 |
82
+ | Badge warning | `--badge-warning-fg` | `--badge-warning-bg` | 4.5:1 | 5.38 | 7.45 |
83
+ | ข้อความผิดพลาดใน Card / Alert | `--destructive` | `--card` | 4.5:1 | 6.52 | 6.98 |
84
+ | ข้อความสำเร็จ | `--success` | `--background` | 4.5:1 | 5.92 | 9.37 |
85
+ | ข้อความเตือน | `--warning` | `--background` | 4.5:1 | 6.23 | 11.06 |
86
+ | ขอบ Checkbox / Radio ที่ยังไม่เลือก | `--control-border` | `--control-bg` | 3:1 | 3.93 | 3.44 |
87
+ | Checkbox / Radio ที่เลือกแล้ว | `--control-checked-bg` | `--background` | 3:1 | 5.23 | 6.99 |
88
+ | เครื่องหมายถูก / จุด | `--control-checked-fg` | `--control-checked-bg` | 3:1 | 4.93 | 6.46 |
89
+ | ราง Switch ตอนปิด | `--switch-track` | `--background` | 3:1 | 3.93 | 4.05 |
90
+ | ปุ่มเลื่อน Switch ตอนปิด | `--switch-thumb` | `--switch-track` | 3:1 | 3.93 | 4.68 |
91
+ | ปุ่มเลื่อน Switch ตอนเปิด | `--switch-thumb-checked` | `--control-checked-bg` | 3:1 | 4.93 | 6.46 |
92
+ | แท็บที่ไม่ได้เลือก | `--tabs-trigger-fg` | `--tabs-list-bg` | 4.5:1 | 5.41 | 6.14 |
93
+ | แท็บที่เลือก | `--tabs-trigger-active-fg` | `--tabs-trigger-active-bg` | 4.5:1 | 19.59 | 12.71 |
94
+ | แท็บ line ที่ไม่ได้เลือก | `--tabs-trigger-fg` | `--background` | 4.5:1 | 5.97 | 8.43 |
95
+ | เส้นใต้แท็บ line | `--tabs-indicator` | `--background` | 3:1 | 19.59 | 18.93 |
96
+ | แถบ Progress บนราง | `--progress-indicator` | `--progress-track` | 3:1 | 4.74 | 5.09 |
97
+ | รายการเมนูที่ไฮไลต์ | `--menu-item-highlight-fg` | `--menu-item-highlight-bg` | 4.5:1 | 15.37 | 13.79 |
98
+ | หัวข้อกลุ่มในเมนู | `--menu-label-fg` | `--popover` | 4.5:1 | 5.97 | 7.30 |
99
+ | รายการลบในเมนู | `--menu-destructive-fg` | `--popover` | 4.5:1 | 6.52 | 6.98 |
100
+ | รายการลบที่ไฮไลต์ | `--menu-destructive-fg` | `--menu-destructive-highlight-bg` | 4.5:1 | 5.46 | 4.91 |
101
+ | Tooltip | `--tooltip-fg` | `--tooltip-bg` | 4.5:1 | 19.59 | 18.93 |
102
+ | วันที่เลือกใน Calendar | `--calendar-day-selected-fg` | `--calendar-day-selected-bg` | 4.5:1 | 4.93 | 6.46 |
103
+ | วันกลางช่วงใน Calendar | `--foreground` | `--calendar-range-bg` | 4.5:1 | 17.76 | 13.79 |
104
+ | ชื่อวันใน Calendar | `--calendar-label-fg` | `--popover` | 4.5:1 | 5.97 | 7.30 |
105
+ | Toggle ที่ไม่ได้กด | `--toggle-fg` | `--background` | 4.5:1 | 5.97 | 8.43 |
106
+ | Toggle ตอน hover | `--toggle-hover-fg` | `--toggle-hover-bg` | 4.5:1 | 17.76 | 13.79 |
107
+ | Toggle ที่กดอยู่ | `--toggle-pressed-fg` | `--toggle-pressed-bg` | 4.5:1 | 17.76 | 13.79 |
108
+ | ขอบ Toggle ที่กดอยู่ | `--toggle-pressed-border` | `--background` | 3:1 | 3.93 | 4.05 |
109
+ | ข้อความใน ButtonGroup | `--button-group-text-fg` | `--button-group-text-bg` | 4.5:1 | 17.76 | 13.79 |
110
+ | Kbd | `--kbd-fg` | `--kbd-bg` | 4.5:1 | 5.41 | 6.14 |
111
+ | Kbd ในกล่องลอย | `--kbd-fg` | `--kbd-bg` | 4.5:1 | 5.41 | 6.14 |
112
+ | Kbd ใน Tooltip | `--kbd-tooltip-fg` | `--kbd-tooltip-bg` | 4.5:1 | 10.96 | 14.60 |
113
+ | ช่วงที่เลือกของ Slider บนราง | `--slider-range` | `--slider-track` | 3:1 | 4.74 | 5.09 |
114
+ | ขอบราง Slider | `--slider-track-border` | `--background` | 3:1 | 3.93 | 4.05 |
115
+ | ขอบปุ่มเลื่อน Slider | `--slider-thumb-border` | `--background` | 3:1 | 5.23 | 6.99 |
116
+ | ปุ่มเลื่อน Slider บนช่วงที่เลือก | `--slider-thumb-bg` | `--slider-range` | 3:1 | 5.23 | 6.99 |
117
+ | แถบเลื่อนของ ScrollArea | `--scroll-area-thumb` | `--background` | 3:1 | 3.93 | 4.05 |
118
+ | สีกราฟชุดที่ 1 | `--chart-1` | `--background` | 3:1 | 5.23 | 6.99 |
119
+ | สีกราฟชุดที่ 1 ใน Card | `--chart-1` | `--card` | 3:1 | 5.23 | 6.05 |
120
+ | สีกราฟชุดที่ 2 | `--chart-2` | `--background` | 3:1 | 5.15 | 8.29 |
121
+ | สีกราฟชุดที่ 2 ใน Card | `--chart-2` | `--card` | 3:1 | 5.15 | 7.17 |
122
+ | สีกราฟชุดที่ 3 | `--chart-3` | `--background` | 3:1 | 6.18 | 7.25 |
123
+ | สีกราฟชุดที่ 3 ใน Card | `--chart-3` | `--card` | 3:1 | 6.18 | 6.28 |
124
+ | สีกราฟชุดที่ 4 | `--chart-4` | `--background` | 3:1 | 6.13 | 7.30 |
125
+ | สีกราฟชุดที่ 4 ใน Card | `--chart-4` | `--card` | 3:1 | 6.13 | 6.31 |
126
+ | สีกราฟชุดที่ 5 | `--chart-5` | `--background` | 3:1 | 4.60 | 10.30 |
127
+ | สีกราฟชุดที่ 5 ใน Card | `--chart-5` | `--card` | 3:1 | 4.60 | 8.91 |
128
+
129
+ <!-- /generated:contrast -->
package/docs/Colors.md ADDED
@@ -0,0 +1,149 @@
1
+ # Colors (สี)
2
+
3
+ ## Purpose
4
+
5
+ สีทั้งหมดของระบบเป็น token ใน `src/styles/theme.css` มีค่าสำหรับโหมดสว่างและโหมดมืด ห้ามใช้ค่าสีตรง ๆ (เช่น `#f97316` หรือ `oklch(...)`) ในคอมโพเนนต์หรือหน้าจอ
6
+
7
+ ## Three layers of tokens
8
+
9
+ 1. **Primitive tokens** (`--palette-*`, หน้านี้): จานสีดิบ เช่น `--palette-orange-700`, `--palette-olive-950` ไม่มีโหมดสว่าง/มืด ใช้ได้เฉพาะใน semantic token เท่านั้น ห้ามใช้ในคอมโพเนนต์หรือหน้าจอ
10
+ 2. **Semantic tokens** (หน้านี้): สีตามความหมาย เช่น `--primary`, `--muted-foreground`, `--destructive` ชี้ไปที่ primitive และเลือก primitive คนละตัวในโหมดสว่างกับโหมดมืด เปลี่ยนที่นี่แล้วทุกคอมโพเนนต์เปลี่ยนตาม
11
+ 3. **Component tokens** (ดู [Component tokens](./ComponentTokens.md)): สีของแต่ละส่วนของคอมโพเนนต์ เช่น `--button-primary-bg` ชี้ไปที่ semantic token เปลี่ยนเพื่อปรับคอมโพเนนต์เดียว
12
+
13
+ ทุกคู่สีที่ใช้จริงผ่าน WCAG 2.2 AA ทั้งสองโหมด ดู [Accessibility](./Accessibility.md)
14
+
15
+ ## How to use
16
+
17
+ - **ในแอปที่ใช้ Tailwind**: `bg-(--primary)`, `text-(--muted-foreground)` ใช้ได้เสมอ ส่วนชื่อสั้น (`bg-primary`) ต้องมี `@theme inline` ในแอป (ดู [Getting started](./GettingStarted.md))
18
+ - **ใน CSS ปกติ**: `color: var(--muted-foreground)`
19
+ - **ตัวอักษรต้องคู่กับพื้นของมัน**: บน `--primary` ใช้ `--primary-foreground`, บน `--card` ใช้ `--card-foreground` ไม่จับคู่ข้ามกัน
20
+ - **`--destructive` / `--success` / `--warning`** ใช้เป็นสีตัวอักษร หรือเป็นพื้นจาง (10% ในโหมดสว่าง, 20% ในโหมดมืด) คู่กับตัวอักษรสีเดียวกัน ไม่ใช้เป็นพื้นทึบใต้ตัวอักษรขาว
21
+ - **`--border` vs `--control-border`**: `--border` สำหรับเส้นตกแต่ง (ขอบ Card, เส้นคั่น, ตาราง) ส่วนขอบที่บอกว่า "ตรงนี้คือช่องกรอก/ตัวเลือก" ต้องใช้ `--control-border` ซึ่งเข้มพอ (3:1)
22
+ - **อย่าบอกความหมายด้วยสีอย่างเดียว**: สถานะ เช่น ความเสี่ยงสูง ต้องมีข้อความหรือไอคอนด้วยเสมอ
23
+
24
+ ## Primitive tokens
25
+
26
+ ชื่อตามสเกลของ Tailwind (สี-ระดับ) แต่ใช้ prefix `--palette-` เพื่อไม่ทับ `--color-*` ของ Tailwind ในแอป สีที่ตรงกับ Tailwind ใช้ระดับเดียวกัน สีที่ปรับเอง (ส่วนใหญ่เพื่อให้ผ่าน WCAG AA) ใช้ระดับที่ใกล้ที่สุดที่ยังว่าง (เช่น `olive-550`) จึงอาจไม่เท่ากับสีชื่อเดียวกันของ Tailwind ดูคอลัมน์ "เทียบกับ Tailwind"
27
+
28
+ เพิ่ม primitive เมื่อ semantic token ต้องการสีที่ยังไม่มีเท่านั้น ไม่ต้องเติมให้ครบทุกระดับ
29
+
30
+ <!-- generated:primitive -->
31
+
32
+ | Token | ค่า | เทียบกับ Tailwind |
33
+ | ----------------------- | ---------------------------- | ----------------------------------- |
34
+ | `--palette-white` | `oklch(1 0 0)` | ขาว |
35
+ | `--palette-white-a10` | `oklch(1 0 0 / 10%)` | ขาวโปร่ง 10% |
36
+ | `--palette-white-a15` | `oklch(1 0 0 / 15%)` | ขาวโปร่ง 15% |
37
+ | `--palette-neutral-50` | `oklch(0.985 0 0)` | ตรงกับ `neutral-50` |
38
+ | `--palette-olive-50` | `oklch(0.988 0.003 106.5)` | ตรงกับ `olive-50` |
39
+ | `--palette-olive-100` | `oklch(0.966 0.005 106.5)` | ตรงกับ `olive-100` |
40
+ | `--palette-olive-200` | `oklch(0.93 0.007 106.5)` | ตรงกับ `olive-200` |
41
+ | `--palette-olive-350` | `oklch(0.8 0.02 106.9)` | ระดับนี้ไม่มีใน Tailwind |
42
+ | `--palette-olive-400` | `oklch(0.737 0.021 106.9)` | ตรงกับ `olive-400` |
43
+ | `--palette-olive-500` | `oklch(0.6 0.02 106.9)` | ค่าต่างจาก `olive-500` ของ Tailwind |
44
+ | `--palette-olive-550` | `oklch(0.55 0.015 106.9)` | ระดับนี้ไม่มีใน Tailwind |
45
+ | `--palette-olive-600` | `oklch(0.5 0.027 107.3)` | ค่าต่างจาก `olive-600` ของ Tailwind |
46
+ | `--palette-olive-650` | `oklch(0.45 0.03 106.9)` | ระดับนี้ไม่มีใน Tailwind |
47
+ | `--palette-olive-800` | `oklch(0.286 0.016 107.4)` | ตรงกับ `olive-800` |
48
+ | `--palette-olive-900` | `oklch(0.228 0.013 107.4)` | ตรงกับ `olive-900` |
49
+ | `--palette-olive-950` | `oklch(0.153 0.006 107.1)` | ตรงกับ `olive-950` |
50
+ | `--palette-zinc-100` | `oklch(0.967 0.001 286.375)` | ตรงกับ `zinc-100` |
51
+ | `--palette-zinc-800` | `oklch(0.274 0.006 286.033)` | ตรงกับ `zinc-800` |
52
+ | `--palette-zinc-900` | `oklch(0.21 0.006 285.885)` | ตรงกับ `zinc-900` |
53
+ | `--palette-orange-50` | `oklch(0.98 0.016 73.684)` | ตรงกับ `orange-50` |
54
+ | `--palette-orange-500` | `oklch(0.705 0.187 47.604)` | ค่าต่างจาก `orange-500` ของ Tailwind |
55
+ | `--palette-orange-700` | `oklch(0.553 0.195 38.402)` | ตรงกับ `orange-700` |
56
+ | `--palette-orange-950` | `oklch(0.205 0.05 40)` | ค่าต่างจาก `orange-950` ของ Tailwind |
57
+ | `--palette-red-400` | `oklch(0.75 0.16 22.216)` | ค่าต่างจาก `red-400` ของ Tailwind |
58
+ | `--palette-red-700` | `oklch(0.505 0.2 27.325)` | ค่าต่างจาก `red-700` ของ Tailwind |
59
+ | `--palette-green-500` | `oklch(0.75 0.16 150)` | ค่าต่างจาก `green-500` ของ Tailwind |
60
+ | `--palette-green-700` | `oklch(0.49 0.12 150)` | ค่าต่างจาก `green-700` ของ Tailwind |
61
+ | `--palette-amber-400` | `oklch(0.82 0.15 80)` | ค่าต่างจาก `amber-400` ของ Tailwind |
62
+ | `--palette-amber-800` | `oklch(0.5 0.12 60)` | ค่าต่างจาก `amber-800` ของ Tailwind |
63
+ | `--palette-teal-500` | `oklch(0.72 0.11 190)` | ค่าต่างจาก `teal-500` ของ Tailwind |
64
+ | `--palette-teal-700` | `oklch(0.52 0.1 190)` | ค่าต่างจาก `teal-700` ของ Tailwind |
65
+ | `--palette-blue-400` | `oklch(0.7 0.14 262)` | ค่าต่างจาก `blue-400` ของ Tailwind |
66
+ | `--palette-blue-700` | `oklch(0.5 0.17 262)` | ค่าต่างจาก `blue-700` ของ Tailwind |
67
+ | `--palette-fuchsia-400` | `oklch(0.72 0.17 330)` | ค่าต่างจาก `fuchsia-400` ของ Tailwind |
68
+ | `--palette-fuchsia-700` | `oklch(0.52 0.19 330)` | ค่าต่างจาก `fuchsia-700` ของ Tailwind |
69
+ | `--palette-lime-500` | `oklch(0.78 0.17 135)` | ค่าต่างจาก `lime-500` ของ Tailwind |
70
+ | `--palette-lime-700` | `oklch(0.55 0.15 135)` | ค่าต่างจาก `lime-700` ของ Tailwind |
71
+
72
+ <!-- /generated:primitive -->
73
+
74
+ ## Semantic tokens
75
+
76
+ ค่าในตารางคือ primitive ที่ token ชี้ไป สีโปร่งแสงเป็น primitive แยก เช่น `--palette-white-a10` คือขาวโปร่ง 10%
77
+
78
+ <!-- generated:semantic -->
79
+
80
+ | Token | โหมดสว่าง | โหมดมืด | ใช้กับ |
81
+ | ------------------------ | ---------------------- | ---------------------- | ------------------------------------------------------- |
82
+ | `--background` | `--palette-white` | `--palette-olive-950` | พื้นหน้า |
83
+ | `--foreground` | `--palette-olive-950` | `--palette-olive-50` | ตัวอักษรหลัก |
84
+ | `--card` | `--palette-white` | `--palette-olive-900` | พื้น Card |
85
+ | `--card-foreground` | `--palette-olive-950` | `--palette-olive-50` | ตัวอักษรใน Card |
86
+ | `--popover` | `--palette-white` | `--palette-olive-900` | พื้นกล่องลอย (Popover, เมนู, Dialog) |
87
+ | `--popover-foreground` | `--palette-olive-950` | `--palette-olive-50` | ตัวอักษรในกล่องลอย |
88
+ | `--primary` | `--palette-orange-700` | `--palette-orange-500` | สีหลักของแบรนด์ (ส้ม): ปุ่มหลัก, ตัวเลือกที่เลือกแล้ว, ลิงก์ |
89
+ | `--primary-foreground` | `--palette-orange-50` | `--palette-orange-950` | ตัวอักษรบน `--primary` |
90
+ | `--secondary` | `--palette-zinc-100` | `--palette-zinc-800` | พื้นปุ่ม/ป้ายรอง |
91
+ | `--secondary-foreground` | `--palette-zinc-900` | `--palette-neutral-50` | ตัวอักษรบน `--secondary` |
92
+ | `--muted` | `--palette-olive-100` | `--palette-olive-800` | พื้นจาง (แคปซูลแท็บ, Skeleton, ราง Progress) |
93
+ | `--muted-foreground` | `--palette-olive-600` | `--palette-olive-400` | ตัวอักษรรอง: คำอธิบาย, placeholder, หัวข้อกลุ่ม |
94
+ | `--accent` | `--palette-olive-100` | `--palette-olive-800` | พื้นรายการที่ไฮไลต์ในเมนู |
95
+ | `--accent-foreground` | `--palette-olive-900` | `--palette-olive-50` | ตัวอักษรบน `--accent` |
96
+ | `--destructive` | `--palette-red-700` | `--palette-red-400` | ข้อผิดพลาด การกระทำที่ลบหรือย้อนกลับไม่ได้ (ใช้เป็นตัวอักษรหรือพื้นจาง) |
97
+ | `--success` | `--palette-green-700` | `--palette-green-500` | สำเร็จ ความเสี่ยงต่ำ (ใช้เป็นตัวอักษรหรือพื้นจาง) |
98
+ | `--warning` | `--palette-amber-800` | `--palette-amber-400` | รอดำเนินการ ความเสี่ยงปานกลาง (ใช้เป็นตัวอักษรหรือพื้นจาง) |
99
+ | `--border` | `--palette-olive-200` | `--palette-white-a10` | เส้นตกแต่ง: ขอบ Card, เส้นคั่น, ตาราง (ไม่ต้องผ่าน 3:1) |
100
+ | `--input` | `--palette-olive-200` | `--palette-white-a15` | พื้นจางของช่องกรอก (ใช้แบบโปร่งแสง) |
101
+ | `--control-border` | `--palette-olive-500` | `--palette-olive-550` | ขอบที่บอกว่าเป็นช่องกรอกหรือตัวควบคุม (ต้องผ่าน 3:1) |
102
+ | `--ring` | `--palette-olive-650` | `--palette-olive-350` | สีวงแหวน focus |
103
+
104
+ <!-- /generated:semantic -->
105
+
106
+ ## Chart colors
107
+
108
+ ใช้ตามลำดับ 1 → 5 แต่ละสีต่างโทนกันและผ่าน 3:1 กับพื้นหน้าและพื้น `Card` ทั้งสองโหมด ใส่ป้ายชื่อหรือ legend เสมอ ดู [Chart](../src/components/Chart/Chart.md)
109
+
110
+ <!-- generated:chart -->
111
+
112
+ | Token | โหมดสว่าง | โหมดมืด | ใช้กับ |
113
+ | ----------- | ----------------------- | ----------------------- | --------------------- |
114
+ | `--chart-1` | `--palette-orange-700` | `--palette-orange-500` | สีกราฟชุดที่ 1: ส้ม (สีหลัก) |
115
+ | `--chart-2` | `--palette-teal-700` | `--palette-teal-500` | สีกราฟชุดที่ 2: เขียวอมฟ้า |
116
+ | `--chart-3` | `--palette-blue-700` | `--palette-blue-400` | สีกราฟชุดที่ 3: น้ำเงิน |
117
+ | `--chart-4` | `--palette-fuchsia-700` | `--palette-fuchsia-400` | สีกราฟชุดที่ 4: ชมพูม่วง |
118
+ | `--chart-5` | `--palette-lime-700` | `--palette-lime-500` | สีกราฟชุดที่ 5: เขียว |
119
+
120
+ <!-- /generated:chart -->
121
+
122
+ TODO: ยังไม่ได้ตรวจว่าแยกสีได้สำหรับผู้ที่มองเห็นสีผิดปกติ
123
+
124
+ ## Sidebar tokens
125
+
126
+ มาจากแอป ยังไม่มีคอมโพเนนต์ในไลบรารีใช้
127
+
128
+ <!-- generated:sidebar -->
129
+
130
+ | Token | โหมดสว่าง | โหมดมืด | ใช้กับ |
131
+ | ------------------------------ | ---------------------- | ---------------------- | ------------------------------------ |
132
+ | `--sidebar` | `--palette-olive-50` | `--palette-olive-900` | พื้นแถบข้าง (สำหรับแอป ยังไม่มีคอมโพเนนต์ใช้) |
133
+ | `--sidebar-foreground` | `--palette-olive-950` | `--palette-olive-50` | ตัวอักษรในแถบข้าง |
134
+ | `--sidebar-primary` | `--palette-orange-700` | `--palette-orange-500` | สีหลักในแถบข้าง |
135
+ | `--sidebar-primary-foreground` | `--palette-orange-50` | `--palette-orange-950` | ตัวอักษรบน `--sidebar-primary` |
136
+ | `--sidebar-accent` | `--palette-olive-100` | `--palette-olive-800` | รายการที่ไฮไลต์ในแถบข้าง |
137
+ | `--sidebar-accent-foreground` | `--palette-olive-900` | `--palette-olive-50` | ตัวอักษรบน `--sidebar-accent` |
138
+ | `--sidebar-border` | `--palette-olive-200` | `--palette-white-a10` | เส้นในแถบข้าง |
139
+ | `--sidebar-ring` | `--palette-olive-650` | `--palette-olive-350` | วงแหวน focus ในแถบข้าง |
140
+
141
+ <!-- /generated:sidebar -->
142
+
143
+ ## Dark mode
144
+
145
+ - ใส่ class `dark` ที่ `<html>` (เช่น `next-themes` ด้วย `attribute="class"`) ทุก token เปลี่ยนเป็นค่าโหมดมืดเอง
146
+ - ใส่ `dark` ที่ element ย่อยก็ได้ ส่วนนั้นจะเป็นโหมดมืดทั้ง semantic และ component token
147
+ - ในโหมดมืด `--primary` สว่างขึ้นและ `--primary-foreground` เป็นสีเข้ม เพื่อให้ปุ่มหลักและตัวเลือกที่เลือกแล้วเห็นชัดบนพื้นมืด
148
+
149
+ ตารางในหน้านี้สร้างจาก `theme.css` ด้วย `pnpm tokens:docs` อย่าแก้ในตารางโดยตรง
@@ -0,0 +1,191 @@
1
+ # Component tokens (token ของคอมโพเนนต์)
2
+
3
+ ## Purpose
4
+
5
+ สีของแต่ละส่วนของคอมโพเนนต์ ชี้ไปที่ [semantic token](./Colors.md) ใช้เมื่อต้องการปรับคอมโพเนนต์เดียวโดยไม่กระทบที่อื่น
6
+
7
+ ## How to use
8
+
9
+ - **ปกติไม่ต้องแตะ**: เปลี่ยน semantic token แล้ว component token ที่ชี้ไปจะเปลี่ยนตาม
10
+ - **ปรับคอมโพเนนต์เดียวทั้งแอป**: กำหนดค่าใหม่ใน CSS ของแอป หลัง import `@designil/labdsnov/styles.css`
11
+
12
+ ```css
13
+ :root,
14
+ .dark {
15
+ --button-primary-hover-bg: color-mix(in oklab, var(--primary) 80%, black);
16
+ }
17
+ ```
18
+
19
+ - **ปรับเฉพาะบางส่วนของหน้า**: กำหนดที่ element ครอบ เช่น `<section style={{ "--field-bg": "var(--card)" }}>`
20
+ - **ค่าที่ต่างตามโหมด** (เช่น พื้นจาง 10% / 20%) กำหนดใน `.dark` ไม่ใช่ใน CSS ของคอมโพเนนต์
21
+ - ค่าใหม่ต้องยังผ่าน contrast: รัน `pnpm tokens:check` (ดู [Accessibility](./Accessibility.md))
22
+
23
+ TODO: ยังไม่ได้ตัดสินใจว่า component token เป็น public API (เปลี่ยนชื่อ = breaking change) หรือไม่
24
+
25
+ ## Reading the tables
26
+
27
+ - **โหมดสว่าง / โหมดมืด**: token ที่ชี้ไป `--primary` 10% = `--primary` โปร่งแสง 10% ส่วน "ผสมดำ 12%" = ผสมกับสีดำ 12%
28
+ - **โหมดมืด "–"**: ใช้ค่าเดียวกับโหมดสว่าง (แต่ semantic token ที่ชี้ไปยังเปลี่ยนตามโหมด)
29
+ - ทุกคอมโพเนนต์มีตาราง "Component tokens" ของตัวเองใน `<Name>.md` ด้วย
30
+
31
+ ## Tokens
32
+
33
+ <!-- generated:component -->
34
+
35
+ ### Shared states
36
+
37
+ | Token | โหมดสว่าง | โหมดมืด | ใช้กับ |
38
+ | ------------------ | ------------------- | ------------------- | ----------------------------------------------- |
39
+ | `--focus-ring` | `--ring` | – | วงแหวน focus จากคีย์บอร์ดของทุกคอมโพเนนต์ (ทึบ 2px) |
40
+ | `--invalid-border` | `--destructive` | – | เส้นขอบเมื่อข้อมูลไม่ถูกต้อง และวงแหวน focus ขณะไม่ถูกต้อง |
41
+ | `--invalid-ring` | `--destructive` 20% | `--destructive` 40% | วงแหวนจางรอบช่องที่ไม่ถูกต้อง (ตกแต่ง) |
42
+
43
+ ### Button
44
+
45
+ | Token | โหมดสว่าง | โหมดมืด | ใช้กับ |
46
+ | ------------------------------- | ----------------------------------- | ---------------------- | ------------------------------------ |
47
+ | `--button-primary-bg` | `--primary` | – | พื้น `default` |
48
+ | `--button-primary-fg` | `--primary-foreground` | – | ตัวอักษร `default` |
49
+ | `--button-primary-hover-bg` | `--primary` ผสมดำ 12% | `--primary` ผสมขาว 12% | พื้น `default` ตอน hover |
50
+ | `--button-secondary-bg` | `--secondary` | – | พื้น `secondary` |
51
+ | `--button-secondary-fg` | `--secondary-foreground` | – | ตัวอักษร `secondary` |
52
+ | `--button-secondary-hover-bg` | `--secondary` ผสม `--foreground` 5% | – | พื้น `secondary` ตอน hover |
53
+ | `--button-outline-bg` | `--background` | `transparent` | พื้น `outline` |
54
+ | `--button-outline-border` | `--border` | – | เส้นขอบ `outline` |
55
+ | `--button-outline-hover-bg` | `--muted` | `--input` | พื้น `outline` ตอน hover / เปิดเมนู |
56
+ | `--button-ghost-hover-bg` | `--muted` | `--muted` 50% | พื้น `ghost` ตอน hover / เปิดเมนู |
57
+ | `--button-hover-fg` | `--foreground` | – | ตัวอักษร `outline` / `ghost` ตอน hover |
58
+ | `--button-destructive-bg` | `--destructive` 10% | `--destructive` 20% | พื้น `destructive` |
59
+ | `--button-destructive-hover-bg` | `--destructive` 18% | `--destructive` 30% | พื้น `destructive` ตอน hover |
60
+ | `--button-destructive-fg` | `--destructive` | – | ตัวอักษร `destructive` |
61
+ | `--button-link-fg` | `--primary` | – | ตัวอักษร `link` |
62
+
63
+ ### Badge
64
+
65
+ | Token | โหมดสว่าง | โหมดมืด | ใช้กับ |
66
+ | ------------------------ | ------------------------ | ------------------- | -------------------- |
67
+ | `--badge-default-bg` | `--primary` | – | พื้น `default` |
68
+ | `--badge-default-fg` | `--primary-foreground` | – | ตัวอักษร `default` |
69
+ | `--badge-secondary-bg` | `--secondary` | – | พื้น `secondary` |
70
+ | `--badge-secondary-fg` | `--secondary-foreground` | – | ตัวอักษร `secondary` |
71
+ | `--badge-outline-border` | `--border` | – | เส้นขอบ `outline` |
72
+ | `--badge-outline-fg` | `--foreground` | – | ตัวอักษร `outline` |
73
+ | `--badge-destructive-bg` | `--destructive` 10% | `--destructive` 20% | พื้น `destructive` |
74
+ | `--badge-destructive-fg` | `--destructive` | – | ตัวอักษร `destructive` |
75
+ | `--badge-success-bg` | `--success` 10% | `--success` 20% | พื้น `success` |
76
+ | `--badge-success-fg` | `--success` | – | ตัวอักษร `success` |
77
+ | `--badge-warning-bg` | `--warning` 10% | `--warning` 20% | พื้น `warning` |
78
+ | `--badge-warning-fg` | `--warning` | – | ตัวอักษร `warning` |
79
+
80
+ ### Text fields: Input, Textarea, Select trigger, InputGroup, Combobox, InputOTP
81
+
82
+ | Token | โหมดสว่าง | โหมดมืด | ใช้กับ |
83
+ | --------------------- | -------------------- | ------ | ------------------- |
84
+ | `--field-bg` | `--input` 50% | – | พื้นช่องกรอก |
85
+ | `--field-border` | `--control-border` | – | เส้นขอบช่องกรอก |
86
+ | `--field-placeholder` | `--muted-foreground` | – | placeholder |
87
+ | `--field-icon` | `--muted-foreground` | – | ไอคอนในช่อง เช่น ลูกศร |
88
+
89
+ ### Checkbox, RadioGroup, Switch
90
+
91
+ | Token | โหมดสว่าง | โหมดมืด | ใช้กับ |
92
+ | ------------------------ | ---------------------- | -------------- | ------------------------ |
93
+ | `--control-bg` | `--background` | `--input` 50% | พื้นตอนยังไม่เลือก |
94
+ | `--control-checked-bg` | `--primary` | – | พื้นและเส้นขอบตอนเลือก |
95
+ | `--control-checked-fg` | `--primary-foreground` | – | เครื่องหมายถูก / จุด ตอนเลือก |
96
+ | `--switch-track` | `--control-border` | – | ราง Switch ตอนปิด |
97
+ | `--switch-thumb` | `--background` | `--foreground` | ปุ่มเลื่อน Switch ตอนปิด |
98
+ | `--switch-thumb-checked` | `--primary-foreground` | – | ปุ่มเลื่อน Switch ตอนเปิด |
99
+
100
+ ### Tabs
101
+
102
+ | Token | โหมดสว่าง | โหมดมืด | ใช้กับ |
103
+ | -------------------------- | -------------------- | --------- | --------------------------- |
104
+ | `--tabs-list-bg` | `--muted` | – | พื้นแคปซูล (`default`) |
105
+ | `--tabs-trigger-fg` | `--muted-foreground` | – | ตัวอักษรแท็บที่ไม่ได้เลือก |
106
+ | `--tabs-trigger-active-bg` | `--background` | `--input` | พื้นแท็บที่เลือก (`default`) |
107
+ | `--tabs-trigger-active-fg` | `--foreground` | – | ตัวอักษรแท็บที่เลือก และตอน hover |
108
+ | `--tabs-indicator` | `--foreground` | – | เส้นใต้แท็บที่เลือก (`line`) |
109
+
110
+ ### Progress
111
+
112
+ | Token | โหมดสว่าง | โหมดมืด | ใช้กับ |
113
+ | ---------------------- | ----------- | ------ | ------------ |
114
+ | `--progress-track` | `--muted` | – | ราง |
115
+ | `--progress-indicator` | `--primary` | – | แถบความคืบหน้า |
116
+
117
+ ### Menus and lists: Select, DropdownMenu, Combobox, NavigationMenu
118
+
119
+ | Token | โหมดสว่าง | โหมดมืด | ใช้กับ |
120
+ | --------------------------------- | --------------------- | ------------------- | ------------------ |
121
+ | `--menu-item-highlight-bg` | `--accent` | – | พื้นรายการที่ไฮไลต์ |
122
+ | `--menu-item-highlight-fg` | `--accent-foreground` | – | ตัวอักษรรายการที่ไฮไลต์ |
123
+ | `--menu-label-fg` | `--muted-foreground` | – | หัวข้อกลุ่ม, ปุ่มลัด |
124
+ | `--menu-destructive-fg` | `--destructive` | – | ตัวอักษรรายการลบ |
125
+ | `--menu-destructive-highlight-bg` | `--destructive` 10% | `--destructive` 20% | พื้นรายการลบที่ไฮไลต์ |
126
+
127
+ ### Tooltip
128
+
129
+ | Token | โหมดสว่าง | โหมดมืด | ใช้กับ |
130
+ | -------------- | -------------- | ------ | --------- |
131
+ | `--tooltip-bg` | `--foreground` | – | พื้นและลูกศร |
132
+ | `--tooltip-fg` | `--background` | – | ตัวอักษร |
133
+
134
+ ### Calendar
135
+
136
+ | Token | โหมดสว่าง | โหมดมืด | ใช้กับ |
137
+ | ---------------------------- | ---------------------- | ------ | ------------------------- |
138
+ | `--calendar-day-selected-bg` | `--primary` | – | พื้นวันที่เลือก (และต้น/ปลายช่วง) |
139
+ | `--calendar-day-selected-fg` | `--primary-foreground` | – | ตัวอักษรวันที่เลือก |
140
+ | `--calendar-range-bg` | `--muted` | – | พื้นวันกลางช่วง |
141
+ | `--calendar-today-bg` | `--muted` | – | พื้นวันนี้ |
142
+ | `--calendar-label-fg` | `--muted-foreground` | – | ชื่อวันในสัปดาห์, เลขสัปดาห์ |
143
+
144
+ ### Toggle, ToggleGroup
145
+
146
+ | Token | โหมดสว่าง | โหมดมืด | ใช้กับ |
147
+ | ------------------------- | -------------------- | ------ | ------------------------------- |
148
+ | `--toggle-fg` | `--muted-foreground` | – | ตัวอักษร/ไอคอนตอนไม่ได้กด |
149
+ | `--toggle-hover-bg` | `--muted` | – | พื้นตอน hover |
150
+ | `--toggle-hover-fg` | `--foreground` | – | ตัวอักษรตอน hover |
151
+ | `--toggle-pressed-bg` | `--muted` | – | พื้นตอนกดอยู่ / เลือกอยู่ |
152
+ | `--toggle-pressed-fg` | `--foreground` | – | ตัวอักษรตอนกดอยู่ / เลือกอยู่ |
153
+ | `--toggle-pressed-border` | `--control-border` | – | ขอบตอนกดอยู่ (contrast 3:1) |
154
+ | `--toggle-outline-border` | `--border` | – | ขอบ variant `outline` ตอนไม่ได้กด |
155
+
156
+ ### ButtonGroup
157
+
158
+ | Token | โหมดสว่าง | โหมดมืด | ใช้กับ |
159
+ | -------------------------- | -------------- | ------ | ------------------------ |
160
+ | `--button-group-text-bg` | `--muted` | – | พื้น `ButtonGroupText` |
161
+ | `--button-group-text-fg` | `--foreground` | – | ตัวอักษร `ButtonGroupText` |
162
+ | `--button-group-separator` | `--input` | – | เส้นคั่นระหว่างปุ่ม |
163
+
164
+ ### Kbd
165
+
166
+ | Token | โหมดสว่าง | โหมดมืด | ใช้กับ |
167
+ | ------------------ | -------------------- | ------------------ | ------------------------ |
168
+ | `--kbd-bg` | `--muted` | – | พื้นปุ่มคีย์บอร์ด |
169
+ | `--kbd-fg` | `--muted-foreground` | – | ตัวอักษรปุ่มคีย์บอร์ด |
170
+ | `--kbd-tooltip-bg` | `--tooltip-fg` 20% | `--tooltip-fg` 12% | พื้นปุ่มคีย์บอร์ดใน Tooltip |
171
+ | `--kbd-tooltip-fg` | `--tooltip-fg` | – | ตัวอักษรปุ่มคีย์บอร์ดใน Tooltip |
172
+
173
+ ### Slider
174
+
175
+ | Token | โหมดสว่าง | โหมดมืด | ใช้กับ |
176
+ | ----------------------- | ------------------ | ------ | --------------------- |
177
+ | `--slider-track` | `--muted` | – | ราง |
178
+ | `--slider-track-border` | `--control-border` | – | ขอบราง (contrast 3:1) |
179
+ | `--slider-range` | `--primary` | – | ช่วงที่เลือก |
180
+ | `--slider-thumb-bg` | `--background` | – | พื้นปุ่มเลื่อน |
181
+ | `--slider-thumb-border` | `--primary` | – | ขอบปุ่มเลื่อน |
182
+
183
+ ### ScrollArea
184
+
185
+ | Token | โหมดสว่าง | โหมดมืด | ใช้กับ |
186
+ | --------------------- | ------------------ | ------ | ------- |
187
+ | `--scroll-area-thumb` | `--control-border` | – | แถบเลื่อน |
188
+
189
+ <!-- /generated:component -->
190
+
191
+ ตารางในหน้านี้สร้างจาก `theme.css` ด้วย `pnpm tokens:docs` อย่าแก้ในตารางโดยตรง
@@ -0,0 +1,104 @@
1
+ # Contributing (การพัฒนาระบบ)
2
+
3
+ ## Purpose
4
+
5
+ ขั้นตอนเพิ่มหรือแก้คอมโพเนนต์และ token ให้เหมือนกันทั้งระบบ สำหรับนักพัฒนาและ AI agent (กฎแบบละเอียดอยู่ใน `AGENTS.md` ที่ root ของ repo)
6
+
7
+ ## Setup
8
+
9
+ ```bash
10
+ pnpm install
11
+ pnpm storybook # http://localhost:6006
12
+ ```
13
+
14
+ ห้าม `npm publish` / `pnpm publish` / `changeset publish` เอง CI เป็นคนเผยแพร่ (ดู `RELEASING.md`) PR ของฟีเจอร์เข้า `develop` ส่วน hotfix เข้า `main`
15
+
16
+ ## Add a component
17
+
18
+ 1. **สร้างโฟลเดอร์** `packages/ui/src/components/<Name>/` ที่มี 5 ไฟล์:
19
+
20
+ | ไฟล์ | เนื้อหา |
21
+ | -------------------- | ----------------------------------------------------------------------------------------- |
22
+ | `<Name>.tsx` | คอมโพเนนต์ ครอบ `@base-ui/react` ไม่มี class ของ Tailwind ในไฟล์ map prop ไป class ของ module |
23
+ | `<Name>.module.css` | สไตล์ด้วย `@apply` ใน `@layer components` สีมาจาก component token เท่านั้น |
24
+ | `index.ts` | export ส่วนที่เป็น public |
25
+ | `<Name>.stories.tsx` | story ละสถานะ พร้อม `play` ตรวจพฤติกรรม ข้อความภาษาไทย |
26
+ | `<Name>.md` | usage doc ภาษาไทย (ดูหัวข้อด้านล่าง) |
27
+ | `<Name>.dsds.yaml` | context layer ภาษาอังกฤษตาม DSDS: กฎการใช้งานแบบมีระดับ เหตุผล และสิ่งที่ตรวจ (ดู `AGENTS.md`) |
28
+
29
+ 2. **export** จาก `packages/ui/src/index.ts` (เรียงตามตัวอักษร) และเพิ่ม `rel: file` ของ `<Name>.dsds.yaml` ใน `packages/ui/src/index.dsds.yaml`
30
+ 3. ถ้าคอมโพเนนต์ใช้ hook หรือ context ใส่ `"use client"` บรรทัดแรก และเพิ่มชื่อในรายการของ `AGENTS.md`
31
+ 4. **ข้อความที่ผู้ใช้เห็น** (รวม `aria-label`) เป็นภาษาไทย วันที่เป็นปี พ.ศ.
32
+ 5. **Code Connect** (ถ้ามีคอมโพเนนต์นี้ในไฟล์ Figma): เพิ่ม `packages/ui/figma/<Name>.figma.ts` ที่ map property ใน Figma ไปเป็น prop ในโค้ด ดูหัวข้อ Code Connect ใน `AGENTS.md`
33
+
34
+ ## Styling rules
35
+
36
+ - **สี**: ใช้ component token แบบ `@apply bg-(--button-primary-bg) text-(--button-primary-fg);` ถ้ายังไม่มี เพิ่มใน `theme.css` (ดูหัวข้อ token ด้านล่าง) ไม่ใช้ค่าสีตรง ๆ หรือ `bg-primary/80`
37
+ - **Focus**: `focus-visible:border-(--focus-ring) focus-visible:ring-2 focus-visible:ring-(--focus-ring)` ทุกตัวที่โฟกัสได้
38
+ - **ข้อมูลไม่ถูกต้อง**: `aria-invalid:border-(--invalid-border) aria-invalid:ring-3 aria-invalid:ring-(--invalid-ring) aria-invalid:focus-visible:ring-2 aria-invalid:focus-visible:ring-(--invalid-border)`
39
+ - **โหมดมืด**: สีที่ต่างตามโหมดกำหนดใน `.dark` ของ `theme.css` ไม่ใช่ `:global(.dark)` ในไฟล์ module
40
+ - **ลำดับ**: กฎสถานะ (focus, invalid, disabled) อยู่หลังกฎ variant
41
+ - **มุมโค้ง**: ใช้ระดับจาก [Radius](./Radius.md) ไม่ใช้ค่า px ตรง ๆ
42
+
43
+ ## Add or change a token
44
+
45
+ 1. แก้ `packages/ui/src/styles/theme.css`
46
+ - **primitive token** (`--palette-*`): เพิ่มเฉพาะเมื่อ semantic token ต้องการสีที่ยังไม่มี ใส่ในบล็อก `:root` แรกของ `theme.css` ตั้งชื่อตามสเกล Tailwind (ถ้าค่าตรงกับ Tailwind ใช้ระดับเดียวกัน) ใช้ใน semantic token เท่านั้น
47
+ - **semantic token**: ใส่ทั้งใน `:root` และ `.dark` ค่าเป็น `var(--palette-…)` (สีโปร่งแสงเพิ่มเป็น primitive แยก เช่น `--palette-white-a10` ไม่ใช้ `color-mix()` เพราะ fallback ของ build เป็นสีทึบ) และเพิ่มใน `@theme inline` ถ้าต้องการ utility ชื่อสั้น
48
+ - **component token**: ใส่ใน `:root, .dark` ใต้ความเห็นชื่อกลุ่ม (เช่น `/* Button */`) ชี้ไปที่ semantic token ค่าที่ต่างในโหมดมืดใส่ใน `.dark` ด้านล่าง
49
+ 2. เพิ่มคำอธิบายภาษาไทยของ token ใน `SEMANTIC_DESC` / `COMPONENT_DESC` ใน `packages/ui/scripts/tokens.mjs` (primitive ไม่ต้อง ตารางจะบอกเองว่าตรงกับสีไหนของ Tailwind)
50
+ 3. ถ้า token วางตัวอักษรหรือขอบบนพื้นใหม่ เพิ่มคู่ใน `CONTRAST_PAIRS`
51
+ 4. รัน
52
+
53
+ ```bash
54
+ pnpm tokens:check # ทุกคู่ต้องผ่าน WCAG AA
55
+ pnpm tokens:docs # สร้างตารางใน docs/Colors.md, ComponentTokens.md, Accessibility.md
56
+ ```
57
+
58
+ 5. แก้ตาราง "Tokens used" ใน `<Name>.md` ของคอมโพเนนต์ที่ใช้ token นั้น
59
+ 6. ค่าสีมาจากแอป `labdsnovweek1` (`src/app/globals.css`) TODO: ยังไม่ได้ตัดสินใจว่าไฟล์ไหนเป็นต้นฉบับ แจ้งทีมแอปเมื่อเปลี่ยนค่า
60
+
61
+ ## Write the usage doc
62
+
63
+ `<Name>.md` มีหัวข้อตามลำดับนี้ (ดูตัวอย่างใน [Button](../src/components/Button/Button.md)):
64
+
65
+ 1. **Purpose**: หนึ่งบรรทัด
66
+ 2. **Import and usage**: การตั้งค่าครั้งเดียวในแอป, import และตัวอย่างสั้น ๆ
67
+ 3. **When to use** / **When not to use** (บอกว่าใช้อะไรแทน)
68
+ 4. **Props and variants**: เฉพาะที่มีจริง
69
+ 5. **Tokens used**: ตาราง "Component tokens" แล้วตาราง "Semantic tokens" พร้อมค่าโหมดสว่าง/มืด
70
+ 6. **Example**: หนึ่งตัวอย่างที่ยกมาจาก story
71
+
72
+ - เขียนให้นักออกแบบและ AI agent อ่าน ไม่ใส่รายละเอียดการ implement (export, data attribute, class)
73
+ - สิ่งที่ยังไม่แน่ใจหรือยังไม่ได้ตัดสินใจ เขียนเป็น `TODO:` ห้ามเดา
74
+ - แก้ prop, variant, token หรือพฤติกรรม ต้องแก้ `.md` และ `.dsds.yaml` ใน change เดียวกัน
75
+ - story file import doc ด้วย `import guidelines from "./<Name>.md?raw"` แล้วส่งผ่าน `usageDoc()` เข้า `parameters.docs.description.component` เพื่อแสดงในหน้า Docs
76
+
77
+ ## Write stories
78
+
79
+ - `tags: ["autodocs"]` และใช้ `fn()` กับ event prop
80
+ - หนึ่ง story ต่อหนึ่งสถานะ: disabled, `aria-invalid`, focus จากคีย์บอร์ด, โหมดมืด (`globals: { theme: "dark" }`)
81
+ - `play` ตรวจด้วยสถานะ (`aria-expanded`, `data-open`) ไม่ใช่ `toBeVisible()` เพราะ popup มี animation
82
+ - พิมพ์ข้อความใน `play` ใช้ `fireEvent.change` ไม่ใช่ `userEvent.type`
83
+ - popup ถูก portal ไปที่ `document.body` ค้นด้วย `screen` ไม่ใช่ `canvas`
84
+
85
+ ## Before you open a pull request
86
+
87
+ ```bash
88
+ pnpm format # จัดรูปแบบโค้ดก่อน CI ตรวจด้วย pnpm format:check
89
+ pnpm typecheck
90
+ pnpm lint
91
+ pnpm tokens:check
92
+ pnpm dsds:check # ตรวจ .dsds.yaml กับ schema และโค้ด
93
+ pnpm build
94
+ pnpm check:dist # ตรวจ dist หลัง build
95
+ pnpm changeset # เพิ่ม changeset ถ้า change นี้กระทบสิ่งที่ publish ใน packages/ui
96
+ ```
97
+
98
+ - คำสั่งชุดนี้คือสิ่งที่ GitHub Actions (`.github/workflows/ci.yml`) รันกับทุก pull request ที่เข้า `main` หรือ `develop` ถ้าไม่ผ่านจะ merge ไม่ได้ (เมื่อตั้ง branch protection แล้ว)
99
+ - merge เข้า `develop` ที่มี changeset ค้างอยู่ CI จะ publish เวอร์ชัน beta (`x.y.z-beta.N`, ติดตั้งด้วย `@beta`) ให้เอง
100
+ - merge เข้า `main` แล้ว bot จะเปิด PR "chore: version packages" พอ merge PR นั้น CI จะ publish เวอร์ชัน stable (`latest`) ขั้นตอนทั้งหมดอยู่ใน `RELEASING.md`
101
+
102
+ - เปิด Storybook ดูทุก story ที่แก้ ทั้งโหมดสว่างและมืด และดูว่า `play` ผ่านในแผง Interactions
103
+ - hover และสถานะ `:active` บังคับใน story ไม่ได้ ตรวจด้วยมือ
104
+ - ตรวจ `packages/ui/dist/` ตามหัวข้อ "Checking a build" ใน `AGENTS.md`