fix(styles): 스타일이 간격·글자·층·그림자 토큰을 읽고 검사가 날 값을 거절한다

셸·페이지 템플릿·카드 CSS가 간격·글자·반경·층·그림자 토큰을 건너뛰고 날
값을 쓴다(`src/presentation/styles/theme/*.css`에서 규칙에 걸리는 선언
118개). `shell.css`·`pages.css`·`templates.css`는 `var(--space-*)`를 한
번도 쓰지 않았고, z-index 100·30·10, 카드·헤더의 손 그림자, `999px`,
`min-height: 2.75rem`이 토큰과 같은 값을 다시 적었다. 필수 semantic 토큰
가운데 `--layer-navigation`·`--layer-modal`·`--opacity-scrim`·
`--opacity-skeleton`·`--elevation-panel`·`--color-disabled-content`·
`--color-action-pressed`를 읽는 스타일이 없었다. 그래서 파생 서비스가
밀도·층·그림자를 토큰으로 바꿔도 화면이 그대로다. 그리고 component.css의
가림막 토큰 셋이 `REQUIRED_COMPONENT_TOKENS`에 없어 UI-03 밖이었다(04-12).

고른 방법:
- 날 값을 토큰으로 바꾼다. 맞는 단계가 없는 간격은 가까운 `--space-*`로
  반올림했다(0.15~0.35rem → 1, 0.4~0.55 → 2, 0.65~0.85 → 3, 0.9 → 4).
  큰 값 3.5rem·4rem은 `--space-14`·`--space-16`을 더했다. 글자 크기도
  가까운 단계(0.8 → xs, 0.8125~0.9 → sm, 1.05 → md, 1.1 → lg, 1.35 → xl),
  굵기 600·650 → semibold, 700·750·800 → bold, 줄 높이 1.5~1.6 → normal,
  1.65·1.7 → relaxed. 페이지 h1은 semantic `--font-size-heading-1`·
  `--line-height-heading-1`(새 primitive 단계 3xl·4xl·compact)을 읽는다.
- 층: skip link는 `--layer-navigation`, sticky 헤더와 sticky 폼 버튼은
  `--layer-sticky`. 그림자: 카드·패널·갤러리 안내는 `--elevation-panel`,
  헤더는 새 `--elevation-sticky`(`--shadow-sticky`). `.ui-panel`의 Tailwind
  `shadow-sm`도 `--elevation-panel`로 바꿔 카드와 같은 높이가 됐다. dialog는
  `--radius-modal`, 가림막 비율은 `--opacity-scrim`을 읽고
  `--dialog-backdrop-weight`는 지웠다.
- 읽는 곳이 없던 semantic 토큰: skeleton 깜박임이 `--opacity-skeleton`,
  꺼진 입력이 `--color-disabled-content`·`--color-disabled-surface`, 누른
  primary 버튼이 새 component 토큰 `--button-primary-pressed`
  (`--color-action-pressed`)를 읽는다. `--layer-modal`은 native `<dialog>`가
  top layer에 열려 z-index가 닿지 않으므로 이유와 함께
  `SEMANTIC_TOKENS_WITHOUT_TEMPLATE_READER`에 둔다.
- `check:design-system`에 셋을 더한다. UI-06: styles 아래 간격·글자·반경·
  z-index·그림자의 날 값을 줄 번호와 함께 거절한다. UI-03을 필수 semantic
  토큰으로 넓힌다. component.css `@theme`의 토큰이 모두 계약에 있어야 한다.
  계약에 `--button-primary-pressed`, `--dialog-backdrop`,
  `--dialog-backdrop-on-surface`를 더했다.
- 버린 대안: 맞는 단계가 없는 값마다 primitive 단계를 더하기(단계가 두 배로
  늘어 scale이 무의미해진다). `--layer-modal`을 dialog에 z-index로 읽히기
  (top layer에서는 효과가 없는 가짜 읽기다).

위험·한계: 반올림과 패널 그림자 때문에 화면이 조금 바뀐다(간격 최대
0.15rem, 굵기 800 → 750, 패널 그림자 크기). 시각 골든은 이 커밋에서 다시
찍고 차이를 PR 본문에 적는다. 다운스트림이 styles에 날 값을 더해 두었으면
UI-06이 그 줄을 알린다. 너비·높이·위치(top 등)와 opacity는 UI-06 밖이다.

검증: 규칙 단위 시험과 check-design-system 연결 시험, 새 검사기로 고치기
전 CSS를 돌린 결과(RED), 시각 골든은 desktop에서 돌려 PR 본문에 적는다.

