@godxjp/ui 19.5.0 → 20.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/dist/components/data-display/card.d.ts +2 -2
  2. package/dist/components/data-display/collapsible.d.ts +23 -4
  3. package/dist/components/data-display/collapsible.js +119 -4
  4. package/dist/components/data-display/index.d.ts +3 -1
  5. package/dist/components/data-display/index.js +2 -0
  6. package/dist/components/data-display/legend.d.ts +15 -0
  7. package/dist/components/data-display/legend.js +11 -0
  8. package/dist/components/data-display/list-row.js +1 -1
  9. package/dist/components/data-display/popover.d.ts +58 -5
  10. package/dist/components/data-display/popover.js +206 -27
  11. package/dist/components/data-display/progress.d.ts +50 -2
  12. package/dist/components/data-display/progress.js +57 -9
  13. package/dist/components/data-entry/calendar.d.ts +1 -1
  14. package/dist/components/data-entry/calendar.js +67 -32
  15. package/dist/components/data-entry/checkbox.d.ts +19 -6
  16. package/dist/components/data-entry/checkbox.js +55 -16
  17. package/dist/components/data-entry/choice-option.d.ts +1 -1
  18. package/dist/components/data-entry/date-range-picker.d.ts +1 -1
  19. package/dist/components/data-entry/field.js +0 -1
  20. package/dist/components/data-entry/form.js +1 -1
  21. package/dist/components/data-entry/label.d.ts +3 -2
  22. package/dist/components/data-entry/label.js +23 -10
  23. package/dist/components/data-entry/month-picker.d.ts +1 -1
  24. package/dist/components/data-entry/month-range-picker.d.ts +1 -1
  25. package/dist/components/data-entry/transfer.js +16 -6
  26. package/dist/components/data-entry/tree-select-strategy.d.ts +1 -1
  27. package/dist/components/data-entry/tree-select.js +29 -12
  28. package/dist/components/data-entry/tree-utils.d.ts +1 -1
  29. package/dist/components/data-entry/upload.js +7 -2
  30. package/dist/components/feedback/dialog.d.ts +105 -38
  31. package/dist/components/feedback/dialog.js +272 -194
  32. package/dist/components/feedback/overlay-close-focus.d.ts +31 -0
  33. package/dist/components/feedback/overlay-close-focus.js +31 -0
  34. package/dist/components/feedback/overlay-header-tone.d.ts +1 -1
  35. package/dist/components/feedback/sheet.d.ts +53 -11
  36. package/dist/components/feedback/sheet.js +150 -81
  37. package/dist/components/feedback/tooltip.d.ts +51 -7
  38. package/dist/components/feedback/tooltip.js +107 -25
  39. package/dist/components/general/button.js +2 -2
  40. package/dist/components/general/logo.d.ts +17 -0
  41. package/dist/components/general/logo.js +22 -16
  42. package/dist/components/general/typography.d.ts +7 -1
  43. package/dist/components/general/typography.js +20 -5
  44. package/dist/components/layout/app-shell.d.ts +1 -1
  45. package/dist/components/layout/app-shell.js +52 -8
  46. package/dist/components/layout/aspect-ratio.js +0 -1
  47. package/dist/components/layout/auth-divider.js +0 -1
  48. package/dist/components/layout/flex.d.ts +1 -1
  49. package/dist/components/layout/flex.js +19 -2
  50. package/dist/components/layout/nav-surface.d.ts +26 -0
  51. package/dist/components/layout/nav-surface.js +17 -0
  52. package/dist/components/layout/org-switcher.d.ts +5 -1
  53. package/dist/components/layout/org-switcher.js +5 -3
  54. package/dist/components/layout/separator.js +0 -1
  55. package/dist/components/layout/sidebar.js +4 -1
  56. package/dist/components/layout/split-pane.d.ts +14 -1
  57. package/dist/components/layout/split-pane.js +26 -13
  58. package/dist/components/layout/topbar-item.js +1 -2
  59. package/dist/components/navigation/app-setting-picker.js +21 -2
  60. package/dist/components/navigation/app-setting-toggle.d.ts +16 -0
  61. package/dist/components/navigation/app-setting-toggle.js +96 -0
  62. package/dist/components/navigation/dropdown-menu.d.ts +199 -18
  63. package/dist/components/navigation/dropdown-menu.js +344 -117
  64. package/dist/components/navigation/index.d.ts +2 -0
  65. package/dist/components/navigation/index.js +2 -0
  66. package/dist/components/navigation/pagination-utils.d.ts +2 -1
  67. package/dist/components/navigation/tabs.d.ts +47 -6
  68. package/dist/components/navigation/tabs.js +152 -90
  69. package/dist/components/ui/accordion.d.ts +50 -5
  70. package/dist/components/ui/accordion.js +239 -33
  71. package/dist/components/ui/aspect-ratio.d.ts +23 -2
  72. package/dist/components/ui/aspect-ratio.js +15 -13
  73. package/dist/components/ui/avatar.d.ts +29 -4
  74. package/dist/components/ui/avatar.js +111 -25
  75. package/dist/components/ui/hover-card.d.ts +42 -4
  76. package/dist/components/ui/hover-card.js +183 -27
  77. package/dist/components/ui/label.js +0 -1
  78. package/dist/components/ui/segmented.d.ts +3 -3
  79. package/dist/components/ui/separator.d.ts +8 -2
  80. package/dist/components/ui/separator.js +17 -9
  81. package/dist/components/ui/toggle-group.d.ts +50 -5
  82. package/dist/components/ui/toggle-group.js +79 -20
  83. package/dist/components/ui/toggle.d.ts +31 -5
  84. package/dist/components/ui/toggle.js +42 -3
  85. package/dist/i18n/messages/en.json +8 -0
  86. package/dist/i18n/messages/ja.json +8 -0
  87. package/dist/i18n/messages/vi.json +8 -0
  88. package/dist/lib/control-styles.d.ts +1 -1
  89. package/dist/lib/control-styles.js +1 -1
  90. package/dist/lib/slot.d.ts +32 -0
  91. package/dist/lib/slot.js +22 -0
  92. package/dist/lib/variants.d.ts +22 -3
  93. package/dist/lib/variants.js +56 -1
  94. package/dist/props/components/app.prop.d.ts +25 -1
  95. package/dist/props/components/data-display.prop.d.ts +17 -0
  96. package/dist/props/components/data-entry.prop.d.ts +32 -4
  97. package/dist/props/components/general.prop.d.ts +31 -1
  98. package/dist/props/components/index.d.ts +1 -1
  99. package/dist/props/components/layout.prop.d.ts +118 -5
  100. package/dist/props/components/navigation.prop.d.ts +1 -1
  101. package/dist/props/registry.d.ts +22 -2
  102. package/dist/props/registry.js +33 -2
  103. package/dist/props/vocabulary/content.prop.d.ts +1 -1
  104. package/dist/props/vocabulary/index.d.ts +2 -2
  105. package/dist/props/vocabulary/interaction.prop.d.ts +17 -1
  106. package/dist/props/vocabulary/layout.prop.d.ts +57 -1
  107. package/dist/styles/control.css +142 -1
  108. package/dist/styles/core.css +5 -2
  109. package/dist/styles/data-display-layout.css +72 -0
  110. package/dist/styles/focus-ring.css +13 -1
  111. package/dist/styles/index.css +5 -2
  112. package/dist/styles/layout.css +106 -0
  113. package/dist/styles/shell-layout.css +140 -8
  114. package/dist/styles/text-layout.css +16 -4
  115. package/dist/tokens/base.css +2 -1
  116. package/dist/tokens/components/data-display.css +11 -0
  117. package/dist/tokens/components/shell.css +3 -1
  118. package/dist/tokens/components/text.css +7 -0
  119. package/dist/tokens/foundation.css +2 -0
  120. package/docs/COMPONENTS.md +9 -3
  121. package/docs/DESIGN-AUTHORITY.md +96 -71
  122. package/docs/FRAME-COVERAGE-REPORT.md +5 -3
  123. package/docs/README.md +14 -14
  124. package/docs/WHAT-BELONGS-HERE.md +179 -0
  125. package/docs/data-display/legend.tsx +145 -0
  126. package/docs/data-display/progress.tsx +32 -0
  127. package/docs/data-entry/segmented.tsx +1 -1
  128. package/docs/data-entry/select.tsx +2 -2
  129. package/docs/feedback/sheet.tsx +1 -1
  130. package/docs/general/typography.tsx +84 -1
  131. package/docs/layout/app-shell-arrangements.tsx +225 -0
  132. package/docs/layout/aspect-ratio.tsx +1 -1
  133. package/docs/navigation/app-setting-picker.tsx +26 -1
  134. package/docs/navigation/app-setting-toggle.tsx +111 -0
  135. package/package.json +11 -8
  136. package/scripts/_agent-setup.mjs +165 -3
  137. package/scripts/consumer-rule.md +98 -0
  138. package/scripts/guinea-pig-skill.md +322 -0
  139. package/scripts/init-guinea-pig.mjs +62 -0
  140. package/scripts/postinstall.mjs +13 -2
  141. package/scripts/ui-audit.mjs +115 -14
  142. /package/dist/tokens/{antd.generated.css → derived.css} +0 -0
