- Add theme-raw.ts (no MUI/DOM deps) as the one source of theme values. Each theme declares only surfaces, 3-tier text, borders, accent and overlay shadow; legacy glass/gradient/glow/crt keys are derived as flat values so existing call sites lose effects without edits. - Tertiary text now clears 4.5:1 on every surface in all six themes (label/inactive/dimLabel/muted alias it). Filled buttons use accent.solid + accent.ink (5.17:1 on dark/light, was 3.68:1). - theme-vars.ts derives popup CSS from the same raw values instead of a hand copy, and defines the previously undefined --d3-overlay-strong and --d3-accent-glow-dim. - MUI: no ripple, global focus-visible ring and reduced-motion rule, flat Card, status colors per theme, shape radius 16 -> 6. - DS: flatten MetalCard/DoubleBezelCard/ScreenPanel/TiltCard, tone-based PhysicalButton (500 weight, no lift), TactileBadge with zero tracking and keyboard support, glow-free Led/StatRing, idle wave amplitude 0. - PhosphorText drops mono/uppercase variants: mono has no Hangul glyphs, which spaced out Korean labels. - design.md: record the 2026-09-28 redesign brief, audit, IA and tokens.
58 lines
2.3 KiB
TypeScript
58 lines
2.3 KiB
TypeScript
// packages/ui/src/theme-vars.ts
|
|
// 팝업 윈도우용 CSS 변수 맵.
|
|
// main process (WindowManager)에서 insertCSS로 팝업에 테마를 주입할 때 사용.
|
|
// 값은 theme-raw.ts(렌더러와 같은 원시값)에서 파생한다 — 손으로 복제하지 않는다.
|
|
// Node.js/Electron main 환경에서 import 가능 (MUI·DOM 의존 없음).
|
|
|
|
import { RAW, STATUS, buildCssVars, isThemeKey, type ThemeKey } from './theme-raw'
|
|
|
|
export type PopupThemeKey = ThemeKey
|
|
|
|
/**
|
|
* 팝업 CSS 가 쓰는 전용 별칭. 렌더러 공통 변수(buildCssVars) 위에 얹는다.
|
|
* v4: 팝업도 평면 — 반투명 배경·다색 파형을 쓰지 않는다.
|
|
*/
|
|
function popupAliases(key: ThemeKey): Record<string, string> {
|
|
const r = RAW[key]
|
|
const st = STATUS[key]
|
|
const wave: Record<string, string> = {}
|
|
for (let i = 1; i <= 9; i++) wave[`--d3-wave-${i}`] = r.accent.main
|
|
return {
|
|
'--d3-bg-tip': r.bg.card,
|
|
'--d3-shadow-popup': r.shadow.overlay,
|
|
'--d3-bg-result': r.bg.card,
|
|
'--d3-border-result': r.border.default,
|
|
'--d3-text-result': r.text.primary,
|
|
'--d3-action-btn': r.text.secondary,
|
|
'--d3-action-btn-hover-bg': 'var(--d3-overlay-soft)',
|
|
'--d3-action-btn-hover': r.text.primary,
|
|
'--d3-accent-glow-dim': r.accent.dim,
|
|
'--d3-status-error': st.danger,
|
|
...wave,
|
|
}
|
|
}
|
|
|
|
/** ThemeMode('system' | 'auto' | 테마 키)를 팝업 테마 키로. 시스템 모드는 호출자가 prefersDark 를 넘긴다. */
|
|
export function resolvePopupThemeKey(themeKey: string, prefersDark = true): PopupThemeKey {
|
|
if (isThemeKey(themeKey)) return themeKey
|
|
if (themeKey === 'system' || themeKey === 'auto') return prefersDark ? 'dark' : 'light'
|
|
return 'dark'
|
|
}
|
|
|
|
/** 팝업용 CSS 변수 맵 조회. 알 수 없는 값은 'dark'. */
|
|
export function getPopupThemeVars(themeKey: string, prefersDark = true): Record<string, string> {
|
|
const key = resolvePopupThemeKey(themeKey, prefersDark)
|
|
return { ...buildCssVars(key), ...popupAliases(key) }
|
|
}
|
|
|
|
/**
|
|
* 팝업 BrowserWindow에 insertCSS로 주입할 CSS 문자열 반환.
|
|
* `:root { --d3-bg-card: #111a30; ... }`
|
|
*/
|
|
export function buildPopupThemeCss(themeKey: string, prefersDark = true): string {
|
|
const vars = getPopupThemeVars(themeKey, prefersDark)
|
|
const declarations = Object.entries(vars)
|
|
.map(([prop, value]) => ` ${prop}: ${value};`)
|
|
.join('\n')
|
|
return `:root {\n${declarations}\n}`
|
|
}
|