fix: 다크 모드에서 흰 바탕에 흰 글씨로 나가던 것

배색을 토큰 별칭으로 옮기면서 TechLog 가 템플릿의 `--color-*` 를 가리키게
됐는데, 템플릿에는 `:root[data-theme="dark"]` 가 있고 그쪽이 더 구체적인
선택자라 TechLog 의 `:root` 를 이긴다. 운영체제가 어두운 화면을 쓰는 사람에게는
글자색만 뒤집히고 배경은 이 파일의 원색(`rgba(252, 252, 251, 0.94)`)이 그대로
남았다 — 스튜디오 헤더가 흰 바탕에 흰 글씨였고, 링크가 안 보이니 눌러도
아무 일이 없는 것처럼 읽혔다.

이 파일의 값은 전부 밝은 화면 하나만 상정하고 고른 것이므로 다크에도 같은
값을 건다. 템플릿의 밝은 값을 그냥 쓰던 여섯 개(hover·pressed·on-action·
disabled 계열)도 이름을 적어 둔다 — 적지 않으면 그 여섯만 혼자 어두워진다.

어두운 배색을 따로 그리는 일은 하지 않았다. 지금은 한 벌만 쓴다.

검사는 「템플릿이 어둡게 덮는 토큰은 TechLog 도 같은 조건에서 되돌린다」를
본다. 템플릿이 새 토큰을 어둡게 덮기 시작하면 그 이름을 짚는다 — 손으로
맞춘 목록은 반드시 낡는다.

(cherry picked from commit 42d1ae1f2da395eb69a29dfaec8bebcd7a003b63)
This commit is contained in:
DongHyeonka
2026-11-12 08:28:55 +09:00
parent c80320dfc7
commit 2fea5c58f4
2 changed files with 55 additions and 1 deletions
@@ -6,7 +6,14 @@
* TechLog-scoped tokens. This preserves the existing visual design without
* letting raw palette values spread through feature CSS.
*/
:root {
/*
다크에도 같은 값을 건다. 이 파일의 값은 전부 밝은 화면 하나만 상정하고 고른 것이라
(`rgba(252, 252, 251, 0.94)` 같은 원색이 그대로 들어 있다) 템플릿의 `[data-theme="dark"]`
가 글자색만 뒤집으면 흰 바탕에 흰 글씨가 된다 — 스튜디오 헤더가 실제로 그렇게 나갔고,
링크가 안 보이니 눌리지 않는 것처럼 읽혔다. 어두운 배색을 따로 그리기 전까지는 한 벌만 쓴다.
*/
:root,
:root[data-theme="dark"] {
--techlog-theme-surface: #f7f7f5;
--techlog-theme-surface-muted: #f0f0ed;
--techlog-theme-panel: #fcfcfb;
@@ -54,6 +61,16 @@
--color-success-content: var(--techlog-theme-success-content);
--color-success-surface: var(--techlog-theme-success-surface);
--color-success-border: var(--techlog-theme-success-border);
/*
TechLog 가 직접 고르지 않고 템플릿의 밝은 값을 그대로 쓰던 것들. 이름을 적어 두지 않으면
다크에서만 이 여섯 개가 뒤집혀 눌린 단추와 비활성 글자만 혼자 어두워진다.
*/
--color-action-hover: var(--palette-blue-700);
--color-action-pressed: var(--palette-blue-700);
--color-danger-hover: var(--palette-red-700);
--color-on-action: var(--palette-white);
--color-disabled-content: color-mix(in oklch, var(--color-content) 55%, transparent);
--color-disabled-surface: var(--color-surface-muted);
--color-info-content: var(--techlog-theme-action);
--color-info-surface: var(--techlog-theme-info-surface);
--color-info-border: var(--techlog-theme-info-border);
@@ -0,0 +1,37 @@
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
/*
TechLog 의 배색은 밝은 화면 하나만 상정하고 고른 값이다. 템플릿은 `[data-theme="dark"]` 로
같은 이름의 토큰을 뒤집는데, 그쪽이 더 구체적인 선택자라 TechLog 의 `:root` 를 이긴다.
글자색만 뒤집히고 배경은 원색 그대로 남아 흰 바탕에 흰 글씨가 나온 적이 있다.
그래서 템플릿이 어둡게 덮는 토큰은 TechLog 도 같은 조건에서 되돌려 놓아야 한다. 템플릿이
새 토큰을 어둡게 덮기 시작하면 이 검사가 그 이름을 짚는다 — 손으로 맞춘 목록은 반드시 낡는다.
*/
const TEMPLATE = "src/presentation/design-system/tokens/semantic.css";
const TECH_LOG = "src/features/tech-log/presentation/styles/tech-log-theme.css";
/** 선택자가 `match` 를 포함하는 블록들이 정의한 커스텀 속성 이름. */
function propertiesUnder(file: string, match: string): ReadonlySet<string> {
// 주석을 먼저 지운다. 남겨 두면 블록 앞 주석이 선택자에 붙어, 설명으로 적은 낱말만으로도
// 통과한다 — 이 검사를 처음 세웠을 때 실제로 그렇게 통과했다.
const source = readFileSync(file, "utf8").replace(/\/\*[\s\S]*?\*\//gu, " ");
const names = new Set<string>();
for (const block of source.matchAll(/([^{}]+)\{([^{}]*)\}/gu)) {
const [, selector = "", body = ""] = block;
if (!selector.includes(match)) continue;
for (const declaration of body.matchAll(/(--[\w-]+)\s*:/gu)) names.add(declaration[1]!);
}
return names;
}
describe("TechLog 배색은 다크에서도 한 벌이다", () => {
it("템플릿이 어둡게 덮는 토큰을 TechLog 가 같은 조건에서 되돌린다", () => {
const darkened = propertiesUnder(TEMPLATE, '[data-theme="dark"]');
const restored = propertiesUnder(TECH_LOG, '[data-theme="dark"]');
expect(darkened.size).toBeGreaterThan(0);
expect([...darkened].filter((name) => !restored.has(name))).toEqual([]);
});
});