From 6fc77bb71f7fb7b68071dfdf68dceafc2046c4d1 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Sun, 1 Nov 2026 22:25:43 +0900 Subject: [PATCH] =?UTF-8?q?fix(design-system):=20h2=C2=B7h3=C2=B7h4?= =?UTF-8?q?=EC=97=90=20=EC=A0=9C=EB=AA=A9=20=EB=8B=A8=EA=B3=84=20=ED=81=AC?= =?UTF-8?q?=EA=B8=B0=EC=99=80=20=EA=B5=B5=EA=B8=B0=EB=A5=BC=20=EC=A4=80?= =?UTF-8?q?=EB=8B=A4=20(08-04)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제: theme.css가 넣는 Tailwind preflight가 제목의 크기·굵기를 본문으로 되돌린다. base.css는 h1 크기와 h2 줄 간격만 정해, 6개 라우트 모두 h2·h3이 16px/400으로 본문과 같았다. 구획을 훑어볼 수 없고, 제품마다 제목 크기를 따로 만들게 된다. 고른 방법: 리뷰의 최소 개선 방향대로 primitive에 --font-size-xl(1.25rem) ·--font-size-2xl(1.5rem)을 더하고, semantic에 제목 단계 토큰 (--font-size-heading-2/3/4, --font-weight-heading = semibold)을 둔 뒤 base.css에서 h2·h3·h4에 적용했다. 컴포넌트 제목(카드 h3, 상태 화면 h2)은 자기 수준의 기본 스타일을 그대로 받는다. 제품은 semantic 토큰 값만 바꿔 단계를 조정한다. 값(24/20/16px, 650)은 1.2배 안팎의 단계로 골랐다. 버린 대안: 컴포넌트마다 크기를 주기 — 같은 값이 여러 곳에 흩어진다. token-contract 필수 목록에 추가 — 다운스트림 토큰 파일이 바로 실패하고, 결과는 아래 e2e가 지킨다. 위험·한계: 화면이 바뀐다. 시각 골든(app-shell, state-surfaces 등)은 오케스트레이터가 갱신한다. 상태 화면이 카드(h3) 안에서 h2로 더 크게 보이는 문제는 08-05가 다룬다. 값 자체는 디자인 결정이라 바꿀 수 있다. 검증: - RED: 새 tests/e2e/typography.spec.ts가 수정 전 chromium에서 실패 (h2 16px, h3 16px: "Expected: > 16, Received: 16"). - GREEN: 같은 spec chromium·firefox·webkit 3/3 통과. accessibility·i18n· ui-gallery·app-shell·responsive·theme·design-system-interactions· compact-smoke + typography chromium/chromium-compact 32/32 통과(별도 playwright 설정, vite preview, pnpm 없이 빌드). - check-design-system PASS(48 tokens). 시각 회귀는 미실행. Refs: docs/reviews/2026-11-01-maturity-review/08-presentation.md 08-04 --- .../design-system/tokens/primitive.css | 2 ++ .../design-system/tokens/semantic.css | 5 +++ src/presentation/styles/theme/base.css | 19 ++++++++++- tests/e2e/typography.spec.ts | 33 +++++++++++++++++++ 4 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 tests/e2e/typography.spec.ts diff --git a/src/presentation/design-system/tokens/primitive.css b/src/presentation/design-system/tokens/primitive.css index c7c2b5ab..c0b47770 100644 --- a/src/presentation/design-system/tokens/primitive.css +++ b/src/presentation/design-system/tokens/primitive.css @@ -26,6 +26,8 @@ --font-size-sm: 0.875rem; --font-size-md: 1rem; --font-size-lg: 1.125rem; + --font-size-xl: 1.25rem; + --font-size-2xl: 1.5rem; --line-height-tight: 1.25; --line-height-normal: 1.5; --line-height-relaxed: 1.7; diff --git a/src/presentation/design-system/tokens/semantic.css b/src/presentation/design-system/tokens/semantic.css index de4142f0..0d8f8ab8 100644 --- a/src/presentation/design-system/tokens/semantic.css +++ b/src/presentation/design-system/tokens/semantic.css @@ -31,6 +31,11 @@ --color-danger-border: oklch(0.72 0.12 25); --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. */ + --font-size-heading-2: var(--font-size-2xl); + --font-size-heading-3: var(--font-size-xl); + --font-size-heading-4: var(--font-size-md); + --font-weight-heading: var(--font-weight-semibold); --spacing-page: var(--space-6); --radius-control: var(--radius-sm); --radius-surface: var(--radius-md); diff --git a/src/presentation/styles/theme/base.css b/src/presentation/styles/theme/base.css index aeb4f630..3c2a3d82 100644 --- a/src/presentation/styles/theme/base.css +++ b/src/presentation/styles/theme/base.css @@ -34,8 +34,25 @@ letter-spacing: -0.04em; } + /* 08-04. Tailwind's preflight resets headings to body text; each level + gets its own step so a section title does not read like a paragraph. */ + h2, + h3, + h4 { + font-weight: var(--font-weight-heading); + line-height: var(--line-height-tight); + } + h2 { - line-height: 1.25; + font-size: var(--font-size-heading-2); + } + + h3 { + font-size: var(--font-size-heading-3); + } + + h4 { + font-size: var(--font-size-heading-4); } :focus-visible { diff --git a/tests/e2e/typography.spec.ts b/tests/e2e/typography.spec.ts new file mode 100644 index 00000000..3fa3cfe3 --- /dev/null +++ b/tests/e2e/typography.spec.ts @@ -0,0 +1,33 @@ +import { expect, test } from "../support/browser/strict-browser-test.ts"; + +// 08-04. Tailwind's preflight resets every heading to the body size and +// weight, so a section title read like a paragraph. Each level must stand +// apart from the next one and from body copy. +test("steps heading size and weight down from h2 to body copy", async ({ + page, +}) => { + await page.goto("/examples/states"); + await expect(page.getByRole("heading", { level: 1 })).toBeVisible(); + + const scale = await page.evaluate(() => { + const read = (element: Element | null) => { + if (!element) throw new Error("missing element"); + const style = getComputedStyle(element); + return { + size: Number.parseFloat(style.fontSize), + weight: Number.parseFloat(style.fontWeight), + }; + }; + const main = document.querySelector("main"); + return { + h2: read(main?.querySelector("h2") ?? null), + h3: read(main?.querySelector("h3") ?? null), + body: read(document.body), + }; + }); + + expect(scale.h2.size).toBeGreaterThan(scale.h3.size); + expect(scale.h3.size).toBeGreaterThan(scale.body.size); + expect(scale.h2.weight).toBeGreaterThan(scale.body.weight); + expect(scale.h3.weight).toBeGreaterThan(scale.body.weight); +});