@@ -4,10 +4,15 @@
4
4
  * NON-DESTRUCTIVE: it only creates a missing file or ADDS a missing key, never
5
5
  * overwrites existing config.
6
6
  */
7
+ import { createHash } from "node:crypto";
7
8
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
8
9
  import { dirname, join } from "node:path";
10
+ import { fileURLToPath } from "node:url";
9
11
 
10
12
  /** The godxjp-ui MCP server — pulled on demand via npx (no extra dependency to ship). */
13
+ /** This package's own root — the source of the version we stamp with. */
14
+ const SELF_ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
15
+
11
16
  export const MCP_SERVER = { command: "npx", args: ["@godxjp/ui-mcp"] };
12
17
  export const MCP_KEY = "godx-ui";
13
18
 
@@ -16,7 +21,47 @@ export const AUDIT_HOOK_CMD = "node node_modules/@godxjp/ui/scripts/audit-hook.m
16
21
  export const PRIMER_CMD = "cat .claude/godxjp-ui-workflow.md";
17
22
 
18
23
  /** The per-session workflow mandate the SessionStart hook injects into the agent. */
19
- export const WORKFLOW_MD = `# @godxjp/ui mandatory workflow (read every session)
24
+ export const KIT_VERSION = readJson(join(SELF_ROOT, "package.json"))?.version ?? "0.0.0";
25
+
26
+ const STAMP = (v) => `<!-- godxjp-ui:version ${v} -->`;
27
+ const STAMP_RE = /<!-- godxjp-ui:version ([^\s]+) -->/;
28
+
29
+ /** The version stamped in `text`, or null when it predates stamping. */
30
+ export function stampedVersion(text) {
31
+ return text?.match(STAMP_RE)?.[1] ?? null;
32
+ }
33
+
34
+ /**
35
+ * A stamp that tracks the CONTENT, for the files this package owns outright.
36
+ *
37
+ * A version stamp answers "which release wrote this", which is the wrong question for a file whose
38
+ * whole job is to carry current guidance. Measured: editing `consumer-rule.md` without bumping the
39
+ * package left two of three consumers holding the previous text, with a stamp that read as current
40
+ * and nothing anywhere reporting a difference. The rules are edited far more often than the
41
+ * version moves — most of all while they are being written, which is exactly when a stale copy
42
+ * does the most damage.
43
+ *
44
+ * So the digest goes in alongside the version: the version stays for humans reading the file, and
45
+ * the digest is what the refresh actually compares. Identical body → still a no-op.
46
+ */
47
+ const DIGEST_RE = /<!-- godxjp-ui:digest ([0-9a-f]{12}) -->/;
48
+ const digestOf = (body) => createHash("sha256").update(body).digest("hex").slice(0, 12);
49
+ const OWNED_STAMP = (body) => `${STAMP(KIT_VERSION)}\n<!-- godxjp-ui:digest ${digestOf(body)} -->`;
50
+
51
+ /** The content digest stamped in `text`, or null when it predates digest stamping. */
52
+ export function stampedDigest(text) {
53
+ return text?.match(DIGEST_RE)?.[1] ?? null;
54
+ }
55
+
56
+ /**
57
+ * Replace the MANAGED region of a file and leave everything else alone.
58
+ *
59
+ * Refreshing is only safe if it cannot eat hand-written content, so the contract is narrow: the
60
+ * region is delimited, and anything outside the delimiters survives byte-for-byte. A consumer that
61
+ * appended repo-specific sections keeps them.
62
+ */
63
+ export const WORKFLOW_MD = `${STAMP(KIT_VERSION)}
64
+ # @godxjp/ui — mandatory workflow (read every session)
20
65
 
21
66
  You are building UI in an app that uses @godxjp/ui. Follow this EVERY time you create
22
67
  or change a component, page, or form — no exceptions.
@@ -50,6 +95,7 @@ or change a component, page, or form — no exceptions.
50
95
  /** Delimited block appended to the consumer's CLAUDE.md — loaded into the agent's context
51
96
  * every turn (the most reliable "ensure it reads the rules"). Markers keep it idempotent. */