Refs: 1112/04-08, 1112/04-12
This commit is contained in:
DongHyeonka
2026-11-13 23:27:47 +09:00
parent b384d29ca5
commit 838ed410f7
19 changed files with 359 additions and 134 deletions
+12
View File
@@ -23,8 +23,20 @@ component별 값에 연결한다.
- UI-02: `color-mix()`는 `oklab`에서 섞는다. 색상(hue) 기반 색 공간에서는 섞지
않는다.
- UI-03: 모든 component 토큰은 어떤 스타일이든 하나에서 읽힌다.
`component.css`의 `@theme`에 정의한 토큰은 모두 `token-contract.ts`의
`REQUIRED_COMPONENT_TOKENS`에 있어야 한다. 필수 semantic 토큰도 스타일
하나가 읽어야 한다. 예외는 `SEMANTIC_TOKENS_WITHOUT_TEMPLATE_READER`에
이유와 함께 적는다(지금 `--layer-modal` 하나: native `<dialog>`는 top
layer에 열려 z-index가 닿지 않는다).
- UI-05: `--font-sans`는 generic family로 시작하거나, repository가
`@font-face`로 함께 배포하는 글꼴로 시작한다.
- UI-06: `src/` 아래 토큰 파일 밖의 스타일은 간격(padding·margin·gap),
글자 크기·굵기·줄 높이, 모서리 반경, z-index, 그림자를 손으로 쓰지 않고
토큰(`var(--space-*)`, `--font-size-*`, `--font-weight-*`,
`--line-height-*`, `--radius-*`, `--layer-*`, `--elevation-*`)을 읽는다.
`0`, `auto`, 키워드, `%`, viewport 단위, margin·padding의 1px 선, 부모
글자에 대한 `em`, `line-height: 1`, `z-index` 0·-1은 된다. 맞는 단계가 없으면
`primitive.css`에 단계를 더한다.
- UI-07: `semantic.css`는 색 값을 직접 쓰지 않는다. 색은 `primitive.css`
팔레트에 이름을 두고 `var()`로 읽는다. 토큰끼리 섞는 `color-mix()`는 된다.
그래서 팔레트만 고쳐도 status 색, focus, 어두운 테마가 따라온다.
+15
View File
@@ -9,12 +9,15 @@ import {
REQUIRED_COMPONENT_TOKENS,
REQUIRED_PRIMITIVE_TOKENS,
REQUIRED_SEMANTIC_TOKENS,
SEMANTIC_TOKENS_WITHOUT_TEMPLATE_READER,
} from "../src/presentation/design-system/tokens/token-contract.ts";
import {
firstFontFamilyFailures,
focusContrastFailures,
hueMixFailures,
rawSemanticColourFailures,
rawStyleValueFailures,
undeclaredComponentTokenFailures,
unreadTokenFailures,
} from "./lib/design-system-rules.ts";
import { readCustomProperties } from "./lib/oklch-contrast.ts";
@@ -64,6 +67,7 @@ for (const { file, source } of cssSources) {
}
}
failures.push(...hueMixFailures({ file, source }));
if (styleFiles.includes(file)) failures.push(...rawStyleValueFailures({ file, source }));
}
const semanticSource = await readFile(tokenFiles.semantic, "utf8");
@@ -110,6 +114,17 @@ failures.push(
REQUIRED_COMPONENT_TOKENS,
cssSources.filter(({ file }) => file !== tokenFiles.component),
),
...unreadTokenFailures(
REQUIRED_SEMANTIC_TOKENS.filter(
(token) => !SEMANTIC_TOKENS_WITHOUT_TEMPLATE_READER.includes(token),
),
cssSources.filter(({ file }) => file !== tokenFiles.semantic),
"semantic",
),
...undeclaredComponentTokenFailures(
{ file: tokenFiles.component, source: await readFile(tokenFiles.component, "utf8") },
REQUIRED_COMPONENT_TOKENS,
),
...firstFontFamilyFailures(
lightProperties.get("--font-sans") ?? "",
cssSources,
+64 -3
View File
@@ -9,11 +9,12 @@ export interface CssSource {
readonly source: string;
}
// Comments keep old code around, and the browser never draws it.
// Comments keep old code around, and the browser never draws it. They turn
// into spaces, newlines kept, so a reported line number stays the file's.
// Limit: a "/*" inside a quoted string would start a false comment. No
// CSS here has one; switch to a CSS tokenizer if that changes.
function withoutComments(css: string): string {
return css.replace(/\/\*[\s\S]*?\*\//g, "");
return css.replace(/\/\*[\s\S]*?\*\//g, (comment) => comment.replace(/[^\n]/g, " "));
}
// UI-01. The focus ring is drawn 3px away from its control, so the colour
@@ -79,6 +80,7 @@ export function hueMixFailures({ file, source }: CssSource): string[] {
export function unreadTokenFailures(
tokens: readonly string[],
styles: readonly CssSource[],
layer: "component" | "semantic" = "component",
): string[] {
const read = new Set(
styles.flatMap(({ source }) =>
@@ -88,7 +90,26 @@ export function unreadTokenFailures(
);
return tokens
.filter((token) => !read.has(token))
.map((token) => `component token ${token} is defined but no style reads it`);
.map((token) => `${layer} token ${token} is defined but no style reads it`);
}
// UI-03 (contract). A component token outside REQUIRED_COMPONENT_TOKENS is
// outside UI-03 too: the reader check only walks the contract list, so a
// token defined in component.css and read by nothing passed (1112/04-12).
// Only the @theme block counts: the forced-colors block redefines semantic
// roles, not component tokens.
export function undeclaredComponentTokenFailures(
{ file, source }: CssSource,
contract: readonly string[],
): string[] {
const theme = /@theme\s*\{([\s\S]*?)\n\}/.exec(withoutComments(source))?.[1] ?? "";
return [...theme.matchAll(/(--[a-z0-9-]+)\s*:/g)]
.map((match) => match[1])
.filter((token) => !contract.includes(token))
.map(
(token) =>
`${file} defines ${token}, which REQUIRED_COMPONENT_TOKENS in token-contract.ts does not list`,
);
}
// UI-05. --font-sans named Inter first, but nothing loads Inter, so most
@@ -142,3 +163,43 @@ export function rawSemanticColourFailures({ file, source }: CssSource): string[]
`${file} ${match[1]} is the raw colour ${match[2].trim()}; name it in primitive.css and read it with var()`,
);
}
// UI-06. A style that writes a spacing, type, radius, layer or shadow value
// by hand does not move when the token does: changing --space-*, --layer-*,
// --elevation-panel or --radius-modal left the shell, the page templates and
// the cards as they were (1112/04-08). Allowed: a token read (var()), 0,
// auto, keywords, %, viewport units, a 1px hairline in margin or padding,
// line-height 1, z-index 0 or -1, and em sizes relative to the parent font.
const LENGTH = /(?<![\w.-])-?(?:\d+\.?\d*|\.\d+)(?:px|rem|em)\b/g;
const NUMBER = /(?<![\w.(-])-?(?:\d+\.?\d*|\.\d+)(?![\w.%])/g;
const SPACING_PROPERTY =
/^(?:padding|margin)(?:-(?:top|right|bottom|left|block|inline)(?:-(?:start|end))?)?$|^(?:row-|column-)?gap$/;
function handWrittenValues(property: string, value: string): string[] {
const tokensRemoved = value.replace(/var\([^)]*\)/g, "");
const lengths = tokensRemoved.match(LENGTH) ?? [];
const numbers = tokensRemoved.replace(LENGTH, "").match(NUMBER) ?? [];
if (SPACING_PROPERTY.test(property)) return lengths.filter((length) => !["1px", "-1px"].includes(length));
if (property === "font-size") return lengths.filter((length) => !/(?<!r)em$/.test(length));
if (property === "font-weight") return numbers;
if (property === "line-height") return [...lengths, ...numbers].filter((item) => item !== "1");
if (/^border(?:-[a-z]+)*-radius$/.test(property)) return lengths;
if (property === "z-index") return numbers.filter((item) => !["0", "-1"].includes(item));
if (property === "box-shadow") return [...lengths, ...numbers];
return [];
}
export function rawStyleValueFailures({ file, source }: CssSource): string[] {
const css = withoutComments(source);
const failures: string[] = [];
for (const match of css.matchAll(/(?<![\w-])([a-z-]+)\s*:\s*([^;{}]+);/g)) {
const [, property, value] = match;
const raw = handWrittenValues(property, value);
if (raw.length === 0) continue;
const line = css.slice(0, match.index).split("\n").length;
failures.push(
`${file}:${line} ${property}: ${value.trim()} writes ${raw.join(", ")} by hand; read a token (docs/styling/design-tokens.md UI-06)`,
);
}
return failures;
}
@@ -2,24 +2,25 @@
--button-primary-background: var(--color-action);
--button-primary-content: var(--color-on-action);
--button-primary-hover: var(--color-action-hover);
--button-primary-pressed: var(--color-action-pressed);
--field-border: var(--color-border-strong);
--field-border-invalid: var(--color-danger);
--dialog-elevation: var(--elevation-dialog);
/* 1106/08-03. The modal scrim: the content colour at this weight.
`--dialog-backdrop` is the translucent scrim `::backdrop` paints.
/* 1106/08-03. The modal scrim: the content colour at the scrim opacity
(`--opacity-scrim`). `--dialog-backdrop` is the translucent scrim
`::backdrop` paints.
`--dialog-backdrop-on-surface` is that scrim already laid over the page
surface, an opaque colour, for the root background under the scrollbar
gutter while a modal is open (primitives.css). The two agree because a
browser blends a translucent colour over another in sRGB. */
--dialog-backdrop-weight: 55%;
--dialog-backdrop: color-mix(
in oklab,
var(--color-content) var(--dialog-backdrop-weight),
var(--color-content) calc(var(--opacity-scrim) * 100%),
transparent
);
--dialog-backdrop-on-surface: color-mix(
in srgb,
var(--color-content) var(--dialog-backdrop-weight),
var(--color-content) calc(var(--opacity-scrim) * 100%),
var(--color-surface)
);
--navigation-active-background: color-mix(
@@ -61,6 +61,8 @@
--space-6: 1.5rem;
--space-8: 2rem;
--space-12: 3rem;
--space-14: 3.5rem;
--space-16: 4rem;
--font-size-xs: 0.75rem;
--font-size-sm: 0.875rem;
@@ -68,6 +70,9 @@
--font-size-lg: 1.125rem;
--font-size-xl: 1.25rem;
--font-size-2xl: 1.5rem;
--font-size-3xl: 2rem;
--font-size-4xl: 3.5rem;
--line-height-compact: 1.05;
--line-height-tight: 1.25;
--line-height-normal: 1.5;
--line-height-relaxed: 1.7;
@@ -80,6 +85,7 @@
--radius-md: 0.75rem;
--radius-full: 999px;
--shadow-sticky: 0 1px 8px rgb(15 23 42 / 8%);
--shadow-panel: 0 8px 28px rgb(15 23 42 / 8%);
--shadow-popover: 0 14px 40px rgb(15 23 42 / 16%);
--shadow-dialog: 0 24px 70px rgb(15 23 42 / 25%);
@@ -31,7 +31,10 @@
--color-danger-border: var(--palette-red-400);
--font-sans: system-ui, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Noto Sans CJK KR", sans-serif;
/* 08-04. One step per heading level; a product retunes the scale here. */
/* 08-04. One step per heading level; a product retunes the scale here.
The page title grows with the viewport between two steps. */
--font-size-heading-1: clamp(var(--font-size-3xl), 5vw, var(--font-size-4xl));
--line-height-heading-1: var(--line-height-compact);
--font-size-heading-2: var(--font-size-2xl);
--font-size-heading-3: var(--font-size-xl);
--font-size-heading-4: var(--font-size-md);
@@ -40,6 +43,7 @@
--radius-control: var(--radius-sm);
--radius-surface: var(--radius-md);
--radius-modal: var(--radius-md);
--elevation-sticky: var(--shadow-sticky);
--elevation-panel: var(--shadow-panel);
--elevation-popover: var(--shadow-popover);
--elevation-dialog: var(--shadow-dialog);
@@ -43,13 +43,28 @@ export const REQUIRED_SEMANTIC_TOKENS = Object.freeze([
"--opacity-skeleton",
] as const);
/**
* 1112/04-08. Required semantic tokens no template style reads, and why.
* check:design-system requires every other required semantic token to be
* read by a style (UI-03). A native `<dialog>` opened with `showModal()` sits
* in the browser's top layer, above every z-index, so the template's dialogs
* and drawer have no `z-index`; `--layer-modal` orders a product's own modal
* surface that is not a `<dialog>`.
*/
export const SEMANTIC_TOKENS_WITHOUT_TEMPLATE_READER: readonly string[] = Object.freeze([
"--layer-modal",
]);
export const REQUIRED_COMPONENT_TOKENS = Object.freeze([
"--button-primary-background",
"--button-primary-content",
"--button-primary-hover",
"--button-primary-pressed",
"--field-border",
"--field-border-invalid",
"--dialog-elevation",
"--dialog-backdrop",
"--dialog-backdrop-on-surface",
"--navigation-active-background",
"--drawer-width",
"--toast-width",
+2 -2
View File
@@ -48,8 +48,8 @@
}
h1 {
font-size: clamp(2rem, 5vw, 3.5rem);
line-height: 1.05;
font-size: var(--font-size-heading-1);
line-height: var(--line-height-heading-1);
letter-spacing: -0.04em;
}
+35 -35
View File
@@ -2,14 +2,14 @@
.readiness-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 1rem;
gap: var(--space-4);
}
.readiness-grid p,
.starter-actions p {
margin-block-end: 0;
color: var(--color-content-muted);
line-height: 1.65;
line-height: var(--line-height-relaxed);
}
.starter-actions {
@@ -17,23 +17,23 @@
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 1.5rem;
gap: var(--space-6);
}
.button-row {
display: flex;
flex-wrap: wrap;
gap: 0.75rem;
gap: var(--space-3);
}
.route-loading {
padding-block-start: 4rem;
padding-block-start: var(--space-16);
}
.gallery-section {
display: grid;
gap: 1rem;
padding-block: 0.5rem;
gap: var(--space-4);
padding-block: var(--space-2);
}
.gallery-section__header {
@@ -46,14 +46,14 @@
}
.gallery-section__header p {
margin-block-start: 0.4rem;
margin-block-start: var(--space-2);
color: var(--color-content-muted);
line-height: 1.6;
line-height: var(--line-height-normal);
}
.component-grid {
display: grid;
gap: 1rem;
gap: var(--space-4);
}
.component-grid--two {
@@ -67,45 +67,45 @@
.component-stack,
.example-form {
display: grid;
gap: 1rem;
gap: var(--space-4);
}
.platform-metric-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
gap: 1rem;
gap: var(--space-4);
margin-block: 0;
}
.platform-metric {
display: grid;
gap: 0.25rem;
padding: 0.85rem 1rem;
gap: var(--space-1);
padding: var(--space-3) var(--space-4);
border: 1px solid var(--color-border);
border-radius: var(--radius-surface);
background: var(--color-panel);
}
.platform-metric dt {
font-size: 0.8125rem;
font-size: var(--font-size-sm);
color: var(--color-content-muted);
}
.platform-metric dd {
display: grid;
gap: 0.15rem;
gap: var(--space-1);
margin-inline-start: 0;
}
.platform-metric__value {
font-weight: 600;
font-weight: var(--font-weight-semibold);
overflow-wrap: anywhere;
}
.platform-metric__hint,
.platform-operation__path {
display: block;
font-size: 0.8125rem;
font-size: var(--font-size-sm);
color: var(--color-content-muted);
overflow-wrap: anywhere;
}
@@ -113,22 +113,22 @@
.badge-row {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
gap: var(--space-2);
}
.token-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
gap: 0.75rem;
gap: var(--space-3);
}
.token-swatch {
display: grid;
gap: 0.45rem;
gap: var(--space-2);
min-width: 0;
border: 1px solid var(--color-border);
border-radius: var(--radius-control);
padding: 0.75rem;
padding: var(--space-3);
background: var(--color-panel);
}
@@ -141,7 +141,7 @@
.token-swatch code {
overflow: hidden;
color: var(--color-content-muted);
font-size: 0.75rem;
font-size: var(--font-size-xs);
text-overflow: ellipsis;
white-space: nowrap;
}
@@ -152,13 +152,13 @@
max-width: 100%;
box-sizing: border-box;
border: 1px solid var(--color-surface-muted);
border-radius: 999px;
padding: 0.65rem 1rem;
border-radius: var(--radius-full);
padding: var(--space-3) var(--space-4);
color: var(--color-content);
background: var(--color-panel);
box-shadow: 0 8px 28px color-mix(in oklab, var(--color-content) 10%, transparent);
font-size: 0.875rem;
font-weight: 650;
box-shadow: var(--elevation-panel);
font-size: var(--font-size-sm);
font-weight: var(--font-weight-semibold);
}
.state-surface {
@@ -170,24 +170,24 @@
justify-content: center;
border: 1px solid var(--color-surface-muted);
border-radius: var(--radius-surface);
padding: 1.25rem;
padding: var(--space-5);
background: var(--color-surface);
}
.state-surface :is(h2, h3, h4),
.state-surface p {
margin-block-end: 0.75rem;
margin-block-end: var(--space-3);
}
.state-surface > p:not(.state-surface__eyebrow) {
color: var(--color-content-muted);
line-height: 1.55;
line-height: var(--line-height-normal);
}
.state-surface__eyebrow {
color: var(--color-action-hover);
font-size: 0.75rem;
font-weight: 800;
font-size: var(--font-size-xs);
font-weight: var(--font-weight-bold);
letter-spacing: 0.04em;
}
@@ -203,7 +203,7 @@
}
.state-surface--loading {
gap: 0.75rem;
gap: var(--space-3);
}
.state-surface--loading .ui-skeleton {
@@ -212,7 +212,7 @@
.state-preview-content {
border-radius: var(--radius-control);
padding: 1rem;
padding: var(--space-4);
background: var(--color-surface);
}
}
+53 -35
View File
@@ -6,7 +6,8 @@
}
.ui-panel {
@apply rounded-surface p-6 shadow-sm;
@apply rounded-surface p-6;
box-shadow: var(--elevation-panel);
border: 1px solid var(--color-border);
background: var(--color-panel);
}
@@ -14,7 +15,7 @@
.ui-button {
@apply rounded-control px-4 py-2 font-semibold;
display: inline-flex;
min-height: 2.75rem;
min-height: var(--size-control-md);
align-items: center;
justify-content: center;
border: 0;
@@ -38,6 +39,10 @@
cursor: progress;
}
.ui-button--primary:active:not(:disabled, [aria-disabled="true"]) {
background: var(--button-primary-pressed);
}
.ui-button--secondary {
border: 1px solid var(--color-surface-muted);
color: var(--color-content);
@@ -70,8 +75,8 @@
.ui-button--compact {
min-height: var(--size-control-sm);
padding: 0.4rem 0.75rem;
font-size: 0.85rem;
padding: var(--space-2) var(--space-3);
font-size: var(--font-size-sm);
}
.ui-icon-button {
@@ -123,7 +128,14 @@
}
.ui-skeleton {
@apply h-24 animate-pulse rounded-surface bg-surface-muted;
@apply h-24 rounded-surface bg-surface-muted;
animation: ui-skeleton-pulse 2s var(--easing-standard) infinite;
}
@keyframes ui-skeleton-pulse {
50% {
opacity: var(--opacity-skeleton);
}
}
.ui-empty,
@@ -133,18 +145,18 @@
.ui-field {
display: grid;
gap: 0.45rem;
gap: var(--space-2);
}
.ui-field__label {
font-weight: 750;
font-weight: var(--font-weight-bold);
}
.ui-field__description,
.ui-field__error {
margin: 0;
font-size: 0.875rem;
line-height: 1.5;
font-size: var(--font-size-sm);
line-height: var(--line-height-normal);
}
.ui-field__description {
@@ -153,20 +165,26 @@
.ui-field__error {
color: var(--color-danger);
font-weight: 650;
font-weight: var(--font-weight-semibold);
}
.ui-field__input {
width: 100%;
min-height: 2.75rem;
min-height: var(--size-control-md);
box-sizing: border-box;
border: 1px solid var(--field-border);
border-radius: var(--radius-control);
padding: 0.65rem 0.8rem;
padding: var(--space-3) var(--space-3);
color: var(--color-content);
background: var(--color-panel);
}
.ui-field__input:disabled {
color: var(--color-disabled-content);
background: var(--color-disabled-surface);
cursor: not-allowed;
}
.ui-field__input[aria-invalid="true"] {
border-color: var(--field-border-invalid);
}
@@ -245,7 +263,7 @@
display: block;
width: 1rem;
height: 1rem;
margin: 0.2rem;
margin: var(--space-1);
border-radius: var(--radius-full);
background: var(--color-content-muted);
content: "";
@@ -278,12 +296,12 @@
display: flex;
min-width: 0;
flex-direction: column;
gap: 1.25rem;
gap: var(--space-5);
border: 1px solid var(--color-border);
border-radius: var(--radius-surface);
padding: 1.25rem;
padding: var(--space-5);
background: var(--color-panel);
box-shadow: 0 8px 28px color-mix(in oklab, var(--color-content) 6%, transparent);
box-shadow: var(--elevation-panel);
}
.ui-card__header :is(h2, h3, h4),
@@ -292,9 +310,9 @@
}
.ui-card__header p {
margin-block-start: 0.4rem;
margin-block-start: var(--space-2);
color: var(--color-content-muted);
line-height: 1.55;
line-height: var(--line-height-normal);
}
.ui-card__content {
@@ -302,7 +320,7 @@
}
.ui-card__footer {
padding-block-start: 1rem;
padding-block-start: var(--space-4);
border-top: 1px solid var(--color-surface-muted);
}
@@ -310,10 +328,10 @@
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 1rem;
gap: var(--space-4);
border: 1px solid var(--color-surface-muted);
border-radius: var(--radius-control);
padding: 1rem;
padding: var(--space-4);
background: var(--color-surface);
}
@@ -339,7 +357,7 @@
.ui-alert__content,
.ui-alert__content p {
margin-block: 0.35rem 0;
margin-block: var(--space-1) 0;
color: var(--color-content-muted);
}
@@ -354,7 +372,7 @@
border-radius: var(--radius-control);
color: var(--color-content);
background: transparent;
font-size: 1.35rem;
font-size: var(--font-size-xl);
cursor: pointer;
}
@@ -372,12 +390,12 @@
.ui-badge {
display: inline-flex;
border-radius: 999px;
padding: 0.3rem 0.65rem;
border-radius: var(--radius-full);
padding: var(--space-1) var(--space-3);
color: var(--color-content);
background: var(--color-surface-muted);
font-size: 0.8rem;
font-weight: 750;
font-size: var(--font-size-xs);
font-weight: var(--font-weight-bold);
}
.ui-badge--info {
@@ -406,7 +424,7 @@
box-sizing: border-box;
overflow: auto;
border: 0;
border-radius: var(--radius-surface);
border-radius: var(--radius-modal);
padding: 0;
color: var(--color-content);
background: var(--color-panel);
@@ -713,36 +731,36 @@
}
.ui-dialog__surface {
padding: 1.5rem;
padding: var(--space-6);
}
.ui-dialog__header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 1rem;
gap: var(--space-4);
}
.ui-dialog__header h2 {
margin-block-end: 0.35rem;
margin-block-end: var(--space-1);
}
.ui-dialog__header p,
.ui-dialog__content p {
color: var(--color-content-muted);
line-height: 1.6;
line-height: var(--line-height-normal);
}
.ui-dialog__content {
padding-block: 1rem;
padding-block: var(--space-4);
}
.ui-dialog__actions {
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 0.75rem;
padding-block-start: 1rem;
gap: var(--space-3);
padding-block-start: var(--space-4);
border-top: 1px solid var(--color-surface-muted);
}
}
+1 -1
View File
@@ -7,7 +7,7 @@
}
.app-shell__header {
padding-inline: 0.75rem;
padding-inline: var(--space-3);
}
.app-shell__menu-button.ui-icon-button {
+29 -29
View File
@@ -13,10 +13,10 @@
.skip-link {
position: fixed;
z-index: 100;
top: 0.75rem;
left: 0.75rem;
padding: 0.75rem 1rem;
z-index: var(--layer-navigation);
top: var(--space-3);
left: var(--space-3);
padding: var(--space-3) var(--space-4);
border-radius: var(--radius-control);
color: var(--color-panel);
background: var(--color-content);
@@ -44,23 +44,23 @@
.app-shell__header {
position: sticky;
z-index: 30;
z-index: var(--layer-sticky);
top: 0;
grid-area: header;
display: flex;
align-items: center;
gap: 1rem;
gap: var(--space-4);
min-width: 0;
padding: 0.75rem 1.25rem;
padding: var(--space-3) var(--space-5);
border-bottom: 1px solid var(--color-surface-muted);
background: color-mix(in oklab, var(--color-panel) 92%, var(--color-surface));
box-shadow: 0 1px 8px color-mix(in oklab, var(--color-content) 8%, transparent);
box-shadow: var(--elevation-sticky);
}
.app-shell__brand {
overflow: hidden;
font-size: 1.05rem;
font-weight: 800;
font-size: var(--font-size-md);
font-weight: var(--font-weight-bold);
text-decoration: none;
text-overflow: ellipsis;
white-space: nowrap;
@@ -68,25 +68,25 @@
/* 08-01. The narrow header drops these; the menu drawer carries them. */
.app-shell__drawer-brand {
margin: 0 0 0.75rem;
font-weight: 800;
margin: 0 0 var(--space-3);
font-weight: var(--font-weight-bold);
}
.app-shell__drawer-preferences {
display: grid;
gap: 0.75rem;
margin-top: 1rem;
padding-top: 1rem;
gap: var(--space-3);
margin-top: var(--space-4);
padding-top: var(--space-4);
border-top: 1px solid var(--color-border);
}
.app-shell__menu-button {
display: none;
align-items: center;
gap: 0.4rem;
gap: var(--space-2);
border: 1px solid var(--color-surface-muted);
border-radius: var(--radius-control);
padding: 0.55rem 0.75rem;
padding: var(--space-2) var(--space-3);
color: var(--color-content);
background: var(--color-panel);
cursor: pointer;
@@ -95,7 +95,7 @@
.app-shell__session {
display: flex;
align-items: center;
gap: 0.75rem;
gap: var(--space-3);
margin-inline-start: auto;
}
@@ -120,7 +120,7 @@
.theme-selector .ui-field__input,
.locale-selector .ui-field__input {
min-height: var(--size-control-sm);
padding: 0.35rem 2rem 0.35rem 0.65rem;
padding: var(--space-1) var(--space-8) var(--space-1) var(--space-3);
cursor: pointer;
}
@@ -128,7 +128,7 @@
position: absolute;
top: calc(100% + 0.25rem);
right: 1rem;
padding: 0.5rem;
padding: var(--space-2);
color: var(--color-danger);
background: var(--color-panel);
}
@@ -137,12 +137,12 @@
display: inline-flex;
width: fit-content;
align-items: center;
border-radius: 999px;
padding: 0.3rem 0.65rem;
border-radius: var(--radius-full);
padding: var(--space-1) var(--space-3);
color: var(--color-content-muted);
background: var(--color-surface-muted);
font-size: 0.8rem;
font-weight: 700;
font-size: var(--font-size-xs);
font-weight: var(--font-weight-bold);
}
.session-status[data-state="authenticated"] {
@@ -159,7 +159,7 @@
top: 4.5rem;
grid-area: sidebar;
height: calc(100vh - 4.5rem);
padding: 1.25rem 0.75rem;
padding: var(--space-5) var(--space-3);
border-right: 1px solid var(--color-border);
background: var(--color-panel);
}
@@ -167,7 +167,7 @@
.app-navigation {
display: flex;
flex-direction: column;
gap: 0.25rem;
gap: var(--space-1);
margin: 0;
padding: 0;
list-style: none;
@@ -176,9 +176,9 @@
.app-navigation__link {
display: block;
border-radius: var(--radius-control);
padding: 0.75rem 0.9rem;
padding: var(--space-3) var(--space-4);
color: var(--color-content-muted);
font-weight: 650;
font-weight: var(--font-weight-semibold);
text-decoration: none;
}
@@ -190,7 +190,7 @@
.app-navigation__link.is-active {
color: var(--color-action-hover);
background: var(--navigation-active-background);
font-weight: 800;
font-weight: var(--font-weight-bold);
}
.app-shell__content {
+23 -23
View File
@@ -1,7 +1,7 @@
@layer components {
.page-header {
max-width: 50rem;
padding-block: clamp(1rem, 5vw, 3.5rem) 0.5rem;
padding-block: clamp(var(--space-4), 5vw, var(--space-14)) var(--space-2);
}
/* 1112/05-02. Pointer navigation only: a keyboard user keeps the
@@ -11,10 +11,10 @@
}
.page-header__eyebrow {
margin-block-end: 0.75rem;
margin-block-end: var(--space-3);
color: var(--color-action);
font-size: 0.8rem;
font-weight: 800;
font-size: var(--font-size-xs);
font-weight: var(--font-weight-bold);
letter-spacing: 0.08em;
text-transform: uppercase;
}
@@ -22,13 +22,13 @@
.page-header__description {
max-width: 45rem;
color: var(--color-content-muted);
font-size: 1.05rem;
line-height: 1.7;
font-size: var(--font-size-md);
line-height: var(--line-height-relaxed);
}
.page-template {
display: grid;
gap: 1.25rem;
gap: var(--space-5);
min-width: 0;
}
@@ -39,9 +39,9 @@
}
.page-template__breadcrumb {
padding-block-start: 1rem;
padding-block-start: var(--space-4);
color: var(--color-content-muted);
font-size: 0.9rem;
font-size: var(--font-size-sm);
}
.page-template__heading {
@@ -49,7 +49,7 @@
min-width: 0;
grid-template-columns: minmax(0, 1fr) auto;
align-items: end;
gap: 1rem;
gap: var(--space-4);
}
.page-template__heading .page-header {
@@ -65,13 +65,13 @@
flex-wrap: wrap;
align-items: center;
justify-content: flex-end;
gap: 0.75rem;
gap: var(--space-3);
}
.page-template__layout {
display: grid;
min-width: 0;
gap: 1.5rem;
gap: var(--space-6);
}
.page-template__layout[data-has-aside="true"] {
@@ -92,7 +92,7 @@
.form-error-summary {
border: 1px solid var(--color-border);
border-radius: var(--radius-surface);
padding: 1rem;
padding: var(--space-4);
background: var(--color-panel);
}
@@ -102,7 +102,7 @@
display: flex;
flex-wrap: wrap;
align-items: end;
gap: 0.75rem;
gap: var(--space-3);
}
.collection-page__result-count {
@@ -114,17 +114,17 @@
.form-page__fields,
.form-page__error-summary {
display: grid;
gap: 1rem;
gap: var(--space-4);
}
.collection-page__pagination {
margin-block-start: 1.25rem;
margin-block-start: var(--space-5);
}
.detail-page__danger {
margin-block-start: 2rem;
margin-block-start: var(--space-8);
border-top: 1px solid var(--color-danger-border);
padding-block-start: 1rem;
padding-block-start: var(--space-4);
}
.form-error-summary {
@@ -133,7 +133,7 @@
}
.form-error-summary :is(h2, h3, h4) {
font-size: 1.1rem;
font-size: var(--font-size-lg);
}
.form-error-summary p,
@@ -142,21 +142,21 @@
}
.form-actions {
padding-block-start: 1rem;
padding-block-start: var(--space-4);
border-top: 1px solid var(--color-border);
}
.form-actions--sticky {
position: sticky;
z-index: 10;
z-index: var(--layer-sticky);
bottom: 0;
padding: 0.75rem;
padding: var(--space-3);
background: color-mix(in oklab, var(--color-panel) 94%, transparent);
}
.status-page {
max-width: 48rem;
padding-block: 2rem;
padding-block: var(--space-8);
}
.status-page__actions {
+93
View File
@@ -11,8 +11,15 @@ import {
focusContrastFailures,
hueMixFailures,
rawSemanticColourFailures,
rawStyleValueFailures,
undeclaredComponentTokenFailures,
unreadTokenFailures,
} from "../../scripts/lib/design-system-rules.ts";
import {
REQUIRED_COMPONENT_TOKENS,
REQUIRED_SEMANTIC_TOKENS,
SEMANTIC_TOKENS_WITHOUT_TEMPLATE_READER,
} from "../../src/presentation/design-system/tokens/token-contract.ts";
import { childProcessTimeout } from "../helpers/child-process-timeout.ts";
const css = (source: string) => ({ file: "probe.css", source });
@@ -144,6 +151,83 @@ describe("design system rules", { timeout: childProcessTimeout(3_540) }, () => {
});
});
// 1112/04-08. A style that writes the value by hand ignores the token.
describe("UI-06 styles read spacing, type, radius, layer and shadow tokens", () => {
it.each([
["padding: 0.75rem 1rem", "0.75rem, 1rem"],
["margin-block-start: 0.4rem", "0.4rem"],
["gap: 12px", "12px"],
["font-size: 0.8rem", "0.8rem"],
["font-weight: 800", "800"],
["line-height: 1.6", "1.6"],
["border-radius: 999px", "999px"],
["z-index: 30", "30"],
["box-shadow: 0 1px 8px var(--color-border)", "1px, 8px, 0"],
])("fails %s", (declaration, raw) => {
const [property] = declaration.split(":");
expect(rawStyleValueFailures(css(`.a {\n ${declaration};\n}`))).toEqual([
`probe.css:2 ${property}: ${declaration.slice(property.length + 1).trim()} writes ${raw} by hand; read a token (docs/styling/design-tokens.md UI-06)`,
]);
});
it("passes token reads, zero, keywords, hairlines, relative and viewport values", () => {
expect(
rawStyleValueFailures(
css(`.a {
padding: var(--space-3) var(--space-4);
margin: -1px;
margin-inline: calc(var(--spacing-page) * -1);
padding-block: clamp(var(--space-4), 5vw, var(--space-14)) 0;
gap: 0;
font-size: 0.9em;
font-weight: var(--font-weight-bold);
line-height: 1;
border-radius: 50%;
z-index: var(--layer-sticky);
box-shadow: none;
width: 2rem;
}`),
),
).toEqual([]);
});
it("reports the file's own line after a comment of several lines", () => {
expect(rawStyleValueFailures(css("/* one\n two\n padding: 1rem; */\n.a { padding: 1rem; }"))).toEqual([
"probe.css:4 padding: 1rem writes 1rem by hand; read a token (docs/styling/design-tokens.md UI-06)",
]);
});
});
describe("UI-03 for the required semantic tokens", () => {
it("names the semantic layer in the message", () => {
expect(unreadTokenFailures(["--layer-navigation"], [css(".a { z-index: 1; }")], "semantic")).toEqual([
"semantic token --layer-navigation is defined but no style reads it",
]);
});
it("leaves out only --layer-modal, which the top layer makes unreadable", () => {
expect(SEMANTIC_TOKENS_WITHOUT_TEMPLATE_READER).toEqual(["--layer-modal"]);
expect(REQUIRED_SEMANTIC_TOKENS).toContain("--layer-modal");
});
});
// 1112/04-12. Every component token is in the contract UI-03 walks.
describe("component tokens and the contract", () => {
it("fails a component token the contract does not list", () => {
const component = css(`@theme {\n --button-primary-background: x;\n --dialog-backdrop-weight: 55%;\n}\n\n@media (forced-colors: active) {\n :root {\n --color-border: CanvasText;\n }\n}`);
expect(undeclaredComponentTokenFailures(component, ["--button-primary-background"])).toEqual([
"probe.css defines --dialog-backdrop-weight, which REQUIRED_COMPONENT_TOKENS in token-contract.ts does not list",
]);
});
it("passes the repository's component tokens", async () => {
const file = "src/presentation/design-system/tokens/component.css";
expect(
undeclaredComponentTokenFailures({ file, source: await readFile(file, "utf8") }, REQUIRED_COMPONENT_TOKENS),
).toEqual([]);
});
});
describe("UI-05 first font family", () => {
it("fails a named font that nothing loads", () => {
expect(firstFontFamilyFailures("Inter, system-ui, sans-serif", [])).toEqual([
@@ -201,6 +285,12 @@ describe("design system rules", { timeout: childProcessTimeout(3_540) }, () => {
await edit(semantic, "--font-sans: ", "--font-sans: Inter, ");
await edit(semantic, "--color-danger-surface: var(--palette-red-50);", "--color-danger-surface: oklch(0.96 0.035 25);");
await edit("src/presentation/styles/theme/primitives.css", "var(--drawer-width)", "20rem");
await edit("src/presentation/styles/theme/shell.css", "z-index: var(--layer-navigation);", "z-index: 50;");
await edit(
"src/presentation/design-system/tokens/component.css",
" --drawer-width:",
" --probe-unlisted: 1px;\n --drawer-width:",
);
await writeFile(
path.join(root, "src/presentation/styles/theme/probe.css"),
".probe { color: color-mix(in oklch, red, blue); }\n",
@@ -219,6 +309,9 @@ describe("design system rules", { timeout: childProcessTimeout(3_540) }, () => {
/^src\/presentation\/styles\/theme\/probe\.css mixes colours in oklch; use oklab$/,
/^component token --drawer-width is defined but no style reads it$/,
/^--font-sans starts with "Inter", which is neither a generic family, loaded by @font-face, nor listed in PRODUCT_LOADED_FONT_FAMILIES$/,
/^src\/presentation\/styles\/theme\/shell\.css:\d+ z-index: 50 writes 50 by hand; read a token \(docs\/styling\/design-tokens\.md UI-06\)$/,
/^semantic token --layer-navigation is defined but no style reads it$/,
/^src\/presentation\/design-system\/tokens\/component\.css defines --probe-unlisted, which REQUIRED_COMPONENT_TOKENS in token-contract\.ts does not list$/,
/^src\/presentation\/design-system\/tokens\/semantic\.css --color-danger-surface is the raw colour oklch\(0\.96 0\.035 25\); name it in primitive\.css and read it with var\(\)$/,
];
expect(failures.filter((failure) => !rules.some((rule) => rule.test(failure)))).toEqual([]);
Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 189 KiB

After

Width:  |  Height:  |  Size: 182 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 189 KiB

After

Width:  |  Height:  |  Size: 189 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 123 KiB

After

Width:  |  Height:  |  Size: 122 KiB