diff --git a/scripts/test/design-principles.ts b/scripts/test/design-principles.ts index a0f0d31c3..7b104b9b7 100644 --- a/scripts/test/design-principles.ts +++ b/scripts/test/design-principles.ts @@ -52,9 +52,17 @@ function walk(dir: string, out: string[] = []): string[] { } /** - * Arbitrary Tailwind values in component markup: `text-[13px]`, `min-h-[4.25rem]`, - * `w-[247px]`. Each one is a decision made outside the design system, which is - * how a system becomes a suggestion. + * Arbitrary Tailwind values in component markup. + * + * CLAUDE.md's four-layer spec already rules on these, and this gate follows it + * rather than inventing a stricter one: COLOUR and TYPOGRAPHY arbitraries are + * never allowed (there is a token; use it), while LAYOUT arbitraries are + * explicitly PERMITTED for one-off constraints with no semantic meaning and are + * therefore ratcheted rather than banned. + * + * An earlier version treated both alike. That was stricter than the documented + * policy, and a gate contradicting the spec it claims to enforce is one people + * learn to route around. * * BASELINE, not zero. SIXTEEN existed when this gate was written — an earlier * count of "nine" came from a narrower pattern that missed z-, max-w- and @@ -63,9 +71,13 @@ function walk(dir: string, out: string[] = []): string[] { * would mean a sweeping refactor in the same change that introduces the rule, * and a gate nobody can pass gets deleted. */ -const ARBITRARY_BASELINE = 16; -const ARBITRARY = - /\b(?:text|min-h|max-h|h|w|min-w|max-w|gap|p[xytrbl]?|m[xytrbl]?|top|left|right|bottom|z)-\[[^\]]+\]/g; +const LAYOUT_ARBITRARY_BASELINE = 16; +/** Layout only — permitted by the four-layer spec, held at its current count. */ +const LAYOUT_ARBITRARY = + /\b(?:min-h|max-h|h|w|min-w|max-w|gap|p[xytrbl]?|m[xytrbl]?|top|left|right|bottom|z)-\[[^\]]+\]/g; +/** Colour and typography — never permitted, at any count. */ +const VISUAL_ARBITRARY = + /\b(?:text|bg|border|shadow|ring|fill|stroke)-\[(?:#|rgb|hsl|oklch|\d)[^\]]*\]/g; console.log("design-principles:"); @@ -87,27 +99,39 @@ check("THE GRAMMAR EXISTS: principles are stated in globals.css", () => { } }); -check("PRINCIPLE 7: arbitrary values never increase", () => { +check("PRINCIPLE 7: no arbitrary COLOUR or TYPOGRAPHY, at any count", () => { + const files = walk(join(ROOT, "src/components")); + const offenders: string[] = []; + for (const file of files) { + const hits = readFileSync(file, "utf8").match(VISUAL_ARBITRARY) ?? []; + if (hits.length > 0) offenders.push(`${file.replace(ROOT + "/", "")}: ${hits.join(", ")}`); + } + assert( + offenders.length === 0, + `a colour or size was typed instead of using a token:\n ${offenders.join("\n ")}`, + ); +}); + +check("PRINCIPLE 7: one-off LAYOUT values are held, never grown", () => { const files = walk(join(ROOT, "src/components")); const offenders: string[] = []; let count = 0; for (const file of files) { - const hits = readFileSync(file, "utf8").match(ARBITRARY) ?? []; + const hits = readFileSync(file, "utf8").match(LAYOUT_ARBITRARY) ?? []; if (hits.length > 0) { count += hits.length; offenders.push(`${file.replace(ROOT + "/", "")}: ${hits.join(", ")}`); } } assert( - count <= ARBITRARY_BASELINE, - `arbitrary values rose to ${count} (baseline ${ARBITRARY_BASELINE}). ` + - `Add the value to globals.css and name it instead:\n ${offenders.join("\n ")}`, + count <= LAYOUT_ARBITRARY_BASELINE, + `one-off layout values rose to ${count} (baseline ${LAYOUT_ARBITRARY_BASELINE}). ` + + `The spec permits these for constraints with no semantic meaning — but if it ` + + `recurs, name it in globals.css:\n ${offenders.join("\n ")}`, ); - // Ratchet: when the count falls, the baseline must come down with it, or the - // gate quietly re-permits what was just cleaned up. assert( - count >= ARBITRARY_BASELINE - 2 || count === 0, - `arbitrary values fell to ${count} — lower ARBITRARY_BASELINE to ${count} in this file so the ground gained is held`, + count >= LAYOUT_ARBITRARY_BASELINE - 2 || count === 0, + `layout arbitraries fell to ${count} — lower LAYOUT_ARBITRARY_BASELINE to ${count} so the ground gained is held`, ); }); diff --git a/src/app/globals.css b/src/app/globals.css index e3435aecd..72f9715df 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -3096,6 +3096,25 @@ .ui-health-chip-interactive { @apply transition-colors hover:border-border-default hover:bg-surface-raised; } + /* In a LIST the chip is not a chip. + Principle 3 (space separates, boxes are a last resort) and principle 2 + (emphasis belongs to alarms): a bordered pill on every row was the only + boxed thing in the rail, so it pulled the eye harder than the flag count + beside it — the one thing on the page that is actually an alarm. It also + kept 8px of column jitter, because a pill's width follows its text. + Plain tabular text, full cell width, right-aligned: the column edge is + then exact and the number is as quiet as the date next to it. It is still + a button and still opens the breakdown. */ + /* The scroll-affordance chevron sits ON content, so it needs a halo in the + page colour to stay legible over text. Named here because CLAUDE.md's + four-layer spec forbids `shadow-[var(--*)]` in JSX: a visual decision + belongs in this file even when its value is already a token. */ + .ui-scroll-affordance-glyph { + filter: drop-shadow(0 0 4px var(--surface-page)); + } + .ui-health-chip-compact { + @apply w-full justify-end rounded-none border-0 bg-transparent px-0 py-0 hover:bg-transparent; + } .ui-health-label { @apply text-micro font-semibold uppercase tracking-caps text-text-tertiary; } diff --git a/src/components/projects/HealthScore.tsx b/src/components/projects/HealthScore.tsx index 9154d746b..5ea3f8df4 100644 --- a/src/components/projects/HealthScore.tsx +++ b/src/components/projects/HealthScore.tsx @@ -230,7 +230,9 @@ export function HealthScoreBar({