52
97
  export const CLAUDE_MD_BLOCK = `<!-- godxjp-ui:start (managed by @godxjp/ui — edit .claude/godxjp-ui-workflow.md instead) -->
98
+ ${STAMP(KIT_VERSION)}
53
99
  ## @godxjp/ui — mandatory UI workflow (do NOT skip)
54
100
 
55
101
  This app uses @godxjp/ui. EVERY time you build or change UI:
@@ -82,6 +128,24 @@ function readJson(path) {
82
128
  }
83
129
 
84
130
  /** Ensure `.mcp.json` registers the godx-ui MCP server. Returns 'created' | 'added' | 'present'. */
131
+ /**
132
+ * The version that wrote each managed artefact, stamped so `postinstall` can tell "already there"
133
+ * apart from "already there and STALE".
134
+ *
135
+ * Everything below used to be install-once: `ensureMcpJson` returned early on a present key,
136
+ * `writeWorkflowMd` on a present file, `ensureClaudeMd` on a present marker. So `npm update
137
+ * @godxjp/ui` brought new components, new audit rules and new catalog entries — and left the
138
+ * agent reading whatever guidance shipped the day the package was FIRST installed. The library
139
+ * moved; the instructions for using it did not.
140
+ */
141
+ export function refreshBlock(current, next, startMarker, endMarker) {
142
+ const i = current.indexOf(startMarker);
143
+ if (i < 0) return current.replace(/\s*$/, "") + "\n\n" + next;
144
+ const j = endMarker ? current.indexOf(endMarker, i) : -1;
145
+ const tail = j < 0 ? "" : current.slice(j + endMarker.length);
146
+ return current.slice(0, i) + next + tail;
147
+ }
148
+
85
149
  export function ensureMcpJson(root) {
86
150
  const path = join(root, ".mcp.json");
87
151
  const json = readJson(path) ?? {};
@@ -127,7 +191,14 @@ export function ensureClaudeHooks(root) {
127
191
  export function writeWorkflowMd(root) {
128
192
  const path = join(root, ".claude", "godxjp-ui-workflow.md");
129
193
  mkdirSync(dirname(path), { recursive: true });
130
- if (existsSync(path)) return false;
194
+ // This file is owned entirely by the package — the CLAUDE.md block tells the consumer to edit
195
+ // it, but nothing else reads from it, so a stale copy is pure loss. Rewrite when the stamp moves.
196
+ if (existsSync(path)) {
197
+ const cur = readFileSync(path, "utf8");
198
+ if (stampedVersion(cur) === KIT_VERSION) return false;
199
+ writeFileSync(path, WORKFLOW_MD);
200
+ return "refreshed";
201
+ }
131
202
  writeFileSync(path, WORKFLOW_MD);
132
203
  return true;
133
204
  }
@@ -139,7 +210,16 @@ export function writeWorkflowMd(root) {
139
210
  export function ensureClaudeMd(root) {
140
211
  const path = join(root, "CLAUDE.md");
141
212
  const existing = existsSync(path) ? readFileSync(path, "utf8") : null;
142
- if (existing?.includes("godxjp-ui:start")) return "present";
213
+ if (existing?.includes("godxjp-ui:start")) {
214
+ // Present — but at WHICH version? Refresh only the delimited block; anything the consumer
215
+ // wrote around it is untouched.
216
+ if (stampedVersion(existing) === KIT_VERSION) return "present";
217
+ writeFileSync(
218
+ path,
219
+ refreshBlock(existing, CLAUDE_MD_BLOCK, "<!-- godxjp-ui:start", "<!-- godxjp-ui:end -->"),
220
+ );
221
+ return "refreshed";
222
+ }
143
223
  if (existing == null) {
144
224
  writeFileSync(path, CLAUDE_MD_BLOCK);
145
225
  return "created";
@@ -157,3 +237,85 @@ export function shouldSkip(root) {
157
237
  if (pkg.name === "@godxjp/ui" || pkg.name === "@godxjp/ui-mcp") return "self";
158
238
  return null;
159
239
  }
240
+
241
+ /**
242
+ * Keep an opted-in guinea-pig skill current.
243
+ *
244
+ * The file is co-authored: sections 0–7 come from this package, and section 8 onward is whatever
245
+ * the repo wrote about ITSELF — its package manager, its audit baseline, its deliberate
246
+ * exceptions. So the refresh replaces the head and keeps the tail, which is the only split that
247
+ * lets the guidance move without eating the consumer's own notes.
248
+ *
249
+ * Only runs where `.guinea-pig-optin` exists: the skill carries an obligation to fix things
250
+ * UPSTREAM, and pushing that into a repo that never asked for it would tell its agent to go edit
251
+ * a library it has no mandate over.
252
+ */
253
+ export function refreshGuineaPigSkill(root) {
254
+ const dir = join(root, ".claude", "skills", "godx-ui-guinea-pig");
255
+ const target = join(dir, "SKILL.md");
256
+ const optin = join(dir, ".guinea-pig-optin");
257
+ if (!existsSync(optin) || !existsSync(target)) return false;
258
+ if (readFileSync(optin, "utf8").trim() === KIT_VERSION) return false;
259
+
260
+ const base = readFileSync(join(SELF_ROOT, "scripts", "guinea-pig-skill.md"), "utf8");
261
+ const current = readFileSync(target, "utf8");
262
+ const marker = "\n---\n\n# 8. ";
263
+ const i = current.indexOf(marker);
264
+ writeFileSync(target, base.replace(/\s*$/, "") + "\n" + (i < 0 ? "" : current.slice(i)));
265
+ writeFileSync(optin, `${KIT_VERSION}\n`);
266
+ return true;
267
+ }
268
+
269
+ /**
270
+ * Install the common consumer rules as a PATH-TRIGGERED file, and wire them into `.ai/rules`.
271
+ *
272
+ * The skill and this file say overlapping things on purpose, because they fire at different
273
+ * moments: a skill loads when the TASK matches its description — once, at the start — while an
274
+ * `.ai/rules` entry loads every time an agent touches a file under its glob. Measured over one
275
+ * session: a dashboard file was edited dozens of times and the skill was never re-read, so the
276
+ * laws that mattered were out of context for every edit after the first.
277
+ *
278
+ * The glob is DETECTED, not assumed. A rule wired to a directory the repo does not have is a rule
279
+ * that never fires, which is worse than no rule at all — it looks installed.
280
+ *
281
+ * Unlike the skill, this file is owned OUTRIGHT by the package and is rewritten whole. That is the
282
+ * honest shape for `.ai/rules`, where the convention is one file per concern and the index loads
283
+ * them all: a repo with something of its own to say writes its own rule file instead of editing
284
+ * this one. The file says so at the top, because the first draft preserved nothing and silently
285
+ * ate a note left inside it — measured, and the reason for that banner.
286
+ */
287
+ export function ensureConsumerRules(root) {
288
+ const uiDir = ["resources/js", "app/javascript", "src/components", "src", "app"].find((d) =>
289
+ existsSync(join(root, d)),
290
+ );
291
+ if (!uiDir) return false;
292
+
293
+ const dir = join(root, ".ai", "rules");
294
+ const target = join(dir, "godxjp-ui.md");
295
+ const body = readFileSync(join(SELF_ROOT, "scripts", "consumer-rule.md"), "utf8");
296
+ const front = `---\npaths:\n - '${uiDir}/**'\n---\n\n`;
297
+ // The digest covers the FRONT MATTER too: the detected glob is part of what makes this file
298
+ // correct, and a repo that grows a `resources/js` after shipping with `src` needs the rewrite.
299
+ const managed = `${front}${body}`;
300
+ const next = `${OWNED_STAMP(managed)}\n${managed}`;
301
+
302
+ if (existsSync(target) && stampedDigest(readFileSync(target, "utf8")) === digestOf(managed)) {
303
+ return false;
304
+ }
305
+ mkdirSync(dir, { recursive: true });
306
+ writeFileSync(target, next);
307
+
308
+ // Only touch the index when the repo keeps one; a missing index means the repo reads rule files
309
+ // directly, and inventing one would change how it loads everything else.
310
+ const index = join(dir, "index.md");
311
+ if (existsSync(index)) {
312
+ const cur = readFileSync(index, "utf8");
313
+ if (!cur.includes(".ai/rules/godxjp-ui.md")) {
314
+ writeFileSync(
315
+ index,
316
+ cur.replace(/\s*$/, "") + `\n| ${uiDir}/** | .ai/rules/godxjp-ui.md |\n`,
317
+ );
318
+ }
319
+ }
320
+ return uiDir;
321
+ }
@@ -0,0 +1,98 @@
1
+ # @godxjp/ui
2
+
3
+ > **Tệp này do gói `@godxjp/ui` sở hữu và bị GHI ĐÈ mỗi lần nâng cấp.**
4
+ > Đừng sửa ở đây — luật của riêng kho thuộc về một tệp khác trong `.ai/rules/`,
5
+ > và index sẽ nạp cả hai. (Khác với `.claude/skills/.../SKILL.md`, nơi mục §8
6
+ > trở đi là của kho và được giữ lại.)
7
+
8
+ Đây là **danh sách kiểm** bắn mỗi lần chạm một tệp UI. Lý do đầy đủ nằm ở
9
+ `docs/CONSUMER-RULES.md` (10 luật) và, với kho chuột bạch, ở
10
+ `.claude/skills/godx-ui-guinea-pig/SKILL.md`.
11
+
12
+ ## Bố cục chuẩn của platform: BA CỘT, và ba cột là BA PHẠM VI
13
+
14
+ Vỏ mặc định của mọi app trên platform là ba cột, dựng bằng một `AppShell`:
15
+
16
+ ```
17
+ navRail (3.5rem) │ sidebar (16rem) │ content
18
+ ```
19
+
20
+ Không tự dựng ba cột bằng cách nhét hai cột vào một khe `sidebar` rồi nới
21
+ `--app-shell-sidebar-width`. Hai bẫy đã đo được: `Sidebar` render
22
+ `.sb-root { display: contents }` nên hai `Sidebar` đặt cạnh nhau **tan vào một
23
+ flex row** và cùng co về 0; và nới token dùng chung khiến mép nội dung **nhảy
24
+ 64px giữa các route**. `navRail` sở hữu track riêng nên không cần cả hai.
25
+
26
+ **Đặt một control vào cột nào là câu hỏi về PHẠM VI, không phải về chỗ trống:**
27
+
28
+ | Cột | Phạm vi | Chứa gì |
29
+ | --------- | ------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
30
+ | `navRail` | **platform** — đúng với cả tổ chức, sống sót qua việc đổi app | đổi tổ chức · đổi app · thông báo · tin nhắn · sự kiện · cài đặt tổ chức · lối tắt liên-app |
31
+ | `sidebar` | **app** — của riêng app đang mở | mục/kênh/route của chính app này |
32
+ | `topbar` | **trang** — bạn đang ở đâu, làm được gì ở đây | breadcrumb · hành động của trang · menu tài khoản |
33
+
34
+ Hai luật phủ định, và chúng làm được việc:
35
+
36
+ - Điều hướng của app **không bao giờ** vào rail. Một rail lặp lại mục của
37
+ sidebar là dải chrome thứ hai mang thứ hạng của dải thứ nhất, chỉ dựng đứng.
38
+ - Công tắc cấp platform **không bao giờ** vào sidebar — đổi app xong nó biến
39
+ mất, trong khi nó vẫn phải ở đó.
40
+ - Đích nào hợp cả hai thì thuộc **rail**: nó sống sót qua việc đổi app.
41
+
42
+ `sidebarCollapsed` chỉ gập cột `sidebar`; rail giữ nguyên bề rộng, nên đích cấp
43
+ platform vẫn với tới được lúc gập. Đừng dựng lại hành vi này bằng CSS của kho.
44
+
45
+ Bề rộng rail là token `--app-shell-nav-rail-width` — kho nào muốn rail rộng kiểu
46
+ Slack thì đặt lại **một dòng**, không fork `.app-nav-rail`.
47
+
48
+ ## Trước khi viết bố cục: TRA, đừng dựng
49
+
50
+ Hỏi MCP `godxjp-ui` (`search_components`, `get_component`). Đo được trong một
51
+ ngày: năm thứ cần đều ĐÃ CÓ và vẫn bị dựng lại bằng thứ khác —
52
+
53
+ | Cần | Đã có |
54
+ | ---------------------------------------- | --------------------- |
55
+ | đường kẻ chạm mép Card | `<CardContent flush>` |
56
+ | header có kẻ khi thân là danh sách flush | `<CardHeader banded>` |
57
+ | một hàng LÀ liên kết (thay cho nút rời) | `<ListRow asChild>` |
58
+ | kẻ ô từng ngày trong lịch | `<Calendar bordered>` |
59
+ | dải giữa hai vùng, tự kẻ theo VỊ TRÍ | `<CardBar>` |
60
+
61
+ Lỗi không phải "đoán sai tên prop" mà là **cho rằng nó không tồn tại nên không
62
+ hỏi**.
63
+
64
+ ## Catalog chở PROP, không chở LUẬT BỐ CỤC
65
+
66
+ `CardBar` trong manifest có đúng một prop (`extra`) — không dòng nào nói nó tự
67
+ kẻ theo vị trí (đầu: kẻ dưới · cuối: kẻ trên · giữa: cả hai). Luật ấy chỉ nằm
68
+ trong chú thích `node_modules/@godxjp/ui/src/styles/card-layout.css`.
69
+
70
+ **Làm bố cục trong một component của DS → mở tệp `*-layout.css` của nó ra đọc.**
71
+
72
+ ## Card không lồng Card
73
+
74
+ Một `<Card>` trong `<Card>` cho hai mép bo cách nhau 16px và hai lớp padding
75
+ chồng lên. Cần viền cho thứ bên trong thì tìm trục của chính nó
76
+ (`Calendar bordered`), đừng bọc thêm một mặt phẳng nữa.
77
+
78
+ Cùng lý do: đừng xếp `<Alert>` thành danh sách trong Card — mỗi Alert là một mặt
79
+ phẳng, và `Alert` còn phát `role="alert"` nên cả danh sách sẽ tự đọc to lên khi
80
+ tải trang. Danh sách là `ListRow`.
81
+
82
+ ## Màu chữ đọc tầng CHỮ, không đọc tầng TÔ
83
+
84
+ `--success/--warning/--info/--destructive` là màu **TÔ** (nền badge, thanh, viền
85
+ alert). Chữ đọc `--text-success/-warning/-info/-error`.
86
+
87
+ Đo được: `Text tone="warning"` đọc nhầm tầng cho **1,74:1**; đúng tầng cho
88
+ **5,90:1**. Cùng `tone` ấy trong `Badge` vẫn đạt 5,52:1 — nên cùng một prop
89
+ hiện đọc được ở chỗ này và không đọc được ở chỗ kia, trên cùng một màn hình.
90
+
91
+ ## Audit xanh ≠ chạy đúng
92
+
93
+ `ui-audit` xanh chỉ nghĩa là **không có gì cấm** bạn. Đo được: một consumer viết
94
+ `modifiers` + `modifiersClassNames` cho màu cuối tuần — audit xanh, tsc xanh,
95
+ build xanh, và **số màu chữ trên cả lưới vẫn là 1**, vì class rơi vào `<td>` còn
96
+ `<button>` tự đặt màu.
97
+
98
+ Một API chết im lặng trông y hệt một API đang chạy. **Mở trang và đo** mới biết.
@@ -0,0 +1,322 @@
1
+ ---
2
+ name: godx-ui-guinea-pig
3
+ description: "Bắt buộc cho mọi kho là consumer CHUỘT BẠCH của @godxjp/ui. Kích hoạt khi: dựng hay sửa bất kỳ màn hình nào, gặp một prop còn thiếu, định viết class Tailwind để lách, định tự dựng component thay cho thứ DS đã có, chạy ui-audit, hoặc thấy chú thích 'chờ upstream'. Dạy MỘT việc mà không tài liệu nào khác dạy: cách KHÉP VÒNG từ 'app thiếu gì' sang 'DS đã sửa, đã phát hành, app đã nâng, vá tạm đã gỡ'. Không dùng cho consumer thường — chuột bạch có nghĩa vụ sửa ngược lên DS, consumer thường thì không."
4
+ ---
5
+
6
+ # Consumer chuột bạch của @godxjp/ui
7
+
8
+ > Bản gốc của tệp này nằm ở kho `godx-jp/godxjp-ui`. Sửa thì sửa ở đó rồi chép
9
+ > sang các consumer, đừng sửa bản chép — kho này đã hỏng đúng kiểu ấy một lần
10
+ > với catalog MCP (xem §4).
11
+
12
+ ## 0. Bạn có HAI việc, không phải một
13
+
14
+ Việc thứ nhất là làm xong màn hình. Việc thứ hai là **để lại design system tốt
15
+ hơn lúc bạn gặp nó**. Chuột bạch là kho mà `@godxjp/ui` bị dùng thật lần đầu;
16
+ mọi khoảng trống lộ ra ở đây mà không được sửa ngược lên sẽ là khoảng trống
17
+ **vĩnh viễn** cho mọi consumer sau.
18
+
19
+ Vì vậy một bản vá tạm ở đây không phải là "nợ kỹ thuật của app". Nó là hai lần
20
+ thất bại: màn hình lệch chuẩn, VÀ khoảng trống bị giấu đi.
21
+
22
+ Bạn được toàn quyền sửa `@godxjp/ui`. Đó là điều kho này tồn tại để làm.
23
+
24
+ ## 1. Trước khi viết dòng JSX đầu tiên
25
+
26
+ Định vị bản checkout của DS. Không có thì clone:
27
+
28
+ ```bash
29
+ ls ~/Herd/godxjp-ui 2>/dev/null || git clone git@github.com:godx-jp/godxjp-ui.git ~/Herd/godxjp-ui
30
+ cd ~/Herd/godxjp-ui && pnpm install # DS dùng pnpm, consumer thường dùng npm — đừng lẫn
31
+ ```
32
+
33
+ Và hỏi MCP `godxjp-ui`, đừng đoán tên prop: `search_components`, `get_component`,
34
+ `get_tokens`. **Catalog là nguồn sự thật, không phải trí nhớ của bạn.**
35
+
36
+ ## 2. Kỷ luật — thứ bị cấm kể cả khi "chỉ tạm thôi"
37
+
38
+ Mười luật ở `docs/CONSUMER-RULES.md` của DS là hàng rào, `ui-audit` cưỡng chế
39
+ chúng. Không chép lại ở đây. Ba điều cấm riêng của **chuột bạch**:
40
+
41
+ 1. **Tự dựng component thay cho thứ DS đã có hoặc lẽ ra phải có.** Hộp tự vẽ
42
+ thay `Card`, hàng tự ghép thay `ListRow`, palette tự viết thay
43
+ `CommandPalette`.
44
+ 2. **Dùng class tiện ích để lách một prop còn thiếu** — `gap-3`, `p-4`,
45
+ `w-[240px]`, `text-muted-foreground`.
46
+ 3. **Gõ mã màu hex hay số đo ngoài thang token.**
47
+
48
+ Thước đo, chạy trước mọi lần review:
49
+
50
+ ```bash
51
+ node node_modules/@godxjp/ui/scripts/ui-audit.mjs resources/js # 0 lỗi là mức đạt
52
+ ```
53
+
54
+ Một lỗi bạn **không sửa được ở phía consumer** chính là một khoảng trống của DS.
55
+ Nó là đầu vào của §3, không phải một ngoại lệ để nới.
56
+
57
+ ## 3. Vòng lặp — sáu bước, và nó phải KHÉP
58
+
59
+ Đây là phần không tài liệu nào khác có. `design-to-page` và `compose-a-screen`
60
+ đều dừng ở `report-bug`; mở issue rồi để đó là hỏng nửa vời.
61
+
62
+ ### Bước 1 — Chứng minh đó là khoảng trống, đừng cảm thấy
63
+
64
+ Viết ra đúng đoạn mã bạn **muốn** viết, rồi chạy `ui-audit` lên nó.
65
+
66
+ Audit xanh nghĩa là **không có gì CẤM** bạn — chưa phải là bạn có nước đi. Nước
67
+ đi chỉ có thật khi bạn MỞ TRANG và thấy nó đổi pixel. Đo được: consumer viết
68
+ `modifiers` + `modifiersClassNames` cho màu cuối tuần, audit xanh, tsc xanh,
69
+ build xanh, và **số màu chữ trên cả lưới vẫn là 1** — class rơi vào `<td>` còn
70
+ `<button>` tự đặt màu. Một API chết im lặng trông y hệt một API đang chạy.
71
+
72
+ Chỉ khi mọi prop và token hiện có đều không nói được điều cần nói, VÀ mọi đường
73
+ còn lại đều bị audit chặn, thì mới là bất khả.
74
+
75
+ ### Bước 2 — Ba câu hỏi, phải đủ cả ba
76
+
77
+ Đọc `docs/WHAT-BELONGS-HERE.md` của DS. Tóm tắt không thay thế nó:
78
+
79
+ 1. Consumer có thật sự **không có nước đi hợp lệ** nào không? (không phải "bất tiện")
80
+ 2. Nó thuộc về **hình dạng** của component, hay **nội dung** của một màn?
81
+ 3. Consumer **khác** có cần không?
82
+
83
+ Trượt bất kỳ câu nào → dựng ở consumer, và ghi rõ TRONG MÃ vì sao nó không
84
+ thuộc về DS.
85
+
86
+ ### Bước 3 — Sửa trong DS, và sửa đủ bốn chỗ
87
+
88
+ ```
89
+ src/… mã
90
+ src/…/__tests__/ test (§5)
91
+ mcp/src/data/ catalog (§4 — chỗ hay quên nhất, và tốn kém nhất)
92
+ docs/ nếu đổi hợp đồng công khai
93
+ ```
94
+
95
+ Thứ tự ưu tiên, chỉ tiến khi bước trước thật sự không diễn đạt nổi:
96
+ **dùng → ghép → thêm prop vào component đã có → tạo component mới.**
97
+ Một prop nữa hơn một component nữa.
98
+
99
+ ### Bước 4 — Kiểm bằng tarball TRƯỚC khi phát hành
100
+
101
+ Đây là bước làm cho "vừa làm vừa trải nghiệm" thành thật. Đừng phát hành rồi
102
+ mới biết mình sửa trượt.
103
+
104
+ ```bash
105
+ cd ~/Herd/godxjp-ui
106
+ pnpm build && npm pack # ra @godxjp-ui-<version>.tgz
107
+ cd <kho consumer>
108
+ npm install ~/Herd/godxjp-ui/godxjp-ui-<version>.tgz
109
+ ```
110
+
111
+ Rồi chạy màn hình thật với bản sửa: `ui-audit` phải sạch **và** đoạn mã bạn
112
+ muốn viết ở Bước 1 phải chạy đúng. Nếu kho có bộ trình duyệt, chạy nó.
113
+
114
+ **Xong việc thì hoàn nguyên `package.json` về bản registry** — đừng để một
115
+ tarball đường dẫn máy bạn lọt vào commit. `main` phải `npm ci` được từ registry.
116
+
117
+ ### Bước 5 — Cổng của DS
118
+
119
+ ```bash
120
+ # = verify:ci:static + check:frame-contracts + pnpm test, tức ĐÚNG những gì ci.yml chạy.
121
+ cd ~/Herd/godxjp-ui && pnpm verify:ci
122
+ ```
123
+
124
+ **Không nới, không tắt, không thêm ngoại lệ để lấy màu xanh.** Một cổng đỏ là
125
+ một câu hỏi, không phải một chướng ngại. Nếu bạn tin cổng ấy sai thì nói ra và
126
+ đưa số đo, đừng lặng lẽ sửa nó.
127
+
128
+ ### Bước 6 — Khép vòng
129
+
130
+ Phát hành → nâng gói ở consumer → **gỡ vá tạm** → **gỡ mọi chú thích "chờ
131
+ upstream"** → **đóng issue**.
132
+
133
+ Vòng chưa khép thì việc chưa xong. Đợt 07–08/09/2026 mở 18 issue cho godxjp-ui;
134
+ #401/#412 và #402 đã vá trên nhánh nhưng issue vẫn mở và consumer vẫn chờ —
135
+ đó là hình dạng của thất bại này.
136
+
137
+ ## 4. Nghĩa vụ catalog — chỗ tốn kém nhất khi quên
138
+
139
+ **Một prop có trong mã nhưng không có trong catalog MCP là một prop KHÔNG TỒN
140
+ TẠI** với agent tiếp theo.
141
+
142
+ Đây không phải suy đoán. Đo được trong phiên 08/09/2026: một agent mới, làm
143
+ đúng mọi hướng dẫn (hỏi MCP, không đoán), kết luận _"Flex chỉ có gap"_ trong khi
144
+ `pad` và `padRaw` đã nằm trong gói đã cài — vì catalog đã phát hành chưa có
145
+ chúng. Nó làm đúng và vẫn ra sai.
146
+
147
+ Nên sau mỗi lần thêm hay đổi prop:
148
+
149
+ ```bash
150
+ node scripts/gen-component-api-manifest.mjs
151
+ pnpm check:mcp-sync && pnpm check:mcp-prop-sync && pnpm check:component-api-manifest
152
+ ```
153
+
154
+ Và kiểm ví dụ trong `mcp/src/data/{patterns,components}.ts` có **biên dịch được
155
+ và qua nổi ui-audit** không. Catalog đã từng dạy: `<Dialog mode="confirm">`
156
+ (không có API ấy), `variant="success"` (bị chính audit cấm),
157
+ `<Input onValueChange>` (không có prop ấy). Ví dụ sai trong catalog không phải
158
+ lỗi chính tả — nó là mã mà agent sau sẽ chép.
159
+
160
+ ## 5. Kỷ luật test của DS — luật, không phải gợi ý
161
+
162
+ - **Test theo TỪNG component**, và chỉ những component **liên quan** tới nó.
163
+ `Dropdown` = menu + list + button + icon → chỉ quanh chừng đó. Không test lan man.
164
+ - **Test của story/example KHÔNG nằm trong CI.** Chúng ở `tests/manual/`, chạy
165
+ bằng tay. CI không tiêu thời gian vào thứ vô bổ.
166
+ - Test bám vào **role và nhãn**, không bám class Tailwind — có cổng
167
+ `check:no-tailwind-class-assertions` chặn.
168
+
169
+ Vì sao role/nhãn: 138 trên 160 selector của bộ Playwright ở consumer bám vào
170
+ `getByRole`/`getByLabel`. Chúng không phải nghi thức a11y — chúng là cái cân cho
171
+ biết một lần đổi nền thư viện có làm vỡ CẤU TRÚC hay không. Gỡ chúng là mất cân.
172
+
173
+ Nhưng chúng **không đo được màu, bo góc, hay phần tử nào đang được tô** — cả một
174
+ đợt lỗi calendar đi qua chúng mà không cái nào đỏ. Cấu trúc và diện mạo là hai
175
+ thước khác nhau; xem §5c.
176
+
177
+ ## 5b. Một cổng canh được đúng thứ nó CHẠY QUA
178
+
179
+ Một cổng viết ra mà không nối vào CI là một cổng không tồn tại — y hệt một prop
180
+ không có trong catalog (§4). Nhưng "đã nối" chưa đủ, và đợt 08/09/2026 đo được
181
+ cả hai nửa của bài học này.
182
+
183
+ **Nửa thứ nhất — đừng đo bằng cái thước sai.** Bản trước của mục này viết rằng
184
+ "25 cổng `check:*` nằm ngoài `verify:ci`", và kết luận từ đó rằng chúng không
185
+ chạy. Kiểm lại bằng workflow thì 22 trong 25 cổng ấy VẪN chạy mỗi lần merge hoặc
186
+ mỗi đêm — chỉ là ở lane khác. Lý do rất đơn giản và rất dễ vấp: **không workflow
187
+ nào chạy `verify:ci`.** `ci.yml` chạy `verify:ci:static` + `check:frame-contracts`
188
+
189
+ - `pnpm test` chia shard; `ci-browser.yml` chạy `verify:browser` (gồm
190
+ `check:contrast`) và `check:frame-axe`; `ci-browser-full.yml` chạy các sweep rộng
191
+ theo lịch đêm; `release-integrity.yml` chạy `check:release-plan`. Hỏi "cổng này
192
+ có trong `verify:ci` không" là hỏi một script không ai gọi.
193
+
194
+ Nên đừng tự viết đoạn `node -e` so với `verify:ci`. Hỏi thẳng cổng canh-cổng, nó
195
+ đọc workflow rồi mới trả lời:
196
+
197
+ ```bash
198
+ pnpm check:gate-coverage --report # in ra: mỗi check:* chạy ở workflow nào
199
+ pnpm check:gate-coverage # đỏ nếu có cổng không ai chạy và không khai miễn trừ
200
+ ```
201
+
202
+ Cổng này nằm trong `verify:ci:static`, nên thêm một `check:` mới mà quên nối vào
203
+ đâu là CI đỏ ngay. Muốn để một cổng ngoài lề thì phải khai TƯỜNG MINH kèm lý do
204
+ trong `EXEMPT` của `scripts/check-gate-coverage.mjs` — hiện có đúng hai cái, và
205
+ cả hai đều là "cần người", không phải "chạy lâu": `check:voiceover-capture` (cần
206
+ VoiceOver thật do người bật) và `check:frame-runtime` (chỉ là alias gọi tám cổng
207
+ đã chạy riêng trong lane đêm). "Chạy lâu" không phải lý do để miễn trừ — đó là
208
+ lý do để nằm trong lane đêm, và lane đêm VẪN được tính là có chạy.
209
+
210
+ **Nửa thứ hai, và là nguyên nhân thật của lỗi đã lọt.** Một toast
211
+ `data-type="success"` với tương phản **1,02:1** — chữ gần như vô hình — phát hành
212
+ trong `@godxjp/ui@19.5.0` và bị bắt bởi **test trình duyệt của một consumer**.
213
+ Kho DS có sẵn hai thứ đáng lẽ phải bắt được nó, và **cả hai đều đã chạy trong
214
+ CI**:
215
+
216
+ - `scripts/check-contrast.mjs` chạy mỗi lần merge trong job "Contrast + visual
217
+ audit" (55–59s, và tên job nằm trong `REQUIRED_CI_CHECK_RUNS` nên bản phát
218
+ hành không đi qua nổi nếu nó đỏ). Nó xanh — vì danh sách `ROUTES` của nó có 11
219
+ route và **không route nào render một cái toast**.
220
+ - `src/components/feedback/__tests__/toast-tone-contrast.test.tsx` chạy trong
221
+ `pnpm test`. Nó xanh — vì nó đọc token trong `src/tokens/**` rồi tính tỉ số
222
+ trên giấy; nó chạy trong jsdom, mà jsdom **không tô màu**, nên nó không nhìn
223
+ thấy màu đã render thật.
224
+
225
+ Không cổng nào bị tắt. Không cổng nào bị bỏ quên. Cả hai đều xanh và cả hai đều
226
+ đúng với thứ chúng đo — chỉ là **không cái nào đo cái đã hỏng**. Đây là dạng
227
+ hỏng đắt hơn hẳn dạng "quên nối cổng", vì bảng CI toàn xanh trông y hệt như một
228
+ kho thật sự an toàn.
229
+
230
+ `check:contrast` đã dính đúng dạng này một lần rồi, và vết sẹo còn nằm trong
231
+ chú thích của chính nó: danh sách route từng trỏ vào `tiximax-*` sau khi các
232
+ route đó bị đổi tên, nên chúng render ra "Showcase not found" và sweep báo trang
233
+ rỗng ấy là AA sạch. Lần đó người ta thêm một guard chặn not-found. Lần này là
234
+ cùng một hình dạng ở một trục khác: route tồn tại, nhưng bề mặt cần soi thì
235
+ không có route nào chạm tới.
236
+
237
+ Nên khi bạn thêm hay sửa một cổng, hỏi HAI câu chứ không phải một:
238
+
239
+ 1. **Nó có chạy không?** → `pnpm check:gate-coverage --report`.
240
+ 2. **Nó có đi qua bề mặt tôi vừa đụng không?** → mở chính danh sách đầu vào của
241
+ cổng (`ROUTES` của `check-contrast.mjs`, danh sách frame của `check:frame-axe`,
242
+ `include` của `vitest.config.ts`) và tìm bề mặt ấy trong đó. Cổng xanh trên
243
+ một danh sách không chứa thứ bạn vừa sửa thì nó chưa nói gì về bản sửa của bạn.
244
+
245
+ Và một hệ quả cho phía consumer: **bộ test trình duyệt của bạn là lớp lưới cuối
246
+ cùng của DS.** Hai lỗi tương phản trên do `php artisan test` của consumer bắt
247
+ được, không phải do CI thư viện. Đừng bỏ axe ra khỏi bộ trình duyệt chỉ vì "hệ
248
+ thống nội bộ" — ở đây nó không đo tuân thủ, nó đo xem DS có phát ra chữ đọc được
249
+ hay không.
250
+
251
+ ## 5c. CSS hỏng IM LẶNG theo ba cách — và cách duy nhất thấy được
252
+
253
+ Một luật CSS sai không báo lỗi, không cảnh báo, và đọc lên vẫn thuyết phục. Ba
254
+ cơ chế, cả ba đo được trong một ngày:
255
+
256
+ 1. **Nhắm vào class không tồn tại.** `weekdays: cn("flex", …)` — không có class
257
+ DS, nên mọi luật viết cho `.ui-calendar-weekdays` chưa từng khớp lần nào.
258
+ 2. **Thua tầng khác.** `buttonVariants` đặt `rounded-[var(--button-radius)]` như
259
+ một Tailwind **utility**, mà `utilities` sau `components` — nên không luật
260
+ components nào đổi được bo góc của một Button. Phải trỏ lại chính biến đó.
261
+ Cùng lớp: CSS bên thứ ba nhập KHÔNG layer thắng mọi thứ; nhập sai vị trí
262
+ layer thì thua cả reset. Thứ tự đúng: `theme, base, vendor, components, utilities`.
263
+ 3. **Class ở phần tử này, sơn ở phần tử kia.** RDP đặt `day-selected` lên `<td>`,
264
+ còn nền/bo góc ở `<button>` bên trong → ngày chọn ra hình vuông sắc trong khi
265
+ hover thì tròn. Quy tắc: **một phần tử sở hữu bề mặt**, mọi trạng thái tô lên nó.
266
+
267
+ Cách duy nhất phát hiện: **mở trang, `getComputedStyle`, rồi CHỤP MÀN HÌNH.** Đo
268
+ đúng thuộc tính vừa sửa là chưa đủ — ba lần liên tiếp tôi báo "xong" trong khi
269
+ khối đó đang vỡ ở chỗ khác.
270
+
271
+ Token màu có HAI TẦNG: `--success/--warning/--info/--destructive` là màu **TÔ**;
272
+ chữ phải đọc `--text-success/-warning/-info/-error`. Đo: `Text tone="warning"`
273
+ đọc nhầm tầng cho **1,74:1**, đúng tầng cho **5,90:1**.
274
+
275
+ ## 5d. Tra catalog TRƯỚC khi tự dựng — bốn lần trong một ngày
276
+
277
+ `CardContent flush` (đường kẻ chạm mép), `CardHeader banded` (header có kẻ khi
278
+ thân là danh sách flush), `ListRow asChild` (hàng LÀ liên kết, thay cho một nút
279
+ rời), `Calendar bordered` — cả bốn **đã có sẵn** và tôi vẫn tự dựng bằng thứ
280
+ khác, vì không hỏi. Lỗi không phải "đoán sai tên prop" mà là **cho rằng thứ đó
281
+ không tồn tại nên không hỏi**.
282
+
283
+ Trước khi viết bất kỳ bố cục nào: `search_components` + `get_component`. Rẻ hơn
284
+ mọi lần sửa sau.
285
+
286
+ **Nhưng catalog chở PROP, không chở LUẬT BỐ CỤC** — và đó là một khoảng trống
287
+ thật của catalog, không chỉ là lỗi của người dùng nó. Ví dụ đo được: `CardBar`
288
+ trong manifest có đúng một prop (`extra`), không dòng nào nói nó **tự lấy đường
289
+ kẻ theo VỊ TRÍ** — đầu thì kẻ dưới, cuối thì kẻ trên, ở giữa thì cả hai. Luật ấy
290
+ chỉ nằm trong chú thích của `src/styles/card-layout.css`, cùng chỗ định nghĩa hai
291
+ nhịp `section` (header phẳng) và `band` (header có kẻ).
292
+
293
+ Nên khi làm bố cục bên trong một component của DS: **mở tệp `*-layout.css` của
294
+ nó ra đọc**. Một agent hỏi MCP đúng cách vẫn sẽ không biết những luật này.
295
+
296
+ ## 6. Thứ KHÔNG đẩy lên DS
297
+
298
+ - Bố cục của một trang cụ thể ("dashboard cần bốn thẻ ngang").
299
+ - Số đo của một màn ("cột vai trò rộng 8rem").
300
+ - Bất cứ thứ gì biết về miền nghiệp vụ của app này.
301
+
302
+ DS sở hữu **hình dạng**. Màn hình sở hữu **nội dung**. Đẩy nhầm hướng làm DS
303
+ phình ra thành thứ không ai nhớ nổi — cũng hỏng như để nó quá hẹp.
304
+
305
+ ## 7. Năm cách hỏng đã đo được — đừng lặp lại
306
+
307
+ 1. **Chẩn đoán bằng mắt rồi sửa.** Một lần đổ lỗi lệch header cho DS; hoá ra là
308
+ heuristic `onChat` của chính consumer. Đo trước, sửa sau.
309
+ 2. **Làm tròn số đo cho sạch lint.** Thiết kế cần 12px, thang bậc tên có 8 và
310
+ 16 — "gần nhất" là một phép đoán, và mỗi khe lệch 4px × n phần tử là cả khối
311
+ trôi. Giữ nguyên literal và mở đường cho DS.
312
+ 3. **Đọc nhầm nguồn rồi kết luận chắc nịch.** Một lần đọc `.ui-inline-*` trong
313
+ khi thứ đang chạy là `.ui-flex-gap-*`, rồi tuyên bố "đã sửa rồi". Trích đúng
314
+ dòng đang chạy, không phải dòng trông giống.
315
+ 4. **Chạy audit sai chỗ.** `ui-audit` chỉ báo lỗi khi chạy TRONG cây consumer;
316
+ chạy nó ở `/tmp` ra 0 lỗi và ru ngủ.
317
+ 5. **Phép thử đột biến không thật sự đột biến.** Một lượt
318
+ `perl -0pi -e 's/data-slot="x"/BROKEN/'` thiếu cờ `/g` chỉ thay lần khớp ĐẦU
319
+ TIÊN — mà lần đầu lại nằm trong một dòng chú thích, nên mã chạy không hề đổi
320
+ và phép kiểm "không đỏ". Suýt kết luận rằng assertion là rỗng. Sau khi phá,
321
+ hãy XÁC NHẬN mình đã phá đúng chỗ (`git diff` một dòng) trước khi tin vào kết
322
+ quả màu.