Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-8772: feat(appearance): Appearance settings and themeable built-in themes (#10126)
Jiayuan Zhangac5f97c5d656
diff --git a/apps/desktop/eslint.config.mjs b/apps/desktop/eslint.config.mjsindex 6065f65c47..1f44e107ab 100644--- a/apps/desktop/eslint.config.mjs+++ b/apps/desktop/eslint.config.mjs@@ -1,6 +1,6 @@import globals from "globals";import reactConfig from "@multica/eslint-config/react";-import { ICON_LIBRARY_IMPORT_PATTERNS } from "@multica/eslint-config/base";+import { ICON_LIBRARY_IMPORT_PATTERNS, REDUCED_MOTION_IMPORT } from "@multica/eslint-config/base";import { NO_ROUND_CONTROLS } from "@multica/eslint-config/control-shape";export default [@@ -64,6 +64,7 @@ export default [message:"Direct navigation from application code breaks the Coordinator protocol (MUL-4741). Use the navigation adapter from src/platform instead.",},+ REDUCED_MOTION_IMPORT,],patterns: ICON_LIBRARY_IMPORT_PATTERNS,},diff --git a/apps/desktop/package.json b/apps/desktop/package.jsonindex 8ebabd9ac5..50031bd633 100644--- a/apps/desktop/package.json+++ b/apps/desktop/package.json@@ -41,6 +41,7 @@"@electron-toolkit/utils": "^4.0.0","@fontsource-variable/geist-mono": "^5.3.0","@fontsource-variable/inter": "^5.2.5",+ "@fontsource-variable/jetbrains-mono": "^5.3.0","@fontsource-variable/source-serif-4": "^5.2.9","@multica/core": "workspace:*","@multica/ui": "workspace:*",diff --git a/apps/desktop/src/renderer/src/App.tsx b/apps/desktop/src/renderer/src/App.tsxindex 3ad3b0b923..46de05b822 100644--- a/apps/desktop/src/renderer/src/App.tsx+++ b/apps/desktop/src/renderer/src/App.tsx@@ -24,6 +24,7 @@ import { useDaemonIPCBridge } from "./platform/daemon-ipc-bridge";import { syncDaemonOnLogin } from "./platform/daemon-login-sync";import { createDesktopLocaleAdapter } from "./platform/i18n-adapter";import { captureEvent } from "@multica/core/analytics";+import { AppearanceSync } from "@multica/views/common/appearance-sync";import { RESOURCES } from "@multica/views/locales";import { DesktopClientUsageReporter } from "./platform/client-usage-reporter";import { DiagnosticRouteReporter } from "./platform/diagnostic-route-reporter";@@ -468,6 +469,7 @@ export default function App() {return (<ThemeProvider>+ <AppearanceSync />{runtimeConfigResult.ok ? (<CoreProviderapiBaseUrl={runtimeConfigResult.config.apiUrl}diff --git a/apps/desktop/src/renderer/src/components/desktop-layout.tsx b/apps/desktop/src/renderer/src/components/desktop-layout.tsxindex cbce145fe4..b0095e5133 100644--- a/apps/desktop/src/renderer/src/components/desktop-layout.tsx+++ b/apps/desktop/src/renderer/src/components/desktop-layout.tsx@@ -83,6 +83,7 @@ function MainTopBar({ railMounted }: { railMounted: boolean }) {return (<headerdata-slot="main-top-bar"+ data-mc="tab-bar"className={cn("relative shrink-0 flex items-center gap-2", TOP_BAR_HEIGHT_CLASS)}style={{ paddingLeft: toolbarClearance }}>@@ -138,8 +139,9 @@ function MainCanvas({return (<divdata-slot="main-canvas"+ data-mc="page"className={cn(- "relative mr-2 mb-2 flex min-h-0 flex-1 flex-row overflow-hidden rounded-xl bg-page-canvas shadow-[var(--surface-shadow)] ring-1 ring-surface-border",+ "relative mr-2 mb-2 flex min-h-0 flex-1 flex-row overflow-hidden rounded-page bg-page-canvas shadow-[var(--page-shadow,var(--surface-shadow))] ring-1 ring-page-border",railMounted && !isCompact ? "ml-0" : "ml-2",)}>diff --git a/apps/desktop/src/renderer/src/components/tab-bar.tsx b/apps/desktop/src/renderer/src/components/tab-bar.tsxindex bb52599abb..4ed59a6721 100644--- a/apps/desktop/src/renderer/src/components/tab-bar.tsx+++ b/apps/desktop/src/renderer/src/components/tab-bar.tsx@@ -6,7 +6,8 @@ import {useState,type RefObject,} from "react";-import { motion, useReducedMotion } from "motion/react";+import { motion } from "motion/react";+import { useReducedMotion } from "@multica/core/appearance";import { X, Plus, Pin, PinOff, ListX, AppWindow } from "@multica/ui/icons";import {DndContext,@@ -491,7 +492,7 @@ export function TabBar() {const group = useActiveGroup();const moveTab = useTabStore((s) => s.moveTab);const activeWorkspaceSlug = useTabStore((s) => s.activeWorkspaceSlug);- const shouldReduceMotion = useReducedMotion() ?? false;+ const shouldReduceMotion = useReducedMotion();const tabScrollRef = useRef<HTMLDivElement>(null);const previousTabsRef = useRef<TabSnapshot | null>(null);const tabFadeStyle = useScrollFade(diff --git a/apps/desktop/src/renderer/src/components/window-toolbar.tsx b/apps/desktop/src/renderer/src/components/window-toolbar.tsxindex cf766725c5..9f9e4f300e 100644--- a/apps/desktop/src/renderer/src/components/window-toolbar.tsx+++ b/apps/desktop/src/renderer/src/components/window-toolbar.tsx@@ -253,6 +253,7 @@ export function WindowToolbar() {return (<divdata-slot="window-toolbar"+ data-mc="window-toolbar"className="fixed left-0 top-0 z-30 flex h-10 shrink-0 items-center pr-3"style={{diff --git a/apps/desktop/src/renderer/src/globals.css b/apps/desktop/src/renderer/src/globals.cssindex 0bd8e0f48b..17beb9358d 100644--- a/apps/desktop/src/renderer/src/globals.css+++ b/apps/desktop/src/renderer/src/globals.css@@ -2,6 +2,8 @@@import "tw-animate-css";@import "shadcn/tailwind.css";@import "@multica/ui/styles/tokens.css";+@import "@multica/ui/styles/theme-variables.css";+@import "@multica/ui/styles/appearance.css";@import "@multica/ui/styles/base.css";@custom-variant dark (&:is(.dark *));@@ -21,14 +23,23 @@would falsely signal alignment guarantees. Browser default fallback handlesthe rare mixed case correctly. */:root {- --font-sans: "Inter Variable", "Inter", -apple-system, BlinkMacSystemFont,- "Segoe UI", "PingFang SC", "Microsoft YaHei",- "Noto Sans CJK SC", "Apple SD Gothic Neo", "Malgun Gothic",- "Noto Sans CJK KR", sans-serif;+ /* --font-ui and --font-cjk are set by the Appearance settings+ (packages/core/appearance); unset, the stack is Inter + the CJK chain. */+ --font-sans: var(--font-ui, "Inter Variable", "Inter"),+ var(--font-cjk, var(--font-cjk-sans));+ --font-cjk-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",+ "Microsoft YaHei", "Noto Sans CJK SC", "Apple SD Gothic Neo",+ "Malgun Gothic", "Noto Sans CJK KR", sans-serif;--font-serif: "Source Serif 4 Variable", "Source Serif 4", "Iowan Old Style","Apple Garamond", Baskerville, "Times New Roman", serif;--font-mono: "Geist Mono Variable", "Geist Mono", ui-monospace, SFMono-Regular,Menlo, Consolas, monospace;+ /* Latin-only faces the Appearance settings can pick. Web defines the same+ names over its next/font families. */+ --font-ui-inter: "Inter Variable", "Inter";+ --font-ui-serif: "Source Serif 4 Variable", "Source Serif 4";+ --font-ui-mono: "Geist Mono Variable", "Geist Mono";+ --font-code-jetbrains: "JetBrains Mono Variable", "JetBrains Mono";}/* Japanese-scoped CJK override. Japanese Kanji share the Han Unicode block@@ -43,23 +54,21 @@`ja` or `ja-<region>` (App.tsx sets `ja-JP`), never unrelated subtagssuch as `jam`. */html[lang|="ja"] {- --font-sans: "Inter Variable", "Inter", "Hiragino Sans",- "Hiragino Kaku Gothic ProN", "Yu Gothic", "YuGothic", "Meiryo",- "Noto Sans CJK JP", "Noto Sans JP", -apple-system,- BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei",- "Noto Sans CJK SC", "Apple SD Gothic Neo", "Malgun Gothic",- "Noto Sans CJK KR", sans-serif;+ --font-cjk-sans: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic",+ "YuGothic", "Meiryo", "Noto Sans CJK JP", "Noto Sans JP",+ -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",+ "Microsoft YaHei", "Noto Sans CJK SC", "Apple SD Gothic Neo",+ "Malgun Gothic", "Noto Sans CJK KR", sans-serif;}/* Traditional Chinese: same problem one level down — the default stack isSimplified-first, so zh-TW users get Simplified glyph shapes for sharedideographs. App.tsx maps zh-Hant to `zh-TW`. Mirrors apps/web/app/globals.css. */html[lang="zh-TW"] {- --font-sans: "Inter Variable", "Inter", -apple-system, BlinkMacSystemFont,- "Segoe UI", "PingFang TC", "Microsoft JhengHei",- "Noto Sans CJK TC", "PingFang SC", "Microsoft YaHei",- "Noto Sans CJK SC", "Apple SD Gothic Neo", "Malgun Gothic",- "Noto Sans CJK KR", sans-serif;+ --font-cjk-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",+ "Microsoft JhengHei", "Noto Sans CJK TC", "PingFang SC",+ "Microsoft YaHei", "Noto Sans CJK SC", "Apple SD Gothic Neo",+ "Malgun Gothic", "Noto Sans CJK KR", sans-serif;}@source "../../../../../packages/ui/**/*.tsx";diff --git a/apps/desktop/src/renderer/src/main.tsx b/apps/desktop/src/renderer/src/main.tsxindex 0ba4c09790..2e5a622b1d 100644--- a/apps/desktop/src/renderer/src/main.tsx+++ b/apps/desktop/src/renderer/src/main.tsx@@ -28,6 +28,9 @@ import "@fontsource-variable/source-serif-4/wght-italic.css";// markdown (600 -> 700). One variable file covers 100-900 and closes the whole// class instead of chasing weights one at a time.import "@fontsource-variable/geist-mono";+// Optional code font from the Appearance settings; the browser only loads the+// face once something renders with it.+import "@fontsource-variable/jetbrains-mono";import "./globals.css";// react-grab: dev-only element inspector. Hold ⌘C (Mac) / Ctrl+C and click anydiff --git a/apps/web/app/custom.css b/apps/web/app/custom.cssindex e10b06dcf2..2855287804 100644--- a/apps/web/app/custom.css+++ b/apps/web/app/custom.css@@ -76,8 +76,8 @@/* -----------------------------------------------------------------------------* Landing editorial serif*- * The landing tree swaps the app's `--font-serif` (Source Serif 4, set on <html>- * by app/layout.tsx) for Instrument Serif, loaded by app/(landing)/layout.tsx as+ * The landing tree swaps the app's `--font-serif` (Source Serif 4, composed in+ * app/globals.css) for Instrument Serif, loaded by app/(landing)/layout.tsx as* `--font-instrument-serif`. The stack is composed here in static CSS rather* than in next/font's `fallback` for the same reasons `--font-sans` is composed* in app/globals.css: it has to be overridable per `<html lang>`, and it staysdiff --git a/apps/web/app/font-stacks.test.ts b/apps/web/app/font-stacks.test.tsnew file mode 100644index 0000000000..dea05e9cce--- /dev/null+++ b/apps/web/app/font-stacks.test.ts@@ -0,0 +1,52 @@+// @vitest-environment node+import { readFileSync } from "node:fs";+import { resolve } from "node:path";+import { describe, expect, it } from "vitest";++const read = (path: string) => readFileSync(resolve(__dirname, path), "utf8");+const webCss = read("./globals.css");+const desktopCss = read("../../desktop/src/renderer/src/globals.css");+const layout = read("./layout.tsx");++const GENERIC = /^(?:serif|sans-serif|monospace|cursive|fantasy|system-ui|math|emoji|fangsong|ui-[a-z-]+)$/;++function rootVariable(css: string, name: string): string {+ const match = css.match(new RegExp(`^\\s*${name}:\\s*([^;]+);`, "m"));+ if (!match?.[1]) throw new Error(`${name} is not declared`);+ return match[1];+}++/** The families next/font writes into `variable`: the face, its metric fallback and `fallback`. */+function nextFontFamilies(variable: string): string[] {+ const call = layout.split(/\n(?=const \w+ = \w+\()/).find((block) => block.includes(`variable: "${variable}"`));+ if (!call) throw new Error(`no next/font call declares ${variable}`);+ const fallback = call.match(/fallback:\s*\[([^\]]*)\]/)?.[1] ?? "";+ return ["<face>", "<face> Fallback", ...[...fallback.matchAll(/"([^"]+)"/g)].map((m) => m[1]!)];+}++function families(stack: string): string[] {+ return stack.split(",").flatMap((part) => {+ const family = part.trim().replace(/^["']|["']$/g, "");+ const variable = family.match(/^var\((--[\w-]+)\)$/)?.[1];+ return variable ? nextFontFamilies(variable) : [family];+ });+}++describe("Appearance Latin faces", () => {+ // The CJK choice follows these in --font-sans and --font-content, so a+ // generic family here would draw Han before the CJK font is reached.+ const names = ["--font-ui-inter", "--font-ui-serif", "--font-ui-mono"];++ it.each(names)("web %s names families only", (name) => {+ expect(families(rootVariable(webCss, name)).filter((f) => GENERIC.test(f))).toEqual([]);+ });++ it.each(names)("desktop %s names families only", (name) => {+ expect(families(rootVariable(desktopCss, name)).filter((f) => GENERIC.test(f))).toEqual([]);+ });++ it("keeps the onboarding serif ending with its generic fallbacks", () => {+ expect(families(rootVariable(webCss, "--font-serif")).slice(-2)).toEqual(["Times New Roman", "serif"]);+ expect(families(rootVariable(webCss, "--font-serif"))).toContain("ui-serif");+ });+});diff --git a/apps/web/app/globals.css b/apps/web/app/globals.cssindex 11b9eda17c..3fd440c1e0 100644--- a/apps/web/app/globals.css+++ b/apps/web/app/globals.css@@ -2,6 +2,8 @@@import "tw-animate-css";@import "shadcn/tailwind.css";@import "../../../packages/ui/styles/tokens.css";+@import "../../../packages/ui/styles/theme-variables.css";+@import "../../../packages/ui/styles/appearance.css";@import "../../../packages/ui/styles/base.css";@import "./custom.css";@@ -24,9 +26,25 @@block, so ko users still get Korean fonts for Hangul). Kept in sync withapps/desktop/src/renderer/src/globals.css. */:root {- --font-sans: var(--font-inter), -apple-system, BlinkMacSystemFont, "Segoe UI",- "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Apple SD Gothic Neo",- "Malgun Gothic", "Noto Sans CJK KR", sans-serif;+ /* --font-ui and --font-cjk are set by the Appearance settings+ (packages/core/appearance); unset, the stack is Inter + the CJK chain. */+ --font-sans: var(--font-ui, var(--font-inter)), var(--font-cjk, var(--font-cjk-sans));+ --font-cjk-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",+ "Microsoft YaHei", "Noto Sans CJK SC", "Apple SD Gothic Neo", "Malgun Gothic",+ "Noto Sans CJK KR", sans-serif;+ --font-mono: var(--font-geist-mono), ui-monospace, SFMono-Regular, Menlo, Consolas,+ monospace;+ --font-serif: var(--font-source-serif), ui-serif, "Iowan Old Style", "Apple Garamond",+ Baskerville, "Times New Roman", serif;+ /* Latin-only faces the Appearance settings can pick, over the next/font+ families from app/layout.tsx. Desktop defines the same names. The CJK+ font follows them, so they name families only: a generic family would+ match Han first. */+ --font-ui-inter: var(--font-inter);+ --font-ui-serif: var(--font-source-serif), "Iowan Old Style", "Apple Garamond",+ Baskerville, "Times New Roman";+ --font-ui-mono: var(--font-geist-mono);+ --font-code-jetbrains: var(--font-jetbrains-mono);}/* Japanese: Kanji are Han ideographs sharing the same Unicode block as Chinese,@@ -37,7 +55,7 @@or `ja-<region>` (layout.tsx emits `ja-JP`), never unrelated 3-letter subtagssuch as `jam`. Inter still leads for Latin; zh/ko remain as a deep fallback. */html[lang|="ja"] {- --font-sans: var(--font-inter), "Hiragino Sans", "Hiragino Kaku Gothic ProN",+ --font-cjk-sans: "Hiragino Sans", "Hiragino Kaku Gothic ProN","Yu Gothic", "YuGothic", "Meiryo", "Noto Sans CJK JP", "Noto Sans JP",-apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC","Microsoft YaHei", "Noto Sans CJK SC", "Apple SD Gothic Neo", "Malgun Gothic",@@ -49,7 +67,7 @@ html[lang|="ja"] {for. Promote the Traditional families for that locale only (layout.tsx emits`zh-TW` for zh-Hant). Kept in sync with the desktop stack. */html[lang="zh-TW"] {- --font-sans: var(--font-inter), -apple-system, BlinkMacSystemFont, "Segoe UI",+ --font-cjk-sans: -apple-system, BlinkMacSystemFont, "Segoe UI","PingFang TC", "Microsoft JhengHei", "Noto Sans CJK TC", "PingFang SC","Microsoft YaHei", "Noto Sans CJK SC", "Apple SD Gothic Neo", "Malgun Gothic","Noto Sans CJK KR", sans-serif;diff --git a/apps/web/app/layout.tsx b/apps/web/app/layout.tsxindex feabf87bea..c828587032 100644--- a/apps/web/app/layout.tsx+++ b/apps/web/app/layout.tsx@@ -1,6 +1,6 @@import type { Metadata, Viewport } from "next";import Script from "next/script";-import { Inter, Geist_Mono, Source_Serif_4 } from "next/font/google";+import { Inter, Geist_Mono, JetBrains_Mono, Source_Serif_4 } from "next/font/google";import { ThemeProvider } from "@/components/theme-provider";import { Toaster } from "@multica/ui/components/ui/sonner";import { cn } from "@multica/ui/lib/utils";@@ -47,28 +47,30 @@ const inter = Inter({// Mono font has no explicit CJK fallback: CJK chars in code blocks are inherently// non-aligned with a mono grid (Chinese is proportional), so listing CJK fonts// here would falsely signal alignment guarantees. Browser default fallback handles-// the rare mixed case correctly.+// the rare mixed case correctly. `--font-mono` itself is composed in+// ./globals.css so the Appearance code font can replace it without losing the+// Geist family, which the monospace UI font still uses.const geistMono = Geist_Mono({subsets: ["latin"],- variable: "--font-mono",- fallback: ["ui-monospace", "SFMono-Regular", "Menlo", "Consolas", "monospace"],+ variable: "--font-geist-mono",});-// Editorial serif used for onboarding headlines. Italic support for h1 em-// accents (e.g. "...on one shared board."). Only loaded on routes that-// render the font; layout-shift-prevention handled by next/font's synthetic-// fallback metrics, same as Inter.+// Optional code font from the Appearance settings. Not preloaded: the face is+// only fetched once something renders with it.+const jetbrainsMono = JetBrains_Mono({+ subsets: ["latin"],+ variable: "--font-jetbrains-mono",+ preload: false,+});+// Editorial serif used for onboarding headlines and the Appearance "Serif"+// font. Italic support for h1 em accents (e.g. "...on one shared board.").+// Only loaded on routes that render the font; layout-shift-prevention handled+// by next/font's synthetic fallback metrics, same as Inter. No `fallback`:+// next/font writes it into the variable, and the stacks built on it in+// ./globals.css differ in whether they may end with a generic family.const sourceSerif = Source_Serif_4({subsets: ["latin"],style: ["normal", "italic"],- variable: "--font-serif",- fallback: [- "ui-serif",- "Iowan Old Style",- "Apple Garamond",- "Baskerville",- "Times New Roman",- "serif",- ],+ variable: "--font-source-serif",});export const viewport: Viewport = {@@ -143,7 +145,7 @@ export default async function RootLayout({<htmllang={HTML_LANG[locale]}suppressHydrationWarning- className={cn("antialiased font-sans h-full", inter.variable, geistMono.variable, sourceSerif.variable)}+ className={cn("antialiased font-sans h-full", inter.variable, geistMono.variable, jetbrainsMono.variable, sourceSerif.variable)}><body className="h-full overflow-hidden">{/*diff --git a/apps/web/app/text-contrast.test.ts b/apps/web/app/text-contrast.test.tsindex 1f114a6fdf..fa581174c5 100644--- a/apps/web/app/text-contrast.test.ts+++ b/apps/web/app/text-contrast.test.ts@@ -2,6 +2,7 @@import { readFileSync, readdirSync, statSync } from "node:fs";import { resolve, join, relative } from "node:path";import { describe, expect, it } from "vitest";+import { BUILT_IN_THEMES, type ThemeTokens } from "@multica/core/appearance";/*** Is every tone the product paints text and marks with actually legible, and is@@ -142,10 +143,11 @@ function expectTonePasses(declarations: Map<string, string>,tone: string,floor: number,+ backgrounds: readonly string[] = backgroundTokens,) {const foreground = oklchToRgb(resolveToken(declarations, tone));- for (const token of backgroundTokens) {+ for (const token of backgrounds) {const background = oklchToRgb(resolveToken(declarations, token));const ratio = contrastRatio(foreground, background);@@ -161,6 +163,20 @@ const tokensCss = () =>const landingCss = () =>readFileSync(resolve(repoRoot, "apps/web/app/custom.css"), "utf8");+/** Later declarations win, as the generated theme stylesheet does over tokens.css. */+const layered = (...blocks: Map<string, string>[]) =>+ new Map(blocks.flatMap((block) => [...block]));++const asDeclarations = (tokens: ThemeTokens | undefined) =>+ new Map(Object.entries(tokens ?? {}).map(([name, value]) => [`--${name}`, value]));++/** What each mode paints under a theme: tokens.css for that mode, then the manifest. */+function themePalette(mode: "light" | "dark", tokens: ThemeTokens | undefined) {+ const base = readBlock(tokensCss(), ":root");+ const palette = mode === "dark" ? layered(base, readBlock(tokensCss(), ".dark")) : base;+ return layered(palette, asDeclarations(tokens));+}+// ── source scanning ────────────────────────────────────────────────────────const scanRoots = ["packages/ui", "packages/views", "apps/web", "apps/desktop/src"];@@ -426,6 +442,59 @@ describe("text contrast", () => {});});+ describe("themes", () => {+ const modes = ["light", "dark"] as const;+ const cases = BUILT_IN_THEMES.flatMap((theme) =>+ modes.map((mode) => [theme.name, mode, theme] as const),+ );+ const readingSurfaces = ["--background", "--page-canvas", "--surface", "--surface-raised"];++ it.each(cases)("%s keeps both tones legible in %s mode", (_name, mode, theme) => {+ const palette = themePalette(mode, theme.tokens[mode]);+ // A theme with its own frame paints the shell behind the rail and tabs,+ // which read the frame tokens instead; the frame test covers them.+ const backgrounds = theme.frame?.[mode]+ ? backgroundTokens.filter((token) => token !== "--app-shell")+ : backgroundTokens;+ expectTonePasses(palette, "--muted-foreground", WCAG_AA_NORMAL_TEXT, backgrounds);+ expectTonePasses(palette, "--faint-foreground", WCAG_AA_NON_TEXT, backgrounds);+ expectTonePasses(palette, "--brand", WCAG_AA_NORMAL_TEXT, readingSurfaces);+ });++ it.each(cases)("%s's primary button label is legible in %s mode", (_name, mode, theme) => {+ const palette = themePalette(mode, theme.tokens[mode]);+ if (!palette.has("--button-primary")) return;+ expectTonePasses(palette, "--button-primary-foreground", WCAG_AA_NORMAL_TEXT, [+ "--button-primary",+ ]);+ });++ it.each(cases.filter(([, mode, theme]) => theme.frame?.[mode]))(+ "%s's frame is legible in %s mode",+ (_name, mode, theme) => {+ const palette = layered(+ themePalette(mode, theme.tokens[mode]),+ asDeclarations(theme.frame?.[mode]),+ );+ const frameBackgrounds = [+ "--app-shell",+ "--background",+ "--page-canvas",+ "--surface",+ "--surface-raised",+ "--surface-hover",+ "--surface-selected",+ "--muted",+ "--sidebar-accent",+ ];+ for (const tone of ["--foreground", "--muted-foreground", "--sidebar-accent-foreground"]) {+ expectTonePasses(palette, tone, WCAG_AA_NORMAL_TEXT, frameBackgrounds);+ }+ expectTonePasses(palette, "--faint-foreground", WCAG_AA_NON_TEXT, frameBackgrounds);+ },+ );+ });+// The landing route tree re-declares the light palette so token-driven// components stay light under next-themes' `.dark` class. That copy is only// correct while it matches the source, so drift here is a bug in itself — adiff --git a/docs/theming.md b/docs/theming.mdnew file mode 100644index 0000000000..3112a45618--- /dev/null+++ b/docs/theming.md@@ -0,0 +1,514 @@+# Theming Multica++A Multica theme is a manifest and some CSS. The CSS overrides public+variables for light and dark mode and can restyle the stable anchors listed+below; the manifest names the theme and can declare options that appear+under **Settings → Appearance → Theme options**. Themes never run+JavaScript.++Only the built-in themes exist for now: Default, Pop, GitHub, Blueprint and+Notion, in `packages/core/appearance/built-in-themes.ts`. People cannot+import their own. The variables, anchors and options below are what the+built-in themes are written against, and what an imported theme would use+if that comes later.++## A built-in theme++```ts+const PAPER = builtInTheme({+ id: "paper",+ name: "Paper",+ author: "Someone",+ tokens: {+ light: { "page-canvas": "#f6efdf", "font-content-latin": "Georgia, Times New Roman", "h1-style": "italic" },+ dark: { "page-canvas": "#1d1b16" },+ },+ options: [+ { id: "hyphens", type: "toggle", label: "Hyphenate", default: true },+ ],+ css: ':root[data-theme-option-hyphens] [data-mc="content"] p { hyphens: auto; }',+});+```++Add it to `BUILT_IN_THEMES` to list it in Settings. `tokens` compile to+`.theme-light { … }` and `.theme-dark { … }` rules, and `frame` (optional)+to rules for the rail, the window toolbar and the tab bar. Written as+tables, the tokens can be read by the contrast test+(`apps/web/app/text-contrast.test.ts`), which checks every built-in palette+against WCAG AA. `css` holds anything a token cannot express: selectors on+anchors and option attributes.++| Field | Rules |+| --- | --- |+| `id` | 1–40 characters of `a-z`, `0-9` and `-`, unique among the built-in themes. |+| `name` | Shown in the theme picker. |+| `author` | Optional; the design system the theme follows. |+| `tokens` | Light and dark values for public variables, without `--`. |+| `frame` | Optional light and dark values for the frame around the page. |+| `options` | Up to 24; see [Options](#options). |+| `css` | Optional extra CSS. |++Set variables on `.theme-light` and `.theme-dark` (both on `<html>`). The+CSS loads after the app's own styles while the theme is active, so at equal+specificity the theme wins; keep selectors that simple and avoid+`!important`. What the person picks on the Appearance page still wins over a+theme: high contrast replaces the muted and border colours, and font choices+other than the defaults replace the font variables. Colour is the theme's+alone; to let people pick one, declare an option.++## Variables++Every variable a theme may set is listed in the [reference](#variable-reference)+at the end, with its default. They come in layers:++- **Foundations** (colours, surfaces, shadows, `--radius`, the text scale,+ fonts) are what everything else is built from. Changing `--surface` or+ `--radius` moves every component that uses it.+- **Components and product** (menus, buttons, nav rows, issue rows, the+ board, status colours) default to a foundation. Set one to change just+ that component: `--menu-radius: 0` squares menus and nothing else.+- **Editor content** (headings, lists, tables, quotes, links, code and+ syntax colours) styles issue descriptions, comments, chat and documents.++A component variable is never declared by the app; components read it with+their default as a fallback. So it can be set on any ancestor, not only on+`.theme-light`:++```css+.theme-light [data-mc="chat-window"] {+ --code-block-background: transparent;+}+```++Token values may only use letters, digits, spaces and `#.,%()/+-`, and font+stacks are family names and `var()`; a test checks every built-in theme+against both.++## Options++Options render on the Appearance page while the theme is active. Their+types follow Obsidian's Style Settings. `toggle` and `select` mark `<html>`+with an attribute; the others set the variable `--<id>` on `<html>` for both+modes (per mode for `color`), always: the chosen value or the default. So+the theme's CSS can read them with a plain `var(--<id>)`.++| Type | Fields | Result |+| --- | --- | --- |+| `heading` | — | Starts a group; `description` is shown under it. |+| `toggle` | `default`: `true` or `false` | `data-theme-option-<id>="on"` when on, absent when off. |+| `select` | `choices`: `[{ "value", "label", "swatch"? }]`, `default` | `data-theme-option-<id>="<value>"`. With a `swatch` on every choice, the choices render as colour dots. |+| `color` | `default`: a hex colour, or `{ "light", "dark" }` | `--<id>`: a hex colour per mode, picked with a colour well for each. |+| `number` | `default`, optional `min`, `max`, `step`, `unit` | `--<id>`: the number with `unit` appended (`px`, `rem`, `%`, …). |+| `slider` | as `number`; `min` and `max` required | as `number`. |+| `text` | `default`: a CSS value | `--<id>`: what was typed, when it is a safe value. |+| `font` | `default`: a font stack | `--<id>`: a font stack (family names and `var()`). |+| `variable-select` | `choices`: `[{ "value", "label" }]` with CSS values, `default` | `--<id>`: the chosen value. |++Option ids are 1–48 characters of `a-z`, `0-9` and `-`, starting with a+letter; `select` choice values are 1–32 of the same. `label`, `description`+and choice labels are a string or an object keyed by locale (`en`,+`zh-Hans`, `zh-Hant`, `ja`, `ko`, `es`, `fr`); English is the fallback.++```json+{ "id": "page-width", "type": "slider", "label": "Page width", "default": 46, "min": 30, "max": 60, "step": 2, "unit": "rem" }+```++```css+[data-mc="content"] { max-width: var(--page-width); }+```++## Selectors++Target anchors, slots and state hooks, not class names or DOM structure:+those change without notice. Anchors, slots and hooks stay until the next+`apiVersion`.++### Anchors++| Anchor | What it marks |+| --- | --- |+| `[data-mc="app-rail"]` | The icon rail on the far left. |+| `[data-mc="sidebar"]` | The navigation panel next to the rail; `data-state` is `expanded` or `collapsed`. |+| `[data-mc="nav-item"]` | A row in the sidebar; `data-active` is `true` on the current one. |+| `[data-mc="page"]` | The rounded canvas that holds the current page. |+| `[data-mc="window-toolbar"]` | Desktop only: the toolbar above the rail. |+| `[data-mc="tab-bar"]` | Desktop only: the tab strip above the page. |+| `[data-mc="issue-group-header"]` | A status group header in issue lists; `data-status` is the status key (`backlog`, `todo`, `in_progress`, `in_review`, `done`, `blocked`, `cancelled`, or a custom key). |+| `[data-mc="issue-row"]` | One issue in a list; `data-status`, `data-priority` (`urgent`, `high`, `medium`, `low`, `none`) and `data-assignee-type` (`member`, `agent`, `squad` or `none`). |+| `[data-mc="board-column"]` | One column on a board. |+| `[data-mc="board-card"]` | One issue card on a board; same attributes as `issue-row`. |+| `[data-mc="status-icon"]` | The status glyph (an `svg`). |+| `[data-mc="priority-icon"]` | The priority glyph (an `svg`). |+| `[data-mc="label-chip"]` | A label; `data-color` is its hex colour. |+| `[data-mc="content"]` | Rich text: issue descriptions, comments, chat messages and documents, reading and editing. `data-density` is `document` or `compact` when reading. |+| `[data-mc="comment"]` | A top-level comment card; `data-author-type` is `member`, `agent` or `system`. |+| `[data-mc="comment-reply"]` | A reply inside a comment card; `data-author-type` as on `comment`. |+| `[data-mc="comment-composer"]` | The box for writing a new comment. |+| `[data-mc="chat-window"]` | The chat panel. |+| `[data-mc="chat-input"]` | The message box in chat. |+| `[data-mc="chat-message"]` | One message in a chat; `data-role` is `user` or `assistant`. |+| `[data-mc="inbox-item"]` | One notification in the inbox; `data-read` is `true` or `false`. |+| `[data-mc="settings-page"]` | The settings page. |++UI primitives carry a `data-slot`; these are public too: `button` (also+`data-variant` and `data-size`), `input`, `textarea`, `switch`, `checkbox`,+`select-trigger`, `select-content`, `select-item`,+`dropdown-menu-content`, `dropdown-menu-item`, `popover-content`,+`tooltip-content`, `dialog-overlay`, `dialog-content`,+`alert-dialog-content`, `sheet-content`, `tabs-list`, `tabs-trigger`,+`card`, `kbd`, `separator`. Line icons are `svg.icon`.++### State on `<html>`++| Class or attribute | When |+| --- | --- |+| `.theme-light`, `.theme-dark` | The mode in use. (`.dark` is set too, in dark mode.) |+| `.is-desktop`, `.is-web` | The Desktop app or a browser. |+| `.mod-macos`, `.mod-windows`, `.mod-linux` | The operating system. |+| `.is-focused` | The window has focus. |+| `.is-sidebar-collapsed` | The navigation panel is collapsed. |+| `[data-theme="<id>"]` | The active theme. |+| `[data-theme-option-<id>]` | The theme's `toggle` and `select` options. |++```css+.mod-macos.is-desktop:not(.is-focused) [data-mc="app-rail"] { opacity: 0.7; }+.theme-dark [data-mc="issue-row"][data-priority="urgent"] { box-shadow: inset 2px 0 var(--priority-urgent); }+```++## Rules for theme CSS++Keep the CSS to variables, anchors, public slots and the state above:++- Use only public variables and anchors. Class names and DOM structure+ change without notice; a test fails when a theme sets a variable that is+ not public.+- Do not load anything: no `url()`, `@import` or `image-set()`. CSS can+ read page content through attribute selectors, so a request is a way out.+- Set variables on `.theme-light` and `.theme-dark`, and keep everything+ else behind a descendant selector, so the theme picker can read a+ theme's colours back from its CSS.+- Name font families only in `--font-ui` and `--font-content-latin`: no+ `sans-serif`, `serif` or other generic family, and no `ui-*` keyword. The+ CJK font follows them, and a generic family matches Han through the+ browser's default for the page language, so the person's CJK choice would+ never apply. The CJK stack ends with its own generic family.++## Variable reference++Generated from `packages/core/appearance/theme-variables.ts`. Where light+and dark differ, both defaults are given.++<!-- theme-variables:start (generated by packages/views/common/theme-variables.test.ts) -->++### Colours and surfaces++| Variable | Default (light / dark) | Use |+| --- | --- | --- |+| `--app-shell` | `oklch(0.964435 0.001327 286.375)` / `oklch(0.155 0.005 285.823)` | The frame around the page: rail, desktop toolbar and tab bar. |+| `--page-canvas` | `oklch(0.988087 0 0)` / `oklch(0.18 0.005 285.823)` | The page that lists, boards and conversations sit on. |+| `--surface` | `oklch(1 0 0)` / `oklch(0.21 0.006 285.885)` | Bounded content groups: cards, board cards, panels. |+| `--surface-foreground` | `oklch(0.141 0.005 285.823)` / `oklch(0.985 0 0)` | Text on a surface. |+| `--surface-raised` | `oklch(1 0 0)` / `oklch(0.235 0.007 285.885)` | Menus, popovers and dialogs. |+| `--surface-hover` | `oklch(0.967 0.001 286.375)` / `oklch(0.274 0.006 286.033)` | Row and card hover. |+| `--surface-selected` | `oklch(0.95 0.002 286.375)` / `oklch(0.3 0.006 286.033)` | Selected rows and the active nav item. |+| `--surface-selected-foreground` | `oklch(0.141 0.005 285.823)` / `oklch(0.985 0 0)` | Text on a selected row. |+| `--surface-border` | `oklch(0.92 0.004 286.32)` / `oklch(1 0 0 / 10%)` | Hairline around surfaces and the page. |+| `--background` | `var(--page-canvas)` | Shadcn alias; follows `page-canvas` unless set. |+| `--foreground` | `oklch(0.141 0.005 285.823)` / `oklch(0.985 0 0)` | Body text. |+| `--card` | `var(--surface)` | Shadcn alias; follows `surface` unless set. |+| `--card-foreground` | `oklch(0.141 0.005 285.823)` / `oklch(0.985 0 0)` | Text on a card. |+| `--popover` | `var(--surface-raised)` | Shadcn alias; follows `surface-raised` unless set. |+| `--popover-foreground` | `oklch(0.141 0.005 285.823)` / `oklch(0.985 0 0)` | Text in menus and popovers. |+| `--primary` | `oklch(0.21 0.006 285.885)` / `oklch(0.92 0.004 286.32)` | Primary buttons and strong marks; also used as text. |+| `--primary-foreground` | `oklch(0.985 0 0)` / `oklch(0.21 0.006 285.885)` | Text on primary. |+| `--secondary` | `oklch(0.967 0.001 286.375)` / `oklch(0.274 0.006 286.033)` | Secondary buttons. |+| `--secondary-foreground` | `oklch(0.21 0.006 285.885)` / `oklch(0.985 0 0)` | Text on secondary. |+| `--muted` | `oklch(0.967 0.001 286.375)` / `oklch(0.274 0.006 286.033)` | Quiet fills: group headers, code blocks, skeletons. |+| `--muted-foreground` | `oklch(0.505 0.016 285.938)` / `oklch(0.705 0.015 286.067)` | Secondary text. Must clear 4.5:1 on every surface. |+| `--faint-foreground` | `oklch(0.606 0.016 285.938)` / `oklch(0.60 0.015 286.067)` | Marks that are not text: chevrons, separators, empty-state icons. |+| `--accent` | `oklch(0.967 0.001 286.375)` / `oklch(0.274 0.006 286.033)` | Hover fill in menus and lists. |+| `--accent-foreground` | `oklch(0.21 0.006 285.885)` / `oklch(0.985 0 0)` | Text on accent. |+| `--border` | `oklch(0.945 0.003 286.32)` / `oklch(1 0 0 / 6%)` | Dividers and table borders. |+| `--input` | `oklch(0.92 0.004 286.32)` / `oklch(1 0 0 / 15%)` | Input borders. |+| `--ring` | `oklch(0.705 0.015 286.067)` / `oklch(0.552 0.016 285.938)` | Focus ring. |+| `--sidebar` | `oklch(0.964435 0.001327 286.375)` / `oklch(0.21 0.006 285.885)` | Sidebar background (shadcn sidebar). |+| `--sidebar-foreground` | `oklch(0.141 0.005 285.823)` / `oklch(0.985 0 0)` | Sidebar text. |+| `--sidebar-primary` | `oklch(0.21 0.006 285.885)` / `oklch(0.488 0.243 264.376)` | Sidebar primary marks. |+| `--sidebar-primary-foreground` | `oklch(0.985 0 0)` | Text on sidebar primary. |+| `--sidebar-accent` | `oklch(0.935 0.003 286.375)` / `oklch(0.274 0.006 286.033)` | Rail hover and active fill. |+| `--sidebar-accent-foreground` | `oklch(0.21 0.006 285.885)` / `oklch(0.985 0 0)` | Text on sidebar accent. |+| `--sidebar-border` | `oklch(0.92 0.004 286.32)` / `oklch(1 0 0 / 10%)` | Sidebar borders. |+| `--sidebar-ring` | `oklch(0.705 0.015 286.067)` / `oklch(0.552 0.016 285.938)` | Sidebar focus ring. |+| `--brand` | `oklch(0.56079497 0.19449888 256.41258418)` / `oklch(0.65 0.16 255)` | Product colour: links, checkboxes, selection highlights. |+| `--brand-foreground` | `oklch(0.985 0 0)` | Text on brand. |+| `--button-primary` | `--primary` | Primary button fill when it should differ from `primary`. |+| `--button-primary-foreground` | `--primary-foreground` | Primary button text. |+| `--button-primary-border` | `--button-primary` | Primary button border. |+| `--destructive` | `oklch(0.577 0.245 27.325)` / `oklch(0.704 0.191 22.216)` | Errors and destructive actions. |+| `--success` | `oklch(0.55 0.16 145)` / `oklch(0.65 0.15 145)` | Success states. |+| `--warning` | `oklch(0.75 0.16 85)` / `oklch(0.70 0.16 85)` | Warnings. |+| `--info` | `oklch(0.55 0.18 250)` / `oklch(0.65 0.18 250)` | Informational marks. |+| `--chart-1` | `oklch(0.55 0.16 255)` / `oklch(0.72 0.16 255)` | First chart series. |+| `--chart-2` | `oklch(0.66 0.13 255)` / `oklch(0.62 0.13 255)` | Second chart series. |+| `--chart-3` | `oklch(0.76 0.10 255)` / `oklch(0.52 0.10 255)` | Third chart series. |+| `--chart-4` | `oklch(0.85 0.06 255)` / `oklch(0.42 0.06 255)` | Fourth chart series. |+| `--chart-5` | `oklch(0.92 0.03 255)` / `oklch(0.32 0.03 255)` | Fifth chart series. |+| `--find-match` | `oklch(0.92 0.15 100)` / `oklch(0.82 0.16 100)` | In-page find match. |+| `--find-match-active` | `oklch(0.82 0.17 62)` / `oklch(0.76 0.18 60)` | The current find match. |+| `--find-match-foreground` | `oklch(0.22 0.03 92)` / `oklch(0.18 0.02 92)` | Text on a find match. |+| `--scrollbar-track` | `transparent` | Scrollbar track. |+| `--scrollbar-thumb` | `oklch(0 0 0 / 10%)` / `oklch(1 0 0 / 8%)` | Scrollbar thumb. |+| `--scrollbar-thumb-hover` | `oklch(0 0 0 / 18%)` / `oklch(1 0 0 / 18%)` | Scrollbar thumb on hover. |++### Status and priority++| Variable | Default (light / dark) | Use |+| --- | --- | --- |+| `--status-backlog` | `var(--muted-foreground)` | Backlog status icon. |+| `--status-todo` | `var(--muted-foreground)` | Todo status icon. |+| `--status-in-progress` | `var(--warning)` | In progress status icon. |+| `--status-in-review` | `var(--success)` | In review status icon. |+| `--status-done` | `var(--info)` | Done status icon. |+| `--status-blocked` | `var(--destructive)` | Blocked status icon. |+| `--status-cancelled` | `var(--muted-foreground)` | Cancelled status icon. |+| `--priority-urgent` | `var(--destructive)` | Urgent priority icon and badge. |+| `--priority-high` | `oklch(0.68 0.18 50)` / `oklch(0.72 0.17 50)` | High priority icon and badge. |+| `--priority-medium` | `var(--warning)` | Medium priority icon and badge. |+| `--priority-low` | `var(--info)` | Low priority icon and badge. |+| `--priority-none` | `var(--muted-foreground)` | No-priority icon. |++### Shape and depth++| Variable | Default (light / dark) | Use |+| --- | --- | --- |+| `--radius` | `0.5rem` | Base corner radius. Every `rounded-*` step and component radius below derives from it. |+| `--surface-shadow` | `0 1px 2px rgb(15 23 42 / 0.04), 0 1px 1px rgb(15 23 42 / 0.03)` / `0 1px 2px rgb(0 0 0 / 0.2), 0 1px 1px rgb(0 0 0 / 0.16)` | Resting shadow of cards and the page. |+| `--floating-shadow` | `0 16px 40px rgb(15 23 42 / 0.14), 0 3px 10px rgb(15 23 42 / 0.08)` / `0 20px 48px rgb(0 0 0 / 0.46), 0 4px 12px rgb(0 0 0 / 0.28)` | Dialogs and sheets. |+| `--menu-shadow` | `0 8px 24px rgb(15 23 42 / 0.08), 0 2px 6px rgb(15 23 42 / 0.05)` / `0 10px 28px rgb(0 0 0 / 0.3), 0 2px 8px rgb(0 0 0 / 0.18)` | Menus, selects and popovers. |+| `--tooltip` | `oklch(0.21 0.006 285.885)` / `oklch(0.3 0.006 286.033)` | Tooltip fill (dark in both modes). |+| `--tooltip-shadow` | `0 4px 12px rgb(15 23 42 / 0.16), 0 1px 3px rgb(15 23 42 / 0.12)` / `0 0 0 1px oklch(1 0 0 / 10%), 0 8px 24px rgb(0 0 0 / 0.4)` | Tooltip shadow. |+| `--icon-stroke-width` | `2` | Stroke width of line icons. |++### Typography++| Variable | Default (light / dark) | Use |+| --- | --- | --- |+| `--font-ui` | Inter, or the Appearance choice | Interface font. The Appearance page's choice wins over a theme's. |+| `--font-cjk` | system CJK sans, or the Appearance choice | Interface font for Chinese, Japanese and Korean. |+| `--font-content-latin` | `--font-ui` | Font for issue descriptions, comments, chat and documents. |+| `--font-content-cjk` | `--font-cjk` | CJK font for that content. |+| `--font-mono` | Geist Mono | Code font. |+| `--content-leading` | `1.625` | Line height of content paragraphs. |+| `--content-leading-cjk` | `1.75` | Line height of CJK content paragraphs. |+| `--text-micro` | `calc(11px * var(--font-scale, 1))` | Counters, badges, timestamps. |+| `--text-micro--line-height` | `calc(15px * var(--font-scale, 1))` | Line height of `text-micro`. |+| `--text-caption` | `calc(12px * var(--font-scale, 1))` | Chips, hints, tooltips, issue identifiers. |+| `--text-caption--line-height` | `calc(16px * var(--font-scale, 1))` | Line height of `text-caption`. |+| `--text-label` | `calc(13px * var(--font-scale, 1))` | Metadata rows, table headers, activity. |+| `--text-label--line-height` | `calc(18px * var(--font-scale, 1))` | Line height of `text-label`. |+| `--text-body` | `calc(14px * var(--font-scale, 1))` | Interface body text. |+| `--text-body--line-height` | `calc(20px * var(--font-scale, 1))` | Line height of `text-body`. |+| `--text-body-lg` | `calc(15px * var(--font-scale, 1))` | Dialog copy, onboarding prose. |+| `--text-body-lg--line-height` | `calc(22px * var(--font-scale, 1))` | Line height of `text-body-lg`. |+| `--text-title-sm` | `calc(16px * var(--font-scale, 1))` | Small headings. |+| `--text-title-sm--line-height` | `calc(24px * var(--font-scale, 1))` | Line height of `text-title-sm`. |+| `--text-title` | `calc(18px * var(--font-scale, 1))` | Section headings. |+| `--text-title--line-height` | `calc(28px * var(--font-scale, 1))` | Line height of `text-title`. |+| `--text-title-lg` | `calc(20px * var(--font-scale, 1))` | Card and dialog titles. |+| `--text-title-lg--line-height` | `calc(28px * var(--font-scale, 1))` | Line height of `text-title-lg`. |+| `--text-display-sm` | `calc(24px * var(--font-scale, 1))` | Page titles. |+| `--text-display-sm--line-height` | `calc(32px * var(--font-scale, 1))` | Line height of `text-display-sm`. |+| `--text-display` | `calc(36px * var(--font-scale, 1))` | Hero numbers and empty-state headlines. |+| `--text-display--line-height` | `calc(40px * var(--font-scale, 1))` | Line height of `text-display`. |++### Controls and overlays++| Variable | Default (light / dark) | Use |+| --- | --- | --- |+| `--button-radius` | `var(--radius)` | Button corners. |+| `--button-radius-sm` | `calc(var(--radius) * 0.75)` | Corners of extra-small and small buttons. |+| `--button-height-xs` | `1.5rem` | Extra-small button height. |+| `--button-height-sm` | `1.75rem` | Small button height. |+| `--button-height-default` | `2rem` | Default button height. |+| `--button-height-lg` | `2.25rem` | Large button height. |+| `--button-padding-xs` | `0.5rem` | Extra-small button side padding. |+| `--button-padding-sm` | `0.625rem` | Small button side padding. |+| `--button-padding-default` | `0.625rem` | Default button side padding. |+| `--button-padding-lg` | `0.625rem` | Large button side padding. |+| `--button-gap-xs` | `0.25rem` | Icon gap in extra-small buttons. |+| `--button-gap-sm` | `0.25rem` | Icon gap in small buttons. |+| `--button-gap-default` | `0.375rem` | Icon gap in default buttons. |+| `--button-gap-lg` | `0.375rem` | Icon gap in large buttons. |+| `--input-radius` | `var(--radius)` | Inputs, textareas and select triggers. |+| `--card-radius` | `calc(var(--radius) * 1.5)` | Cards. |+| `--menu-radius` | `calc(var(--radius) * 1.5)` | Dropdown, context and select menus. |+| `--menu-item-radius` | `calc(var(--radius) * 0.75)` | Items inside a menu. |+| `--menu-item-hover-background` | `var(--accent)` | Highlighted menu item. |+| `--menu-item-hover-color` | `var(--accent-foreground)` | Text of the highlighted menu item. |+| `--popover-radius` | `var(--radius)` | Popovers. |+| `--dialog-radius` | `calc(var(--radius) * 1.5)` | Dialogs and alert dialogs. |+| `--tooltip-radius` | `var(--radius)` | Tooltips. |+| `--avatar-radius` | `calc(infinity * 1px)` | Avatars. Set a length for square avatars. |+| `--label-radius` | `calc(infinity * 1px)` | Issue label chips. |++### Navigation and page++| Variable | Default (light / dark) | Use |+| --- | --- | --- |+| `--page-radius` | `calc(var(--radius) * 1.5)` | Corners of the page card inside the frame. |+| `--page-border-color` | `var(--surface-border)` | Hairline around the page card. |+| `--page-shadow` | `var(--surface-shadow)` | Shadow of the page card. |+| `--rail-item-radius` | `calc(var(--radius) * 1.5)` | Space buttons in the rail. |+| `--rail-item-color` | `var(--muted-foreground)` | Rail button icon and label. |+| `--rail-item-hover-background` | `color-mix(in oklab, var(--sidebar-accent) 60%, transparent)` | Rail button hover. |+| `--rail-item-active-background` | `var(--sidebar-accent)` | The current space. |+| `--rail-item-active-color` | `var(--sidebar-accent-foreground)` | Icon and label of the current space. |+| `--nav-item-height` | `2rem` | Minimum height of a row in the space panel. |+| `--nav-item-radius` | `var(--radius)` | Rows in the space panel. |+| `--nav-item-color` | `var(--muted-foreground)` | Row text. |+| `--nav-item-hover-background` | `var(--surface-hover)` | Row hover. |+| `--nav-item-hover-color` | `var(--foreground)` | Row text on hover. |+| `--nav-item-active-background` | `var(--surface-selected)` | The current row. |+| `--nav-item-active-color` | `var(--surface-selected-foreground)` | Text of the current row. |++### Issues++| Variable | Default (light / dark) | Use |+| --- | --- | --- |+| `--issue-row-height` | `36px` | Height of a row in the issue list. |+| `--issue-row-padding-x` | `1rem` | Side padding of an issue row. |+| `--issue-row-hover-background` | `var(--surface-hover)` | Issue row hover. |+| `--issue-row-selected-background` | `var(--surface-selected)` | Selected issue row. |+| `--issue-row-identifier-color` | `var(--muted-foreground)` | Issue identifier (MUL-123) in a row. |+| `--issue-group-header-height` | `2.5rem` | Status group header in the list. |+| `--issue-group-header-radius` | `var(--radius)` | Corners of a group header. |+| `--issue-group-header-background` | `var(--muted)` | Group header fill. |+| `--issue-group-header-hover-background` | `var(--accent)` | Group header hover. |+| `--board-column-radius` | `calc(var(--radius) * 1.5)` | Board columns. |+| `--board-column-background` | `color-mix(in oklab, var(--muted) 40%, transparent)` | Board column fill. |+| `--board-card-radius` | `var(--radius)` | Board cards. |+| `--board-card-background` | `var(--surface)` | Board card fill. |+| `--board-card-hover-background` | `var(--surface-hover)` | Board card hover. |+| `--board-card-border-color` | `var(--surface-border)` | Board card border. |+| `--board-card-shadow` | `var(--surface-shadow)` | Board card shadow. |++### Editor content++| Variable | Default (light / dark) | Use |+| --- | --- | --- |+| `--h1-font` | `var(--font-content)` | Font of level 1 headings. |+| `--h1-size` | `var(--text-display-sm)` | Size of level 1 headings. |+| `--h1-weight` | `600` | Weight of level 1 headings. |+| `--h1-style` | `normal` | `italic` for italic level 1 headings. |+| `--h1-variant` | `normal` | `small-caps` and other font variants. |+| `--h1-letter-spacing` | `normal` | Tracking of level 1 headings. |+| `--h1-line-height` | `1.3` | Line height of level 1 headings. |+| `--h1-color` | `currentColor` | Colour of level 1 headings. |+| `--h2-font` | `var(--font-content)` | Font of level 2 headings. |+| `--h2-size` | `var(--text-title)` | Size of level 2 headings. |+| `--h2-weight` | `600` | Weight of level 2 headings. |+| `--h2-style` | `normal` | `italic` for italic level 2 headings. |+| `--h2-variant` | `normal` | `small-caps` and other font variants. |+| `--h2-letter-spacing` | `normal` | Tracking of level 2 headings. |+| `--h2-line-height` | `1.35` | Line height of level 2 headings. |+| `--h2-color` | `currentColor` | Colour of level 2 headings. |+| `--h3-font` | `var(--font-content)` | Font of level 3 headings. |+| `--h3-size` | `var(--text-body-lg)` | Size of level 3 headings. |+| `--h3-weight` | `600` | Weight of level 3 headings. |+| `--h3-style` | `normal` | `italic` for italic level 3 headings. |+| `--h3-variant` | `normal` | `small-caps` and other font variants. |+| `--h3-letter-spacing` | `normal` | Tracking of level 3 headings. |+| `--h3-line-height` | `1.4` | Line height of level 3 headings. |+| `--h3-color` | `currentColor` | Colour of level 3 headings. |+| `--h4-font` | `var(--font-content)` | Font of level 4 headings. |+| `--h4-size` | `var(--text-body)` | Size of level 4 headings. |+| `--h4-weight` | `600` | Weight of level 4 headings. |+| `--h4-style` | `normal` | `italic` for italic level 4 headings. |+| `--h4-variant` | `normal` | `small-caps` and other font variants. |+| `--h4-letter-spacing` | `normal` | Tracking of level 4 headings. |+| `--h4-line-height` | `1.45` | Line height of level 4 headings. |+| `--h4-color` | `currentColor` | Colour of level 4 headings. |+| `--h5-font` | `var(--font-content)` | Font of level 5 headings. |+| `--h5-size` | `var(--text-label)` | Size of level 5 headings. |+| `--h5-weight` | `600` | Weight of level 5 headings. |+| `--h5-style` | `normal` | `italic` for italic level 5 headings. |+| `--h5-variant` | `normal` | `small-caps` and other font variants. |+| `--h5-letter-spacing` | `normal` | Tracking of level 5 headings. |+| `--h5-line-height` | `1.5` | Line height of level 5 headings. |+| `--h5-color` | `currentColor` | Colour of level 5 headings. |+| `--h6-font` | `var(--font-content)` | Font of level 6 headings. |+| `--h6-size` | `var(--text-caption)` | Size of level 6 headings. |+| `--h6-weight` | `600` | Weight of level 6 headings. |+| `--h6-style` | `normal` | `italic` for italic level 6 headings. |+| `--h6-variant` | `normal` | `small-caps` and other font variants. |+| `--h6-letter-spacing` | `normal` | Tracking of level 6 headings. |+| `--h6-line-height` | `1.5` | Line height of level 6 headings. |+| `--h6-color` | `var(--muted-foreground)` | Colour of level 6 headings. |+| `--paragraph-spacing` | `0.625rem` | Space above and below paragraphs. |+| `--list-indent` | `1.25rem` | Indent of bulleted lists. |+| `--list-indent-ordered` | `1.5rem` | Indent of numbered lists. |+| `--list-item-spacing` | `0.25rem` | Space between list items. |+| `--list-marker-color` | `var(--muted-foreground)` | Bullets and numbers. |+| `--checkbox-size` | `0.95rem` | Task list checkboxes. |+| `--checkbox-color` | `var(--brand)` | Checked checkbox fill. |+| `--checklist-done-color` | `var(--muted-foreground)` | Text of a completed task. |+| `--link-color` | `var(--brand)` | Links in content. |+| `--link-decoration` | `underline` | `underline` or `none`. |+| `--link-decoration-color` | `color-mix(in srgb, var(--brand) 40%, transparent)` | Link underline. |+| `--link-decoration-color-hover` | `var(--brand)` | Link underline on hover. |+| `--link-underline-offset` | `2px` | Gap between text and underline. |+| `--mention-color` | `var(--primary)` | @mentions. |+| `--mention-weight` | `600` | Weight of @mentions. |+| `--bold-weight` | `600` | Bold text. |+| `--bold-color` | `currentColor` | Colour of bold text. |+| `--italic-color` | `currentColor` | Colour of italic text. |+| `--strikethrough-color` | `var(--muted-foreground)` | Colour of struck-through text. |+| `--highlight-background` | `color-mix(in srgb, #facc15 45%, transparent)` | `==highlighted==` text. |+| `--highlight-radius` | `0.2em` | Corners of highlighted text. |+| `--blockquote-border-width` | `3px` | Quote bar width. |+| `--blockquote-border-color` | `color-mix(in srgb, var(--muted-foreground) 30%, transparent)` | Quote bar colour. |+| `--blockquote-padding` | `0.75rem` | Space between the bar and the text. |+| `--blockquote-color` | `var(--muted-foreground)` | Quote text. |+| `--blockquote-background` | `transparent` | Quote fill. |+| `--blockquote-style` | `italic` | `italic` or `normal`. |+| `--hr-color` | `var(--border)` | Horizontal rules. |+| `--hr-thickness` | `1px` | Horizontal rule thickness. |+| `--table-border-width` | `1px` | Table borders. |+| `--table-border-color` | `var(--border)` | Table border colour. |+| `--table-radius` | `var(--radius)` | Table corners. |+| `--table-header-background` | `color-mix(in srgb, var(--muted) 50%, transparent)` | Header row fill. |+| `--table-header-color` | `var(--muted-foreground)` | Header text. |+| `--table-header-weight` | `500` | Header weight. |+| `--table-row-hover-background` | `color-mix(in srgb, var(--muted) 30%, transparent)` | Row hover. |+| `--table-cell-padding` | `0.5rem 0.75rem` | Cell padding. |++### Code++| Variable | Default (light / dark) | Use |+| --- | --- | --- |+| `--code-font-size` | `var(--text-body)` | Inline code size. |+| `--code-background` | `color-mix(in srgb, var(--foreground) 3%, transparent)` | Inline code fill. |+| `--code-border-color` | `color-mix(in srgb, var(--foreground) 5%, transparent)` | Inline code border. |+| `--code-color` | `color-mix(in srgb, var(--foreground) 75%, transparent)` | Inline code text. |+| `--code-padding` | `0.125rem 0.375rem` | Inline code padding. |+| `--code-radius` | `var(--radius-sm)` | Inline code corners. |+| `--code-block-background` | `var(--muted)` | Code block fill. |+| `--code-block-border` | `none` | Code block border, e.g. `1px solid var(--border)`. |+| `--code-block-radius` | `var(--radius)` | Code block corners. |+| `--code-block-padding` | `0.75rem 1rem` | Code block padding. |+| `--code-block-color` | `var(--foreground)` | Code block text. |+| `--code-block-font-size` | `var(--text-label)` | Code block size. |+| `--code-block-line-height` | `1.6` | Code block line height. |+| `--code-keyword` | `oklch(0.55 0.16 255)` / `oklch(0.7 0.14 255)` | Keywords and built-ins. |+| `--code-string` | `oklch(0.55 0.14 155)` / `oklch(0.7 0.14 155)` | Strings and added lines. |+| `--code-comment` | `var(--muted-foreground)` | Comments. |+| `--code-number` | `oklch(0.58 0.16 30)` / `oklch(0.72 0.14 30)` | Numbers and literals. |+| `--code-function` | `oklch(0.55 0.14 280)` / `oklch(0.72 0.12 280)` | Function and section names. |+| `--code-property` | `oklch(0.58 0.12 60)` / `oklch(0.72 0.1 60)` | Attributes and properties. |+| `--code-variable` | `oklch(0.58 0.14 20)` / `oklch(0.72 0.12 20)` | Variables. |+| `--code-type` | `oklch(0.55 0.14 200)` / `oklch(0.72 0.12 200)` | Types and classes. |+| `--code-deletion` | `oklch(0.55 0.2 25)` / `oklch(0.7 0.18 25)` | Removed lines. |+| `--code-tag` | `oklch(0.55 0.16 255)` / `oklch(0.72 0.14 255)` | HTML and XML element names. |+| `--code-punctuation` | `var(--muted-foreground)` | HTML and XML brackets. |++<!-- theme-variables:end -->diff --git a/packages/core/appearance/anchors.ts b/packages/core/appearance/anchors.tsnew file mode 100644index 0000000000..74a8fac756--- /dev/null+++ b/packages/core/appearance/anchors.ts@@ -0,0 +1,64 @@+/**+ * Selectors a theme's CSS may rely on. Class names and DOM structure are not+ * part of this list and change without notice.+ *+ * `data-mc` marks product surfaces. Removing or renaming one breaks themes:+ * keep it until the next THEME_API_VERSION. A test checks that every name+ * here is still rendered somewhere and that no unlisted `data-mc` appears.+ */+export const THEME_ANCHORS = {+ "app-rail": "The icon rail on the far left.",+ sidebar: "The navigation panel next to the rail; `data-state` is expanded or collapsed.",+ "nav-item": "A row in the sidebar; `data-active` is true on the current one.",+ page: "The rounded canvas that holds the current page.",+ "window-toolbar": "Desktop only: the toolbar above the rail with history buttons.",+ "tab-bar": "Desktop only: the tab strip above the page.",+ "issue-group-header": "A status group header in issue lists; `data-status` is the status key.",+ "issue-row":+ "One issue in a list; `data-status`, `data-priority` and `data-assignee-type` (member, agent, squad or none).",+ "board-column": "One column on a board.",+ "board-card": "One issue card on a board; same attributes as `issue-row`.",+ "status-icon": "The status glyph (an svg).",+ "priority-icon": "The priority glyph (an svg).",+ "label-chip": "A label; `data-color` is its hex colour.",+ content:+ "Rich text: issue descriptions, comments, chat messages and documents, in both reading and editing; `data-density` is document or compact when reading.",+ comment: "A top-level comment card in an issue timeline; `data-author-type` is member, agent or system.",+ "comment-reply": "A reply inside a comment card; `data-author-type` as on `comment`.",+ "comment-composer": "The box for writing a new comment.",+ "chat-window": "The chat panel.",+ "chat-input": "The message box in chat.",+ "chat-message": "One message in a chat; `data-role` is user or assistant.",+ "inbox-item": "One notification in the inbox list; `data-read` is true or false.",+ "settings-page": "The settings page.",+} as const;++export type ThemeAnchor = keyof typeof THEME_ANCHORS;++/**+ * `data-slot` values of UI primitives that are public too. Buttons also carry+ * `data-variant` and `data-size`.+ */+export const THEME_PUBLIC_SLOTS = [+ "button",+ "input",+ "textarea",+ "switch",+ "checkbox",+ "select-trigger",+ "select-content",+ "select-item",+ "dropdown-menu-content",+ "dropdown-menu-item",+ "popover-content",+ "tooltip-content",+ "dialog-overlay",+ "dialog-content",+ "alert-dialog-content",+ "sheet-content",+ "tabs-list",+ "tabs-trigger",+ "card",+ "kbd",+ "separator",+] as const;diff --git a/packages/core/appearance/built-in-themes.ts b/packages/core/appearance/built-in-themes.tsnew file mode 100644index 0000000000..8873ca0a41--- /dev/null+++ b/packages/core/appearance/built-in-themes.ts@@ -0,0 +1,938 @@+import { THEME_API_VERSION, themeTokensCss, type BuiltInTheme, type ThemeTokens } from "./themes";++/**+ * The themes Multica ships. Each is a token table (read by the contrast test+ * in apps/web) plus CSS for what variables can't express, compiled to the same+ * CSS an installed theme ships.+ */++function builtInTheme(theme: Omit<BuiltInTheme, "apiVersion" | "css"> & { css?: string }): BuiltInTheme {+ return {+ ...theme,+ apiVersion: THEME_API_VERSION,+ css: [themeTokensCss(theme), theme.css].filter(Boolean).join("\n\n"),+ };+}++export const DEFAULT_THEME_ID = "default";++const INK = "oklch(0.145 0 0)";+const POP_YELLOW = "oklch(0.9 0.17 98)";++/** Pop's frame is black in both modes, so what sits on it reads light tokens. */+const POP_FRAME: ThemeTokens = {+ foreground: "oklch(0.97 0 0)",+ "muted-foreground": "oklch(0.8 0 0)",+ "faint-foreground": "oklch(0.64 0 0)",+ background: INK,+ "page-canvas": "oklch(0.25 0 0)",+ surface: "oklch(0.2 0 0)",+ "surface-raised": "oklch(0.25 0 0)",+ "surface-hover": "oklch(0.3 0 0)",+ "surface-selected": "oklch(0.32 0.05 98)",+ muted: "oklch(0.27 0 0)",+ "sidebar-accent": "oklch(0.27 0 0)",+ "sidebar-accent-foreground": POP_YELLOW,+ "surface-border": "oklch(0.4 0 0)",+ "surface-shadow": "none",+ ring: POP_YELLOW,+};++const POP_SIGNALS = {+ yellow: POP_YELLOW,+ mint: "oklch(0.87 0.12 165)",+ sky: "oklch(0.83 0.1 230)",+ coral: "oklch(0.8 0.13 30)",+};++const POP_FRAME_ANCHORS = ':is([data-mc="app-rail"], [data-mc="window-toolbar"], [data-mc="tab-bar"])';+const POP_STATUS_BLOCKS: [string, string][] = [+ ['[data-status="backlog"], [data-status="todo"]', "oklch(0.88 0.035 250)"],+ ['[data-status="in_progress"]', "oklch(0.84 0.13 68)"],+ ['[data-status="in_review"]', "oklch(0.86 0.1 165)"],+ ['[data-status="done"]', "oklch(0.8 0.09 255)"],+ ['[data-status="blocked"]', "oklch(0.78 0.13 28)"],+];+const POP_SIGNAL_ON = ':root[data-theme-option-signal]:not([data-theme-option-signal="yellow"])';+const POP_BUTTON = '[data-slot="button"][data-variant="default"]:not(:disabled):hover';+const POP_GROUP = '[data-mc="issue-group-header"]';+const POP_BLOCKED_STATUSES = POP_STATUS_BLOCKS.map(([status]) => status).join(", ");++/** Pop's signal colour, whichever one is picked. */+const POP_SIGNAL = `var(--pop-signal, ${POP_YELLOW})`;++/** Shape and content treatments Pop uses in both modes. */+const POP_SHARED: ThemeTokens = {+ radius: "0.25rem",+ "menu-radius": "0.25rem",+ "popover-radius": "0.25rem",+ "dialog-radius": "0.25rem",+ "card-radius": "0.25rem",+ "page-radius": "0.375rem",+ "menu-item-radius": "0.125rem",+ "menu-item-hover-background": "var(--surface-selected)",+ "menu-item-hover-color": "var(--foreground)",+ "label-radius": "0.25rem",+ "board-column-radius": "0.25rem",+ "board-card-radius": "0.25rem",+ "h1-weight": "800",+ "h2-weight": "800",+ "h3-weight": "700",+ "h1-letter-spacing": "-0.02em",+ "h2-letter-spacing": "-0.015em",+ "bold-weight": "700",+ "mention-color": "var(--foreground)",+ "mention-weight": "700",+ "link-color": "var(--foreground)",+ "link-decoration-color": POP_SIGNAL,+ "link-decoration-color-hover": "var(--foreground)",+ "link-underline-offset": "3px",+ "highlight-radius": "0",+ "checkbox-color": "var(--foreground)",+ "blockquote-border-width": "4px",+ "blockquote-border-color": "var(--surface-border)",+ "blockquote-style": "normal",+ "blockquote-color": "var(--foreground)",+ "code-background": "var(--surface-selected)",+ "code-border-color": "var(--surface-border)",+ "code-color": "var(--foreground)",+ "code-radius": "0.125rem",+ "code-block-background": "var(--surface)",+ "code-block-border": "1px solid var(--surface-border)",+ "code-block-radius": "0.25rem",+ "table-radius": "0.25rem",+ "table-border-color": "var(--surface-border)",+ "table-header-background": "var(--muted)",+ "table-header-color": "var(--foreground)",+ "table-header-weight": "700",+ "hr-color": "var(--surface-border)",+ "hr-thickness": "2px",+};++/** Pop's component treatments, each behind one of its options. */+const POP_CSS = [+ "/* Signal colour: button fill, selection, focus ring and dark floating shadows. */",+ ...Object.entries(POP_SIGNALS)+ .filter(([id]) => id !== "yellow")+ .map(([id, color]) => `:root[data-theme-option-signal="${id}"] { --pop-signal: ${color}; }`),+ `${POP_SIGNAL_ON} { --button-primary: var(--pop-signal); --surface-selected: color-mix(in oklab, var(--pop-signal) 35%, oklch(1 0 0)); }`,+ `${POP_SIGNAL_ON}.theme-dark { --ring: var(--pop-signal); --floating-shadow: 6px 6px 0 var(--pop-signal); --menu-shadow: 4px 4px 0 var(--pop-signal); --surface-selected: color-mix(in oklab, var(--pop-signal) 22%, oklch(0.2 0 0)); }`,+ `${POP_SIGNAL_ON} ${POP_FRAME_ANCHORS} { --sidebar-accent-foreground: var(--pop-signal); --ring: var(--pop-signal); --surface-selected: color-mix(in oklab, var(--pop-signal) 22%, oklch(0.2 0 0)); }`,+ "",+ "/* Primary buttons lift onto a hard shadow on hover instead of darkening. */",+ `:root[data-theme-option-offset-shadow] ${POP_BUTTON} { background-color: var(--button-primary, var(--primary)); translate: -2px -2px; box-shadow: 3px 3px 0 var(--surface-border); }`,+ `@media (prefers-reduced-motion: reduce) { :root[data-theme-option-offset-shadow] ${POP_BUTTON} { translate: none; } }`,+ "",+ "/* Issue group headers become solid blocks per status; custom statuses stay neutral. */",+ `:root[data-theme-option-status-blocks] ${POP_GROUP} { box-shadow: inset 0 0 0 1px var(--surface-border); }`,+ `:root[data-theme-option-status-blocks] ${POP_GROUP}:is(${POP_BLOCKED_STATUSES}) { --foreground: ${INK}; --muted-foreground: oklch(0.3 0 0); color: var(--foreground); }`,+ `:root[data-theme-option-status-blocks] ${POP_GROUP}:is(${POP_BLOCKED_STATUSES}) svg { color: var(--foreground); }`,+ ...POP_STATUS_BLOCKS.map(+ ([status, color]) =>+ `:root[data-theme-option-status-blocks] ${POP_GROUP}:is(${status}) { background-color: ${color}; }`,+ ),+ "",+ "/* Label chips get an ink outline. */",+ `:root[data-theme-option-outlined-chips] [data-mc="label-chip"] { box-shadow: inset 0 0 0 1px var(--surface-border); }`,+ "",+ "/* Code blocks sit on the same hard shadow as cards. */",+ `:root[data-theme-option-offset-shadow] [data-mc="content"] pre { box-shadow: 3px 3px 0 var(--surface-border); }`,+ "",+ "/* Thick signal underlines, and an ink outline on the current sidebar item. */",+ '[data-mc="content"] a { text-decoration-thickness: 3px; }',+ '[data-mc="nav-item"][data-active="true"] { box-shadow: inset 0 0 0 1px var(--surface-border); }',+].join("\n");++/**+ * Pop: black frame, warm paper canvas, ink outlines, small radius, hard+ * offset shadows and a signal-colour primary. --primary stays ink because it+ * also paints text (`text-primary`); the signal colour reaches buttons+ * through --button-primary.+ */+const POP = builtInTheme({+ id: "pop",+ name: "Pop",+ tokens: {+ light: {+ ...POP_SHARED,+ "highlight-background": POP_SIGNAL,+ "app-shell": INK,+ "page-canvas": "oklch(0.974 0.008 95)",+ surface: "oklch(1 0 0)",+ "surface-raised": "oklch(1 0 0)",+ "surface-hover": "oklch(0.945 0.014 95)",+ "surface-selected": "oklch(0.93 0.08 98)",+ "surface-border": INK,+ "surface-shadow": `2px 2px 0 ${INK}`,+ "floating-shadow": `6px 6px 0 ${INK}`,+ "menu-shadow": `4px 4px 0 ${INK}`,+ secondary: "oklch(0.945 0.014 95)",+ muted: "oklch(0.945 0.014 95)",+ accent: "oklch(0.945 0.014 95)",+ "muted-foreground": "oklch(0.44 0.012 95)",+ "faint-foreground": "oklch(0.56 0.012 95)",+ border: INK,+ input: INK,+ ring: INK,+ sidebar: "oklch(0.945 0.014 95)",+ "sidebar-accent": "oklch(0.91 0.02 95)",+ "sidebar-border": INK,+ brand: "oklch(0.5 0.2 262)",+ "button-primary": POP_YELLOW,+ "button-primary-foreground": INK,+ "button-primary-border": INK,+ },+ dark: {+ ...POP_SHARED,+ "highlight-background": `color-mix(in oklab, ${POP_SIGNAL} 35%, transparent)`,+ "app-shell": "oklch(0 0 0)",+ "page-canvas": "oklch(0.17 0 0)",+ surface: "oklch(0.2 0 0)",+ "surface-raised": "oklch(0.22 0 0)",+ "surface-hover": "oklch(0.26 0 0)",+ "surface-selected": "oklch(0.32 0.06 98)",+ "surface-border": "oklch(0.92 0 0)",+ "surface-shadow": `2px 2px 0 oklch(0.92 0 0)`,+ "floating-shadow": `6px 6px 0 ${POP_YELLOW}`,+ "menu-shadow": `4px 4px 0 ${POP_YELLOW}`,+ secondary: "oklch(0.26 0 0)",+ muted: "oklch(0.26 0 0)",+ accent: "oklch(0.26 0 0)",+ "muted-foreground": "oklch(0.8 0 0)",+ "faint-foreground": "oklch(0.62 0 0)",+ border: "oklch(0.92 0 0)",+ input: "oklch(0.92 0 0)",+ ring: POP_YELLOW,+ sidebar: "oklch(0.2 0 0)",+ "sidebar-accent": "oklch(0.26 0 0)",+ "sidebar-border": "oklch(0.92 0 0)",+ brand: "oklch(0.72 0.15 262)",+ "button-primary": POP_YELLOW,+ "button-primary-foreground": INK,+ "button-primary-border": "oklch(0.92 0 0)",+ },+ },+ frame: { light: POP_FRAME, dark: POP_FRAME },+ options: [+ {+ id: "signal",+ type: "select",+ label: {+ en: "Signal color",+ "zh-Hans": "信号色",+ "zh-Hant": "信號色",+ ja: "シグナルカラー",+ ko: "시그널 색상",+ es: "Color de señal",+ fr: "Couleur signal",+ ru: "Сигнальный цвет",+ },+ description: {+ en: "Primary buttons, selection and focus.",+ "zh-Hans": "主按钮、选中项和焦点。",+ "zh-Hant": "主按鈕、選取項目和焦點。",+ ja: "主要ボタン、選択項目、フォーカス。",+ ko: "기본 버튼, 선택 항목, 포커스.",+ es: "Botones principales, selección y foco.",+ fr: "Boutons principaux, sélection et focus.",+ ru: "Основные кнопки, выделение и фокус.",+ },+ default: "yellow",+ choices: [+ { value: "yellow", label: { en: "Yellow", "zh-Hans": "黄", "zh-Hant": "黃", ja: "イエロー", ko: "노랑", es: "Amarillo", fr: "Jaune", ru: "Жёлтый" }, swatch: POP_SIGNALS.yellow },+ { value: "mint", label: { en: "Mint", "zh-Hans": "薄荷", "zh-Hant": "薄荷", ja: "ミント", ko: "민트", es: "Menta", fr: "Menthe", ru: "Мятный" }, swatch: POP_SIGNALS.mint },+ { value: "sky", label: { en: "Sky", "zh-Hans": "天蓝", "zh-Hant": "天藍", ja: "スカイ", ko: "하늘", es: "Cielo", fr: "Ciel", ru: "Небесный" }, swatch: POP_SIGNALS.sky },+ { value: "coral", label: { en: "Coral", "zh-Hans": "珊瑚", "zh-Hant": "珊瑚", ja: "コーラル", ko: "코랄", es: "Coral", fr: "Corail", ru: "Коралловый" }, swatch: POP_SIGNALS.coral },+ ],+ },+ {+ id: "offset-shadow",+ type: "toggle",+ label: { en: "Hard shadows", "zh-Hans": "硬投影", "zh-Hant": "硬投影", ja: "ハードシャドウ", ko: "하드 섀도", es: "Sombras duras", fr: "Ombres franches", ru: "Жёсткие тени" },+ description: {+ en: "Primary buttons lift onto a solid offset shadow on hover.",+ "zh-Hans": "悬停时主按钮浮起,露出实色投影。",+ "zh-Hant": "滑過時主按鈕浮起,露出實色投影。",+ ja: "ホバー時に主要ボタンが浮き、ベタの影が出ます。",+ ko: "마우스를 올리면 기본 버튼이 떠오르며 단색 그림자가 생깁니다.",+ es: "Los botones principales se elevan sobre una sombra sólida al pasar el cursor.",+ fr: "Les boutons principaux se soulèvent sur une ombre pleine au survol.",+ ru: "При наведении основные кнопки приподнимаются над сплошной тенью.",+ },+ default: true,+ },+ {+ id: "status-blocks",+ type: "toggle",+ label: { en: "Status blocks", "zh-Hans": "状态色块", "zh-Hant": "狀態色塊", ja: "ステータスブロック", ko: "상태 블록", es: "Bloques de estado", fr: "Blocs de statut", ru: "Блоки статусов" },+ description: {+ en: "Group headers in issue lists fill with their status color.",+ "zh-Hans": "列表按状态分组时,分组标题整块填色。",+ "zh-Hant": "列表依狀態分組時,分組標題整塊填色。",+ ja: "課題リストのグループ見出しをステータス色で塗ります。",+ ko: "이슈 목록의 그룹 제목을 상태 색으로 채웁니다.",+ es: "Los encabezados de grupo se rellenan con el color de su estado.",+ fr: "Les en-têtes de groupe prennent la couleur de leur statut.",+ ru: "Заголовки групп окрашиваются в цвет своего статуса.",+ },+ default: true,+ },+ {+ id: "outlined-chips",+ type: "toggle",+ label: { en: "Outlined labels", "zh-Hans": "标签描边", "zh-Hant": "標籤描邊", ja: "ラベルの枠線", ko: "라벨 테두리", es: "Etiquetas con contorno", fr: "Étiquettes contourées", ru: "Метки с обводкой" },+ description: {+ en: "Label chips get an ink outline.",+ "zh-Hans": "标签加一圈墨线。",+ "zh-Hant": "標籤加一圈墨線。",+ ja: "ラベルに墨色の枠線を付けます。",+ ko: "라벨에 먹색 테두리를 둘러요.",+ es: "Las etiquetas llevan un contorno de tinta.",+ fr: "Les étiquettes reçoivent un contour encre.",+ ru: "Метки получают чернильную обводку.",+ },+ default: true,+ },+ ],+ css: POP_CSS,+});++/** Primer's font stacks, shared by GitHub. */+/**+ * Latin stacks name families only. A generic family (`sans-serif`, `serif`)+ * matches Han through the browser's per-language default, so the CJK stack+ * after it, which carries the person's CJK choice and its own generic, would+ * never apply.+ */+const SYSTEM_SANS = "-apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial";+const SYSTEM_MONO = "ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace";++/** Shape and content treatments GitHub uses in both modes. */+const GITHUB_SHARED: ThemeTokens = {+ "font-ui": SYSTEM_SANS,+ "font-mono": SYSTEM_MONO,+ radius: "0.375rem",+ "icon-stroke-width": "1.75",+ "menu-radius": "0.75rem",+ "popover-radius": "0.75rem",+ "dialog-radius": "0.75rem",+ "menu-item-radius": "0.375rem",+ "card-radius": "0.375rem",+ "page-radius": "0.375rem",+ "nav-item-radius": "0.375rem",+ "nav-item-color": "var(--foreground)",+ "nav-item-active-color": "var(--foreground)",+ "menu-item-hover-color": "var(--foreground)",+ "issue-group-header-radius": "0.375rem",+ "board-column-radius": "0.375rem",+ "board-card-radius": "0.375rem",+ "board-card-shadow": "none",+ "h1-size": "2em",+ "h2-size": "1.5em",+ "h3-size": "1.25em",+ "h1-line-height": "1.25",+ "h2-line-height": "1.25",+ "blockquote-border-width": "0.25em",+ "blockquote-padding": "1em",+ "blockquote-style": "normal",+ "code-font-size": "85%",+ "code-padding": "0.2em 0.4em",+ "code-radius": "0.375rem",+ "code-border-color": "transparent",+ "code-color": "var(--foreground)",+ "code-block-radius": "0.375rem",+ "code-block-padding": "1rem",+ "code-block-font-size": "85%",+ "code-block-line-height": "1.45",+ "table-radius": "0",+ "table-header-background": "transparent",+ "table-header-color": "var(--foreground)",+ "table-header-weight": "600",+ "table-cell-padding": "0.375rem 0.8125rem",+ "link-decoration-color": "transparent",+ "link-decoration-color-hover": "currentColor",+ "hr-thickness": "0.25em",+ "mention-color": "var(--foreground)",+};++/** GitHub's content CSS: ruled h1/h2, striped tables, and NavList's current-item bar. */+const GITHUB_CSS = [+ '[data-mc="content"] :is(h1, h2) { padding-bottom: 0.3em; border-bottom: 1px solid var(--border); }',+ '[data-mc="content"] tr:nth-child(2n) { background-color: var(--muted); }',+ '[data-mc="nav-item"][data-active="true"] { position: relative; font-weight: 600; }',+ '[data-mc="nav-item"][data-active="true"]::before { content: ""; position: absolute; left: -0.5rem; top: calc(50% - 0.75rem); width: 0.25rem; height: 1.5rem; border-radius: 0.375rem; background-color: var(--brand); }',+].join("\n");++/**+ * GitHub (Primer): system type, cool greys, green primary, blue links, the+ * Primer status colours (open green, done purple) and markdown-body content.+ */+const GITHUB = builtInTheme({+ id: "github",+ name: "GitHub",+ author: "Primer",+ tokens: {+ light: {+ ...GITHUB_SHARED,+ "app-shell": "oklch(0.978 0.003 247.9)",+ "page-canvas": "oklch(1 0 0)",+ surface: "oklch(1 0 0)",+ "surface-raised": "oklch(1 0 0)",+ "surface-hover": "oklch(0.96 0.005 247.9)",+ "surface-selected": "oklch(0.948 0.005 247.9)",+ "surface-border": "oklch(0.881 0.013 244.3)",+ "surface-shadow": "0 1px 0 rgb(31 35 40 / 0.04)",+ "menu-shadow": "0 0 0 1px rgb(209 217 224 / 0.5), 0 6px 12px -3px rgb(37 41 46 / 0.04), 0 6px 18px 0 rgb(37 41 46 / 0.12)",+ "floating-shadow": "0 0 0 1px rgb(209 217 224), 0 40px 80px 0 rgb(37 41 46 / 0.24)",+ foreground: "oklch(0.254 0.011 254)",+ "surface-foreground": "oklch(0.254 0.011 254)",+ "surface-selected-foreground": "oklch(0.254 0.011 254)",+ "card-foreground": "oklch(0.254 0.011 254)",+ "popover-foreground": "oklch(0.254 0.011 254)",+ primary: "oklch(0.254 0.011 254)",+ secondary: "oklch(0.978 0.003 247.9)",+ muted: "oklch(0.978 0.003 247.9)",+ accent: "oklch(0.96 0.005 247.9)",+ "muted-foreground": "oklch(0.495 0.022 250.8)",+ "faint-foreground": "oklch(0.596 0.022 253)",+ border: "oklch(0.916 0.009 247.9)",+ input: "oklch(0.881 0.013 244.3)",+ ring: "oklch(0.54 0.191 257.5)",+ sidebar: "oklch(0.978 0.003 247.9)",+ "sidebar-accent": "oklch(0.935 0.008 253.9)",+ "sidebar-border": "oklch(0.881 0.013 244.3)",+ brand: "oklch(0.54 0.191 257.5)",+ "button-primary": "oklch(0.552 0.145 148.2)",+ "button-primary-foreground": "oklch(1 0 0)",+ "button-primary-border": "oklch(0.5 0.13 148)",+ "nav-item-hover-background": "rgb(129 139 152 / 0.1)",+ "nav-item-active-background": "rgb(129 139 152 / 0.15)",+ "menu-item-hover-background": "rgb(129 139 152 / 0.1)",+ "issue-row-hover-background": "var(--muted)",+ "issue-group-header-background": "var(--muted)",+ "issue-group-header-hover-background": "rgb(129 139 152 / 0.15)",+ "board-column-background": "var(--muted)",+ "status-backlog": "#59636e",+ "status-todo": "#1a7f37",+ "status-in-progress": "#9a6700",+ "status-in-review": "#0969da",+ "status-done": "#8250df",+ "status-blocked": "#d1242f",+ "status-cancelled": "#59636e",+ "priority-urgent": "#d1242f",+ "priority-high": "#bc4c00",+ "priority-medium": "#9a6700",+ "priority-low": "#0969da",+ "code-background": "rgb(129 139 152 / 0.2)",+ "code-block-background": "#f6f8fa",+ "code-block-color": "#1f2328",+ "code-keyword": "#cf222e",+ "code-string": "#0a3069",+ "code-comment": "#59636e",+ "code-number": "#0550ae",+ "code-function": "#8250df",+ "code-property": "#0550ae",+ "code-variable": "#953800",+ "code-type": "#953800",+ "code-deletion": "#82071e",+ "code-tag": "#116329",+ "code-punctuation": "#1f2328",+ "blockquote-border-color": "#d1d9e0",+ "table-border-color": "#d1d9e0",+ "hr-color": "#d1d9e0",+ "highlight-background": "#fff8c5",+ },+ dark: {+ ...GITHUB_SHARED,+ "app-shell": "oklch(0.104 0.019 248.3)",+ "page-canvas": "oklch(0.176 0.014 258.4)",+ surface: "oklch(0.22 0.018 255.7)",+ "surface-raised": "oklch(0.22 0.018 255.7)",+ "surface-hover": "oklch(0.274 0.018 251.9)",+ "surface-selected": "oklch(0.292 0.02 260.6)",+ "surface-border": "oklch(0.384 0.018 254.7)",+ "menu-shadow": "0 0 0 1px rgb(61 68 77), 0 6px 12px -3px rgb(1 4 9 / 0.4), 0 6px 18px 0 rgb(1 4 9 / 0.4)",+ "floating-shadow": "0 0 0 1px rgb(61 68 77), 0 24px 48px 0 rgb(1 4 9)",+ foreground: "oklch(0.97 0.01 247.9)",+ "surface-foreground": "oklch(0.97 0.01 247.9)",+ "surface-selected-foreground": "oklch(0.97 0.01 247.9)",+ "card-foreground": "oklch(0.97 0.01 247.9)",+ "popover-foreground": "oklch(0.97 0.01 247.9)",+ secondary: "oklch(0.274 0.018 251.9)",+ muted: "oklch(0.22 0.018 255.7)",+ accent: "oklch(0.274 0.018 251.9)",+ "muted-foreground": "oklch(0.706 0.015 254.6)",+ "faint-foreground": "oklch(0.604 0.021 258.4)",+ border: "oklch(0.326 0.016 255.6)",+ input: "oklch(0.384 0.018 254.7)",+ ring: "oklch(0.663 0.169 255.9)",+ sidebar: "oklch(0.176 0.014 258.4)",+ "sidebar-accent": "oklch(0.274 0.018 251.9)",+ "sidebar-border": "oklch(0.326 0.016 255.6)",+ brand: "oklch(0.663 0.169 255.9)",+ "button-primary": "oklch(0.546 0.147 146.3)",+ "button-primary-foreground": "oklch(1 0 0)",+ "button-primary-border": "oklch(0.6 0.15 146)",+ "nav-item-hover-background": "rgb(101 108 118 / 0.2)",+ "nav-item-active-background": "rgb(101 108 118 / 0.3)",+ "menu-item-hover-background": "rgb(101 108 118 / 0.2)",+ "issue-row-hover-background": "var(--surface)",+ "issue-group-header-background": "var(--surface)",+ "issue-group-header-hover-background": "rgb(101 108 118 / 0.3)",+ "board-column-background": "var(--surface)",+ "board-card-background": "var(--page-canvas)",+ "status-backlog": "#9198a1",+ "status-todo": "#3fb950",+ "status-in-progress": "#d29922",+ "status-in-review": "#4493f8",+ "status-done": "#ab7df8",+ "status-blocked": "#f85149",+ "status-cancelled": "#9198a1",+ "priority-urgent": "#f85149",+ "priority-high": "#db6d28",+ "priority-medium": "#d29922",+ "priority-low": "#4493f8",+ "code-background": "rgb(101 108 118 / 0.4)",+ "code-block-background": "#151b23",+ "code-block-color": "#f0f6fc",+ "code-keyword": "#ff7b72",+ "code-string": "#a5d6ff",+ "code-comment": "#9198a1",+ "code-number": "#79c0ff",+ "code-function": "#d2a8ff",+ "code-property": "#79c0ff",+ "code-variable": "#ffa657",+ "code-type": "#ffa657",+ "code-deletion": "#ffdcd7",+ "code-tag": "#7ee787",+ "code-punctuation": "#f0f6fc",+ "blockquote-border-color": "#3d444d",+ "table-border-color": "#3d444d",+ "hr-color": "#3d444d",+ "highlight-background": "rgb(187 128 9 / 0.15)",+ },+ },+ css: GITHUB_CSS,+});++/** Shape and content treatments Blueprint uses in both modes. */+const BLUEPRINT_SHARED: ThemeTokens = {+ "font-ui": "-apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Open Sans, Helvetica Neue",+ "font-mono": SYSTEM_MONO,+ radius: "0.125rem",+ "menu-radius": "0.25rem",+ "popover-radius": "0.25rem",+ "dialog-radius": "0.375rem",+ "menu-item-radius": "0.125rem",+ "card-radius": "0.25rem",+ "page-radius": "0.25rem",+ "nav-item-radius": "0.125rem",+ "nav-item-height": "1.875rem",+ "label-radius": "0.125rem",+ "issue-row-height": "32px",+ "issue-group-header-radius": "0",+ "issue-group-header-background": "transparent",+ "issue-group-header-hover-background": "rgb(143 153 168 / 0.15)",+ "issue-row-hover-background": "rgb(143 153 168 / 0.15)",+ "nav-item-hover-background": "rgb(143 153 168 / 0.15)",+ "nav-item-active-background": "#2d72d2",+ "nav-item-active-color": "#ffffff",+ "menu-item-hover-background": "rgb(143 153 168 / 0.15)",+ "menu-item-hover-color": "var(--foreground)",+ "board-column-radius": "0.25rem",+ "board-card-radius": "0.25rem",+ "board-card-border-color": "transparent",+ "blockquote-border-width": "4px",+ "blockquote-padding": "1.25rem",+ "blockquote-style": "normal",+ "blockquote-color": "var(--foreground)",+ "code-font-size": "0.875em",+ "code-padding": "0.125rem 0.3125rem",+ "code-radius": "0.125rem",+ "code-block-radius": "0.125rem",+ "code-block-padding": "0.8125rem 0.9375rem",+ "table-radius": "0",+ "table-header-background": "transparent",+ "table-header-color": "var(--foreground)",+ "table-header-weight": "600",+ "table-cell-padding": "0.6875rem",+ "link-decoration-color": "transparent",+ "link-decoration-color-hover": "currentColor",+};++/** Blueprint's HTMLTable rule under every row and section header. */+const BLUEPRINT_CSS = [+ '[data-mc="issue-row"], [data-mc="issue-group-header"] { box-shadow: inset 0 -1px var(--border); }',+].join("\n");++/**+ * Blueprint (Blueprint 5): dense rows, 2px corners, square tags, and the+ * primary intent blue on the current sidebar item, as in its Tree.+ */+const BLUEPRINT = builtInTheme({+ id: "blueprint",+ name: "Blueprint",+ author: "Palantir",+ tokens: {+ light: {+ ...BLUEPRINT_SHARED,+ "app-shell": "oklch(0.951 0.005 258.3)",+ "page-canvas": "oklch(0.976 0.003 264.5)",+ surface: "oklch(1 0 0)",+ "surface-raised": "oklch(1 0 0)",+ "surface-hover": "oklch(0.93 0.005 247.9)",+ "surface-selected": "oklch(0.94 0.02 257.5)",+ "surface-border": "oklch(0.88 0.01 252.8)",+ "surface-shadow": "0 0 0 1px rgb(17 20 24 / 0.04), 0 1px 1px rgb(17 20 24 / 0.12)",+ "menu-shadow": "0 0 0 1px rgb(17 20 24 / 0.1), 0 2px 4px rgb(17 20 24 / 0.2), 0 8px 24px rgb(17 20 24 / 0.2)",+ foreground: "oklch(0.245 0.014 253.1)",+ "surface-foreground": "oklch(0.245 0.014 253.1)",+ "surface-selected-foreground": "oklch(0.245 0.014 253.1)",+ "card-foreground": "oklch(0.245 0.014 253.1)",+ "popover-foreground": "oklch(0.245 0.014 253.1)",+ primary: "oklch(0.245 0.014 253.1)",+ secondary: "oklch(0.951 0.005 258.3)",+ muted: "oklch(0.951 0.005 258.3)",+ accent: "oklch(0.93 0.005 247.9)",+ "muted-foreground": "oklch(0.5 0.031 257.1)",+ "faint-foreground": "oklch(0.595 0.03 255.2)",+ border: "oklch(0.905 0.008 253.9)",+ input: "oklch(0.84 0.013 255.5)",+ ring: "oklch(0.56 0.163 257.6)",+ sidebar: "oklch(0.951 0.005 258.3)",+ "sidebar-accent": "oklch(0.905 0.008 253.9)",+ "sidebar-border": "oklch(0.88 0.01 252.8)",+ brand: "oklch(0.487 0.146 257.7)",+ "button-primary": "oklch(0.56 0.163 257.6)",+ "button-primary-foreground": "oklch(1 0 0)",+ "button-primary-border": "oklch(0.487 0.146 257.7)",+ "board-column-background": "#edeff2",+ "board-card-shadow": "0 0 0 1px rgb(17 20 24 / 0.1), 0 1px 1px rgb(17 20 24 / 0.2)",+ "status-backlog": "#8f99a8",+ "status-todo": "#5f6b7c",+ "status-in-progress": "#2d72d2",+ "status-in-review": "#c87619",+ "status-done": "#238551",+ "status-blocked": "#cd4246",+ "status-cancelled": "#8f99a8",+ "priority-urgent": "#cd4246",+ "priority-high": "#c87619",+ "priority-medium": "#d1980b",+ "priority-low": "#2d72d2",+ "code-background": "rgb(255 255 255 / 0.7)",+ "code-border-color": "rgb(17 20 24 / 0.2)",+ "code-color": "#5f6b7c",+ "code-block-background": "#f6f7f9",+ "code-block-border": "1px solid rgb(17 20 24 / 0.15)",+ "code-block-color": "#1c2127",+ "code-keyword": "#2d72d2",+ "code-string": "#238551",+ "code-comment": "#738091",+ "code-number": "#c87619",+ "code-function": "#7961db",+ "code-property": "#147eb3",+ "code-variable": "#cd4246",+ "code-type": "#00a396",+ "code-deletion": "#cd4246",+ "code-tag": "#2d72d2",+ "code-punctuation": "#5f6b7c",+ "blockquote-border-color": "rgb(17 20 24 / 0.15)",+ "table-border-color": "rgb(17 20 24 / 0.15)",+ "hr-color": "rgb(17 20 24 / 0.15)",+ "link-color": "#215db0",+ "highlight-background": "rgb(240 183 38 / 0.3)",+ },+ dark: {+ ...BLUEPRINT_SHARED,+ "app-shell": "oklch(0.245 0.014 253.1)",+ "page-canvas": "oklch(0.283 0.015 256.8)",+ surface: "oklch(0.323 0.016 259.8)",+ "surface-raised": "oklch(0.362 0.018 258.4)",+ "surface-hover": "oklch(0.362 0.018 258.4)",+ "surface-selected": "oklch(0.377 0.057 259.3)",+ "surface-border": "oklch(0.399 0.023 258.4)",+ foreground: "oklch(0.976 0.003 264.5)",+ "surface-foreground": "oklch(0.976 0.003 264.5)",+ "surface-selected-foreground": "oklch(0.976 0.003 264.5)",+ "card-foreground": "oklch(0.976 0.003 264.5)",+ "popover-foreground": "oklch(0.976 0.003 264.5)",+ secondary: "oklch(0.362 0.018 258.4)",+ muted: "oklch(0.323 0.016 259.8)",+ accent: "oklch(0.362 0.018 258.4)",+ "muted-foreground": "oklch(0.8 0.019 258.4)",+ "faint-foreground": "oklch(0.7 0.025 258.4)",+ border: "oklch(0.369 0.017 258.4)",+ input: "oklch(0.45 0.025 258.4)",+ ring: "oklch(0.655 0.159 257.4)",+ sidebar: "oklch(0.245 0.014 253.1)",+ "sidebar-accent": "oklch(0.323 0.016 259.8)",+ "sidebar-border": "oklch(0.399 0.023 258.4)",+ brand: "oklch(0.76 0.12 257.4)",+ "button-primary": "oklch(0.56 0.163 257.6)",+ "button-primary-foreground": "oklch(1 0 0)",+ "button-primary-border": "oklch(0.655 0.159 257.4)",+ "board-column-background": "#252a31",+ "board-card-shadow": "0 0 0 1px rgb(17 20 24 / 0.4), 0 1px 1px rgb(17 20 24 / 0.4)",+ "status-backlog": "#8f99a8",+ "status-todo": "#abb3bf",+ "status-in-progress": "#4c90f0",+ "status-in-review": "#ec9a3c",+ "status-done": "#32a467",+ "status-blocked": "#e76a6e",+ "status-cancelled": "#8f99a8",+ "priority-urgent": "#e76a6e",+ "priority-high": "#ec9a3c",+ "priority-medium": "#f0b726",+ "priority-low": "#4c90f0",+ "code-background": "rgb(17 20 24 / 0.3)",+ "code-border-color": "rgb(17 20 24 / 0.4)",+ "code-color": "#abb3bf",+ "code-block-background": "rgb(17 20 24 / 0.3)",+ "code-block-border": "1px solid rgb(17 20 24 / 0.4)",+ "code-block-color": "#f6f7f9",+ "code-keyword": "#8abbff",+ "code-string": "#72ca9b",+ "code-comment": "#abb3bf",+ "code-number": "#fbb360",+ "code-function": "#bdadff",+ "code-property": "#68c1ee",+ "code-variable": "#fa999c",+ "code-type": "#7ae1d8",+ "code-deletion": "#fa999c",+ "code-tag": "#8abbff",+ "code-punctuation": "#abb3bf",+ "blockquote-border-color": "rgb(255 255 255 / 0.2)",+ "table-border-color": "rgb(255 255 255 / 0.2)",+ "hr-color": "rgb(255 255 255 / 0.2)",+ "link-color": "#8abbff",+ "highlight-background": "rgb(240 183 38 / 0.25)",+ },+ },+ css: BLUEPRINT_CSS,+});++/** Shape and content treatments Notion uses in both modes. */+const NOTION_SHARED: ThemeTokens = {+ "font-ui": "-apple-system, BlinkMacSystemFont, Segoe UI Variable Display, Segoe UI, Helvetica, Apple Color Emoji, Arial",+ "font-mono": "SFMono-Regular, Menlo, Consolas, PT Mono, Liberation Mono, Courier, monospace",+ radius: "0.375rem",+ "menu-radius": "0.625rem",+ "popover-radius": "0.625rem",+ "dialog-radius": "0.75rem",+ "menu-item-radius": "0.375rem",+ "nav-item-radius": "0.375rem",+ "nav-item-height": "1.875rem",+ "nav-item-active-color": "var(--foreground)",+ "menu-item-hover-color": "var(--foreground)",+ "label-radius": "0.1875rem",+ "issue-group-header-background": "transparent",+ "board-column-background": "transparent",+ "board-card-radius": "0.5rem",+ "board-card-border-color": "transparent",+ "h1-size": "1.875em",+ "h2-size": "1.5em",+ "h3-size": "1.25em",+ "blockquote-border-width": "3px",+ "blockquote-border-color": "currentColor",+ "blockquote-padding": "0.875rem",+ "blockquote-style": "normal",+ "blockquote-color": "var(--foreground)",+ "code-color": "#eb5757",+ "code-background": "rgb(135 131 120 / 0.15)",+ "code-border-color": "transparent",+ "code-radius": "0.25rem",+ "code-padding": "0.2em 0.4em",+ "code-font-size": "85%",+ "code-block-radius": "0.25rem",+ "code-block-padding": "1.5rem 1.75rem",+ "code-block-font-size": "85%",+ "code-block-line-height": "1.5",+ "code-block-color": "var(--foreground)",+ "link-color": "currentColor",+ "link-decoration-color": "color-mix(in srgb, currentColor 40%, transparent)",+ "link-decoration-color-hover": "currentColor",+ "mention-color": "var(--foreground)",+ "mention-weight": "500",+ "checkbox-color": "#2383e2",+ "list-marker-color": "var(--foreground)",+ "table-radius": "0",+ "table-header-color": "var(--muted-foreground)",+ "table-header-weight": "500",+};++/** Notion's page fonts: Default, Serif and Mono, as in its page style menu. */+const NOTION_PAGE_FONT = {+ id: "font-content-latin",+ type: "variable-select",+ label: { en: "Page font", "zh-Hans": "页面字体", "zh-Hant": "頁面字體", ja: "ページのフォント", ko: "페이지 글꼴", es: "Fuente de página", fr: "Police de page", ru: "Шрифт страницы" },+ description: {+ en: "Descriptions, comments and chat. Your Content text font still wins.",+ "zh-Hans": "描述、评论和对话。你在「内容文字」里选的字体优先。",+ "zh-Hant": "描述、留言和對話。你在「內容文字」裡選的字體優先。",+ ja: "説明、コメント、チャット。「コンテンツの文字」で選んだフォントが優先されます。",+ ko: "설명, 댓글, 채팅. ‘콘텐츠 글자’에서 고른 글꼴이 우선합니다.",+ es: "Descripciones, comentarios y chat. Tu fuente de Texto del contenido tiene prioridad.",+ fr: "Descriptions, commentaires et chat. Votre police de Texte du contenu reste prioritaire.",+ ru: "Описания, комментарии и чат. Ваш шрифт для текста содержимого имеет приоритет.",+ },+ default: "var(--font-ui)",+ choices: [+ { value: "var(--font-ui)", label: { en: "Default", "zh-Hans": "默认", "zh-Hant": "預設", ja: "デフォルト", ko: "기본", es: "Predeterminada", fr: "Par défaut", ru: "По умолчанию" } },+ { value: "Lyon-Text, Georgia", label: { en: "Serif", "zh-Hans": "衬线", "zh-Hant": "襯線", ja: "セリフ", ko: "세리프", es: "Serif", fr: "Serif", ru: "С засечками" } },+ { value: "iawriter-mono, Nitti, Menlo, Courier", label: { en: "Mono", "zh-Hans": "等宽", "zh-Hant": "等寬", ja: "等幅", ko: "고정폭", es: "Monoespaciada", fr: "Mono", ru: "Моноширинный" } },+ ],+} as const;++/**+ * Notion: system type, warm greys, quiet sidebar, borderless boards with+ * lifted cards, red inline code, and Default / Serif / Mono page fonts.+ */+const NOTION = builtInTheme({+ id: "notion",+ name: "Notion",+ tokens: {+ light: {+ ...NOTION_SHARED,+ "app-shell": "oklch(0.976 0.003 106.4)",+ "page-canvas": "oklch(1 0 0)",+ surface: "oklch(1 0 0)",+ "surface-raised": "oklch(1 0 0)",+ "surface-hover": "oklch(0.958 0.003 106.4)",+ "surface-selected": "oklch(0.943 0.003 106.5)",+ "surface-border": "oklch(0.933 0.003 106.5)",+ "surface-shadow": "0 1px 2px rgb(15 15 15 / 0.04)",+ "floating-shadow": "0 0 0 1px rgb(15 15 15 / 0.05), 0 3px 6px rgb(15 15 15 / 0.1), 0 9px 24px rgb(15 15 15 / 0.2)",+ "menu-shadow": "0 0 0 1px rgb(15 15 15 / 0.05), 0 3px 6px rgb(15 15 15 / 0.1), 0 9px 24px rgb(15 15 15 / 0.2)",+ foreground: "oklch(0.329 0.011 91.7)",+ "surface-foreground": "oklch(0.329 0.011 91.7)",+ "surface-selected-foreground": "oklch(0.329 0.011 91.7)",+ "card-foreground": "oklch(0.329 0.011 91.7)",+ "popover-foreground": "oklch(0.329 0.011 91.7)",+ primary: "oklch(0.329 0.011 91.7)",+ secondary: "oklch(0.958 0.003 106.4)",+ muted: "oklch(0.958 0.003 106.4)",+ accent: "oklch(0.958 0.003 106.4)",+ "muted-foreground": "oklch(0.51 0.006 95.2)",+ "faint-foreground": "oklch(0.617 0.005 91.5)",+ border: "oklch(0.946 0.001 106.4)",+ input: "oklch(0.894 0.003 106.5)",+ ring: "oklch(0.606 0.167 252.7)",+ sidebar: "oklch(0.976 0.003 106.4)",+ "sidebar-accent": "oklch(0.943 0.003 106.5)",+ "sidebar-border": "oklch(0.933 0.003 106.5)",+ brand: "oklch(0.541 0.153 254)",+ "button-primary": "oklch(0.541 0.153 254)",+ "button-primary-foreground": "oklch(1 0 0)",+ "nav-item-hover-background": "rgb(55 53 47 / 0.06)",+ "nav-item-active-background": "rgb(55 53 47 / 0.08)",+ "menu-item-hover-background": "rgb(55 53 47 / 0.06)",+ "issue-row-hover-background": "rgb(55 53 47 / 0.04)",+ "issue-group-header-hover-background": "rgb(55 53 47 / 0.06)",+ "board-card-hover-background": "#fafaf9",+ "board-card-shadow": "0 0 0 1px rgb(15 15 15 / 0.1), 0 2px 4px rgb(15 15 15 / 0.1)",+ "status-backlog": "#9b9a97",+ "status-todo": "#787774",+ "status-in-progress": "#337ea9",+ "status-in-review": "#cb912f",+ "status-done": "#448361",+ "status-blocked": "#d44c47",+ "status-cancelled": "#9b9a97",+ "priority-urgent": "#d44c47",+ "priority-high": "#d9730d",+ "priority-medium": "#cb912f",+ "priority-low": "#337ea9",+ "code-block-background": "#f7f6f3",+ "code-keyword": "#0077aa",+ "code-string": "#669900",+ "code-comment": "#708090",+ "code-number": "#990055",+ "code-function": "#dd4a68",+ "code-property": "#990055",+ "code-variable": "#ee9900",+ "code-type": "#dd4a68",+ "code-deletion": "#990055",+ "code-tag": "#990055",+ "code-punctuation": "#999999",+ "table-border-color": "#e9e9e7",+ "table-header-background": "#f7f6f3",+ "hr-color": "rgb(55 53 47 / 0.16)",+ "highlight-background": "#fbf3db",+ },+ dark: {+ ...NOTION_SHARED,+ "app-shell": "oklch(0.244 0 0)",+ "page-canvas": "oklch(0.213 0 0)",+ surface: "oklch(0.264 0 0)",+ "surface-raised": "oklch(0.264 0 0)",+ "surface-hover": "oklch(0.293 0 0)",+ "surface-selected": "oklch(0.305 0 0)",+ "surface-border": "oklch(0.337 0 0)",+ foreground: "oklch(0.87 0 0)",+ "surface-foreground": "oklch(0.87 0 0)",+ "surface-selected-foreground": "oklch(0.87 0 0)",+ "card-foreground": "oklch(0.87 0 0)",+ "popover-foreground": "oklch(0.87 0 0)",+ secondary: "oklch(0.293 0 0)",+ muted: "oklch(0.264 0 0)",+ accent: "oklch(0.293 0 0)",+ "muted-foreground": "oklch(0.72 0 0)",+ "faint-foreground": "oklch(0.6 0 0)",+ border: "oklch(0.285 0 0)",+ input: "oklch(0.364 0 0)",+ ring: "oklch(0.664 0.101 238.1)",+ sidebar: "oklch(0.244 0 0)",+ "sidebar-accent": "oklch(0.293 0 0)",+ "sidebar-border": "oklch(0.305 0 0)",+ brand: "oklch(0.7 0.1 238.1)",+ "button-primary": "oklch(0.541 0.153 254)",+ "button-primary-foreground": "oklch(1 0 0)",+ "nav-item-hover-background": "rgb(255 255 255 / 0.055)",+ "nav-item-active-background": "rgb(255 255 255 / 0.08)",+ "menu-item-hover-background": "rgb(255 255 255 / 0.055)",+ "issue-row-hover-background": "rgb(255 255 255 / 0.03)",+ "issue-group-header-hover-background": "rgb(255 255 255 / 0.055)",+ "board-card-hover-background": "#2c2c2c",+ "board-card-shadow": "0 0 0 1px rgb(255 255 255 / 0.094), 0 2px 4px rgb(15 15 15 / 0.2)",+ "status-backlog": "#7f7f7f",+ "status-todo": "#9b9b9b",+ "status-in-progress": "#379ad3",+ "status-in-review": "#ca9849",+ "status-done": "#529e72",+ "status-blocked": "#df5452",+ "status-cancelled": "#7f7f7f",+ "priority-urgent": "#df5452",+ "priority-high": "#c77d48",+ "priority-medium": "#ca9849",+ "priority-low": "#379ad3",+ "code-block-background": "#202020",+ "code-keyword": "#cc99cd",+ "code-string": "#7ec699",+ "code-comment": "#999999",+ "code-number": "#f08d49",+ "code-function": "#f08d49",+ "code-property": "#f8c555",+ "code-variable": "#e2777a",+ "code-type": "#f8c555",+ "code-deletion": "#e2777a",+ "code-tag": "#e2777a",+ "code-punctuation": "#cccccc",+ "table-border-color": "rgb(255 255 255 / 0.094)",+ "table-header-background": "#202020",+ "hr-color": "rgb(255 255 255 / 0.13)",+ "highlight-background": "rgb(255 212 0 / 0.14)",+ },+ },+ options: [NOTION_PAGE_FONT],+});++const DEFAULT = builtInTheme({+ id: DEFAULT_THEME_ID,+ name: "Default",+ tokens: { light: {}, dark: {} },+});++export const BUILT_IN_THEMES: readonly BuiltInTheme[] = [DEFAULT, POP, GITHUB, BLUEPRINT, NOTION];++export function findBuiltInTheme(id: string): BuiltInTheme | undefined {+ return BUILT_IN_THEMES.find((theme) => theme.id === id);+}diff --git a/packages/core/appearance/index.test.ts b/packages/core/appearance/index.test.tsnew file mode 100644index 0000000000..26ee16af27--- /dev/null+++ b/packages/core/appearance/index.test.ts@@ -0,0 +1,270 @@+// @vitest-environment jsdom+import { beforeEach, describe, expect, it } from "vitest";+import {+ APPEARANCE_STORAGE_KEY,+ BUILT_IN_THEMES,+ DEFAULT_APPEARANCE,+ activeTheme,+ appearanceRootVariables,+ appearanceStylesheet,+ appearanceThemeAttributes,+ appearanceThemeCss,+ findBuiltInTheme,+ isDefaultAppearance,+ isSafeFontValue,+ isSafeThemeValue,+ localizedText,+ sanitizeAppearance,+ THEME_VARIABLE_NAMES,+ themeModeVariables,+ themeTokensCss,+ useAppearanceStore,+ type AppearancePreferences,+ type Theme,+} from ".";++const pop = findBuiltInTheme("pop")!;+const defaults = findBuiltInTheme("default")!;++describe("appearance store", () => {+ beforeEach(() => {+ localStorage.clear();+ useAppearanceStore.setState(DEFAULT_APPEARANCE);+ });++ it("saves the preferences on this device", () => {+ useAppearanceStore.getState().set({ theme: "github", fontSize: 16, contentSize: 17 });+ const saved = JSON.parse(localStorage.getItem(APPEARANCE_STORAGE_KEY) ?? "{}");+ expect(saved.state).toMatchObject({ theme: "github", fontSize: 16, contentSize: 17 });+ });++ it("keeps option values per theme", () => {+ const { setThemeOption } = useAppearanceStore.getState();+ setThemeOption("pop", "signal", "mint");+ setThemeOption("pop", "status-blocks", false);+ expect(useAppearanceStore.getState().themeOptions).toEqual({+ pop: { signal: "mint", "status-blocks": false },+ });+ });++ it("resets everything to the defaults", () => {+ const { set, setThemeOption, reset } = useAppearanceStore.getState();+ set({ theme: "pop", contentFont: "serif" });+ setThemeOption("pop", "signal", "sky");+ reset();+ expect(isDefaultAppearance(sanitizeAppearance(useAppearanceStore.getState()))).toBe(true);+ });++ it("reads older saved shapes", async () => {+ localStorage.setItem(+ APPEARANCE_STORAGE_KEY,+ JSON.stringify({ state: { style: "pop", cjkFont: "kai", accent: "violet" }, version: 0 }),+ );+ await useAppearanceStore.persist.rehydrate();+ expect(useAppearanceStore.getState()).toMatchObject({ theme: "pop", uiCjkFont: "kai" });+ expect(useAppearanceStore.getState()).not.toHaveProperty("accent");+ });+});++describe("sanitizeAppearance", () => {+ it("falls back per field for unknown or missing values", () => {+ expect(+ sanitizeAppearance({+ theme: "Not An Id",+ fontSize: 40,+ density: "comfortable",+ reduceMotion: "yes",+ contentSize: 99,+ uiCjkFont: 'local:Evil"; }',+ }),+ ).toEqual({ ...DEFAULT_APPEARANCE, density: "comfortable" });+ expect(sanitizeAppearance(null)).toEqual(DEFAULT_APPEARANCE);+ });++ it("keeps only built-in theme ids, and their options", () => {+ expect(sanitizeAppearance({ theme: "notion" }).theme).toBe("notion");+ expect(sanitizeAppearance({ theme: "solarized" }).theme).toBe("default");+ expect(sanitizeAppearance({ themeOptions: { solarized: { a: true }, pop: { signal: "sky" } } }).themeOptions).toEqual({+ pop: { signal: "sky" },+ });+ });++ it("accepts installed CJK families and follow-the-interface values", () => {+ expect(+ sanitizeAppearance({ uiCjkFont: "local:Hiragino Sans GB", contentCjkFont: "ui", contentFont: "serif" }),+ ).toMatchObject({ uiCjkFont: "local:Hiragino Sans GB", contentCjkFont: "ui", contentFont: "serif" });+ });++ it("drops malformed theme options", () => {+ expect(+ sanitizeAppearance({ themeOptions: { pop: { signal: "mint", "Bad Key": true, big: "x".repeat(301) }, "!": {} } })+ .themeOptions,+ ).toEqual({ pop: { signal: "mint" } });+ });+});++describe("appearanceRootVariables", () => {+ it("leaves every variable unset for the defaults", () => {+ expect(Object.values(appearanceRootVariables(DEFAULT_APPEARANCE)).every((v) => v === null)).toBe(true);+ });++ it("maps interface and content type onto separate variables", () => {+ const vars = appearanceRootVariables({+ ...DEFAULT_APPEARANCE,+ uiFont: "serif",+ uiCjkFont: "kai",+ contentFont: "inter",+ contentCjkFont: "local:Songti SC",+ contentSize: 16,+ contentLeading: "relaxed",+ codeFont: "jetbrains",+ fontSize: 15,+ density: "compact",+ });+ expect(vars["--font-ui"]).toBe("var(--font-ui-serif)");+ expect(vars["--font-cjk"]).toBe("var(--font-cjk-kai)");+ expect(vars["--font-content-latin"]).toBe("var(--font-ui-inter)");+ expect(vars["--font-content-cjk"]).toBe('"Songti SC", var(--font-cjk-sans)');+ expect(vars["--content-scale"]).toBe(String(16 / 14));+ expect(vars["--content-leading"]).toBe("1.8");+ expect(vars["--font-mono"]).toMatch(/^var\(--font-code-jetbrains\)/);+ expect(vars["--font-scale"]).toBe(String(15 / 14));+ expect(vars["--issue-row-height"]).toBe("32px");+ });+});++describe("appearanceStylesheet", () => {+ it("is empty for the defaults", () => {+ expect(appearanceStylesheet(defaults, DEFAULT_APPEARANCE)).toBe("");+ expect(appearanceThemeAttributes(defaults, DEFAULT_APPEARANCE)).toEqual({ "data-theme": null });+ });++ it("writes contrast with selectors that outrank the theme's", () => {+ const prefs = { ...DEFAULT_APPEARANCE, theme: "github", highContrast: true } as const;+ const css = appearanceStylesheet(activeTheme(prefs), prefs);+ expect(css).not.toContain("--brand");+ expect(css).toMatch(/:root:not\(\.dark\), :root\.dark \{ --muted-foreground: color-mix/);+ expect(activeTheme(prefs).css).toMatch(/^\.theme-light \{/);+ });++ it("names the theme and its options, defaults included", () => {+ const prefs: AppearancePreferences = {+ ...DEFAULT_APPEARANCE,+ theme: "pop",+ themeOptions: { pop: { signal: "sky", "status-blocks": false, unknown: true } },+ };+ expect(appearanceThemeAttributes(pop, prefs)).toEqual({+ "data-theme": "pop",+ "data-theme-option-signal": "sky",+ "data-theme-option-offset-shadow": "on",+ "data-theme-option-status-blocks": null,+ "data-theme-option-outlined-chips": "on",+ });+ });++ it("writes option variables per mode, from valid choices or the defaults", () => {+ const theme: Theme = {+ apiVersion: 1,+ id: "paper",+ name: "Paper",+ css: "",+ options: [+ { id: "paper-color", type: "color", label: "Paper", default: { light: "#f6efdf", dark: "#1d1b16" } },+ { id: "page-width", type: "slider", label: "Width", default: 46, min: 30, max: 60, unit: "rem" },+ { id: "h1-style", type: "text", label: "H1", default: "normal" },+ { id: "hyphens", type: "toggle", label: "Hyphens", default: true },+ ],+ };+ const prefs: AppearancePreferences = {+ ...DEFAULT_APPEARANCE,+ themeOptions: { paper: { "paper-color": { dark: "#000000" }, "page-width": 99, "h1-style": "x; }" } },+ };+ expect(appearanceStylesheet(theme, prefs)).toBe(+ [+ ":root.theme-light { --paper-color: #f6efdf; --page-width: 60rem; --h1-style: normal; }",+ ":root.theme-dark { --paper-color: #000000; --page-width: 60rem; --h1-style: normal; }",+ ].join("\n"),+ );+ expect(appearanceThemeAttributes(theme, prefs)).toEqual({+ "data-theme": "paper",+ "data-theme-option-hyphens": "on",+ });+ });++ it("keeps stored option values of every type", () => {+ const stored = sanitizeAppearance({+ themeOptions: { pop: { a: true, b: "sky", c: 1.5, d: { light: "#fff", dark: 3 }, e: Number.NaN, f: [] } },+ });+ expect(stored.themeOptions).toEqual({ pop: { a: true, b: "sky", c: 1.5, d: { light: "#fff" } } });+ });++ it("applies a built-in theme and its CSS, and Default for anything else", () => {+ const active = activeTheme({ ...DEFAULT_APPEARANCE, theme: "notion" });+ expect(active.id).toBe("notion");+ expect(appearanceThemeCss(active)).toBe(active.css);+ expect(activeTheme({ ...DEFAULT_APPEARANCE, theme: "not-built-in" }).id).toBe("default");+ });+});++describe("built-in themes", () => {+ it("set only public variables with values a declaration cannot escape", () => {+ expect(new Set(BUILT_IN_THEMES.map((t) => t.id)).size).toBe(BUILT_IN_THEMES.length);+ for (const theme of BUILT_IN_THEMES) {+ for (const tokens of [theme.tokens.light, theme.tokens.dark, theme.frame?.light, theme.frame?.dark]) {+ for (const [name, value] of Object.entries(tokens ?? {})) {+ expect(THEME_VARIABLE_NAMES.has(name), name).toBe(true);+ expect(isSafeFontValue(value) || isSafeThemeValue(value), `${name}: ${value}`).toBe(true);+ }+ }+ }+ });++ it("leave Han to the CJK choice: Latin font stacks name no generic family", () => {+ const generic = /^(?:serif|sans-serif|monospace|cursive|fantasy|system-ui|math|emoji|fangsong|ui-[a-z-]+)$/;+ const latin = ["font-ui", "font-content-latin"];+ for (const theme of BUILT_IN_THEMES) {+ const stacks = [theme.tokens.light, theme.tokens.dark].flatMap((tokens) =>+ latin.flatMap((name) => (tokens[name] ? [tokens[name]] : [])),+ );+ for (const option of theme.options ?? []) {+ if (option.type === "variable-select" && latin.includes(option.id)) {+ stacks.push(...option.choices.map((choice) => choice.value));+ }+ }+ for (const stack of stacks) {+ const families = stack.split(",").map((family) => family.trim());+ expect(families.filter((family) => generic.test(family)), `${theme.id}: ${stack}`).toEqual([]);+ }+ }+ });++ it("compile their token tables to mode rules a preview can read back", () => {+ const github = findBuiltInTheme("github")!;+ expect(themeModeVariables(github.css).light).toEqual(github.tokens.light);+ expect(themeModeVariables(github.css).dark).toEqual(github.tokens.dark);+ expect(themeTokensCss({ tokens: { light: { surface: "oklch(1 0 0)" }, dark: {} } })).toBe(+ ".theme-light { --surface: oklch(1 0 0); }",+ );+ });++ it("give Pop's options a label in every locale the app ships", () => {+ for (const option of pop.options ?? []) {+ for (const locale of ["en", "zh-Hans", "zh-Hant", "ja", "ko", "es", "fr"]) {+ expect(localizedText(option.label, locale)).not.toBe("");+ }+ }+ expect(localizedText(pop.options![0]!.label, "zh-Hant")).toBe("信號色");+ expect(localizedText(pop.options![0]!.label, "de")).toBe("Signal color");+ });+});++describe("isSafeFontValue", () => {+ it("accepts font stacks and rejects anything that can leave the declaration", () => {+ expect(isSafeFontValue('"Source Serif 4", Georgia, var(--font-ui-serif)')).toBe(true);+ expect(isSafeFontValue('"霞鹜文楷", serif')).toBe(true);+ expect(isSafeFontValue('"Open')).toBe(false);+ expect(isSafeFontValue("Inter; color: red")).toBe(false);+ expect(isSafeFontValue("url(x)")).toBe(false);+ expect(isSafeFontValue("Inter}")).toBe(false);+ });+});diff --git a/packages/core/appearance/index.ts b/packages/core/appearance/index.tsnew file mode 100644index 0000000000..b29cc12504--- /dev/null+++ b/packages/core/appearance/index.ts@@ -0,0 +1,369 @@+import { useSyncExternalStore } from "react";+import { create } from "zustand";+import { createJSONStorage, persist } from "zustand/middleware";+import { defaultStorage } from "../platform/storage";+import { DEFAULT_THEME_ID, findBuiltInTheme } from "./built-in-themes";+import { isLocalFont, localFontFamily, type LocalFont } from "./local-fonts";+import {+ themeOptionAttributes,+ themeOptionVariables,+ type Theme,+ type ThemeOptionValue,+ type ThemeOptionValues,+} from "./themes";++export * from "./themes";+export * from "./built-in-themes";+export * from "./anchors";+export * from "./theme-variables";+export * from "./local-fonts";++/**+ * Appearance sits on top of light/dark mode: a theme (see ./themes) with its+ * options, type for the interface and for content, density and two+ * accessibility switches. All of it is saved on this device.+ * `AppearanceSync` in @multica/views writes it onto `<html>`: global+ * variables as inline style, the theme's CSS and the adjustments on top of+ * it as two generated stylesheets.+ */++export const UI_FONTS = ["inter", "system", "serif", "mono"] as const;+export type UiFont = (typeof UI_FONTS)[number];++/** Built-in CJK faces; the families per locale live in appearance.css. */+export const CJK_FONTS = ["sans", "serif", "kai"] as const;+export type CjkFont = (typeof CJK_FONTS)[number];++export type CjkFontChoice = CjkFont | LocalFont;++/** Content settings can follow the interface instead of naming a value. */+export const FOLLOW_UI = "ui";+export type ContentFont = typeof FOLLOW_UI | UiFont;+export type ContentCjkFont = typeof FOLLOW_UI | CjkFontChoice;++export const CODE_FONTS = ["geist", "jetbrains", "system"] as const;+export type CodeFont = (typeof CODE_FONTS)[number];++export const FONT_SIZES = [12, 13, 14, 15, 16] as const;+export type FontSize = (typeof FONT_SIZES)[number];+export const DEFAULT_FONT_SIZE: FontSize = 14;++export const CONTENT_SIZES = [13, 14, 15, 16, 17, 18] as const;+export type ContentSize = typeof FOLLOW_UI | (typeof CONTENT_SIZES)[number];++export const CONTENT_LEADINGS = ["compact", "default", "relaxed"] as const;+export type ContentLeading = (typeof CONTENT_LEADINGS)[number];++export const DENSITIES = ["compact", "default", "comfortable"] as const;+export type Density = (typeof DENSITIES)[number];++export interface AppearancePreferences {+ theme: string;+ /** Option values per theme id, so switching themes keeps each one's choices. */+ themeOptions: Readonly<Record<string, ThemeOptionValues>>;+ uiFont: UiFont;+ uiCjkFont: CjkFontChoice;+ fontSize: FontSize;+ contentFont: ContentFont;+ contentCjkFont: ContentCjkFont;+ contentSize: ContentSize;+ contentLeading: ContentLeading;+ codeFont: CodeFont;+ density: Density;+ reduceMotion: boolean;+ highContrast: boolean;+}++export const DEFAULT_APPEARANCE: AppearancePreferences = {+ theme: DEFAULT_THEME_ID,+ themeOptions: {},+ uiFont: "inter",+ uiCjkFont: "sans",+ fontSize: DEFAULT_FONT_SIZE,+ contentFont: FOLLOW_UI,+ contentCjkFont: FOLLOW_UI,+ contentSize: FOLLOW_UI,+ contentLeading: "default",+ codeFont: "geist",+ density: "default",+ reduceMotion: false,+ highContrast: false,+};++export const APPEARANCE_STORAGE_KEY = "multica_appearance";+export const APPEARANCE_THEME_ATTR = "data-theme";++const oneOf =+ <T,>(values: readonly T[]) =>+ (v: unknown): v is T =>+ (values as readonly unknown[]).includes(v);++const isCjkChoice = (v: unknown): v is CjkFontChoice => oneOf(CJK_FONTS)(v) || isLocalFont(v);+const OPTION_KEY = /^[a-z][a-z0-9-]{0,47}$/;++function sanitizeOptionValue(v: unknown): ThemeOptionValue | undefined {+ if (typeof v === "boolean") return v;+ if (typeof v === "number") return Number.isFinite(v) ? v : undefined;+ if (typeof v === "string") return v.length <= 300 ? v : undefined;+ if (!v || typeof v !== "object" || Array.isArray(v)) return undefined;+ const color: { light?: string; dark?: string } = {};+ for (const mode of ["light", "dark"] as const) {+ const value = (v as Record<string, unknown>)[mode];+ if (typeof value === "string" && value.length <= 16) color[mode] = value;+ }+ return Object.keys(color).length > 0 ? color : undefined;+}++function sanitizeThemeOptions(value: unknown): Record<string, ThemeOptionValues> {+ if (!value || typeof value !== "object" || Array.isArray(value)) return {};+ const out: Record<string, ThemeOptionValues> = {};+ for (const [themeId, options] of Object.entries(value).slice(0, 40)) {+ if (!findBuiltInTheme(themeId) || !options || typeof options !== "object") continue;+ const clean: Record<string, ThemeOptionValue> = {};+ for (const [key, v] of Object.entries(options).slice(0, 24)) {+ const value = sanitizeOptionValue(v);+ if (OPTION_KEY.test(key) && value !== undefined) clean[key] = value;+ }+ if (Object.keys(clean).length > 0) out[themeId] = clean;+ }+ return out;+}++/**+ * Reads whatever is stored, field by field, falling back to the default for+ * anything missing or unknown. The theme id is kept even when no such theme+ * is installed yet (installed themes load from their own storage); an+ * unknown id renders as the default theme. Older versions stored `style`+ * instead of `theme` and `cjkFont` instead of `uiCjkFont`.+ */+export function sanitizeAppearance(stored: unknown): AppearancePreferences {+ const p = (stored && typeof stored === "object" ? stored : {}) as Record<string, unknown>;+ const pick = <K extends keyof AppearancePreferences>(+ key: K,+ valid: (v: unknown) => v is AppearancePreferences[K],+ value: unknown = p[key],+ ): AppearancePreferences[K] => (valid(value) ? value : DEFAULT_APPEARANCE[key]);+ const isFollow = (v: unknown): v is typeof FOLLOW_UI => v === FOLLOW_UI;+ return {+ theme: pick(+ "theme",+ (v): v is string => typeof v === "string" && findBuiltInTheme(v) !== undefined,+ p.theme ?? p.style,+ ),+ themeOptions: sanitizeThemeOptions(p.themeOptions),+ uiFont: pick("uiFont", oneOf(UI_FONTS)),+ uiCjkFont: pick("uiCjkFont", isCjkChoice, p.uiCjkFont ?? p.cjkFont),+ fontSize: pick("fontSize", oneOf(FONT_SIZES)),+ contentFont: pick("contentFont", (v): v is ContentFont => isFollow(v) || oneOf(UI_FONTS)(v)),+ contentCjkFont: pick("contentCjkFont", (v): v is ContentCjkFont => isFollow(v) || isCjkChoice(v)),+ contentSize: pick("contentSize", (v): v is ContentSize => isFollow(v) || oneOf(CONTENT_SIZES)(v)),+ contentLeading: pick("contentLeading", oneOf(CONTENT_LEADINGS)),+ codeFont: pick("codeFont", oneOf(CODE_FONTS)),+ density: pick("density", oneOf(DENSITIES)),+ reduceMotion: pick("reduceMotion", (v): v is boolean => typeof v === "boolean"),+ highContrast: pick("highContrast", (v): v is boolean => typeof v === "boolean"),+ };+}++export function isDefaultAppearance(prefs: AppearancePreferences): boolean {+ return (Object.keys(DEFAULT_APPEARANCE) as (keyof AppearancePreferences)[]).every((key) =>+ key === "themeOptions"+ ? Object.keys(prefs.themeOptions).length === 0+ : prefs[key] === DEFAULT_APPEARANCE[key],+ );+}++const UI_FONT_FAMILIES: Record<UiFont, string> = {+ inter: "var(--font-ui-inter)",+ system: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial',+ serif: "var(--font-ui-serif)",+ mono: "var(--font-ui-mono)",+};+const CJK_FONT_FAMILIES: Record<CjkFont, string> = {+ sans: "var(--font-cjk-sans)",+ serif: "var(--font-cjk-serif)",+ kai: "var(--font-cjk-kai)",+};++/** The CSS stack for a CJK choice; a local family falls back to the built-in sans chain. */+export function cjkFontStack(choice: CjkFontChoice): string {+ return isLocalFont(choice)+ ? `"${localFontFamily(choice)}", var(--font-cjk-sans)`+ : CJK_FONT_FAMILIES[choice];+}++export function uiFontStack(font: UiFont): string {+ return UI_FONT_FAMILIES[font];+}++const CODE_FONT_FAMILIES: Record<CodeFont, string | null> = {+ geist: null,+ jetbrains: "var(--font-code-jetbrains), var(--font-ui-mono), ui-monospace, monospace",+ system: 'ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace',+};+const ROW_HEIGHTS: Record<Density, string | null> = {+ compact: "32px",+ default: null,+ comfortable: "42px",+};+const LEADINGS: Record<ContentLeading, [string, string] | null> = {+ compact: ["1.5", "1.65"],+ default: null,+ relaxed: ["1.8", "1.95"],+};++/**+ * Mode-independent variables for `<html>`'s inline style. `null` means+ * "remove", so the theme's value or the stylesheet default applies. The font+ * variables feed the `--font-sans` stack in each app's globals.css and+ * `--font-content` in appearance.css.+ */+export function appearanceRootVariables(+ prefs: AppearancePreferences,+): Record<string, string | null> {+ const leading = LEADINGS[prefs.contentLeading];+ return {+ "--font-ui": prefs.uiFont === "inter" ? null : UI_FONT_FAMILIES[prefs.uiFont],+ "--font-cjk": prefs.uiCjkFont === "sans" ? null : cjkFontStack(prefs.uiCjkFont),+ "--font-content-latin":+ prefs.contentFont === FOLLOW_UI ? null : UI_FONT_FAMILIES[prefs.contentFont],+ "--font-content-cjk":+ prefs.contentCjkFont === FOLLOW_UI ? null : cjkFontStack(prefs.contentCjkFont),+ "--font-mono": CODE_FONT_FAMILIES[prefs.codeFont],+ "--font-scale": prefs.fontSize === DEFAULT_FONT_SIZE ? null : String(prefs.fontSize / 14),+ "--content-scale": prefs.contentSize === FOLLOW_UI ? null : String(prefs.contentSize / 14),+ "--content-leading": leading?.[0] ?? null,+ "--content-leading-cjk": leading?.[1] ?? null,+ "--issue-row-height": ROW_HEIGHTS[prefs.density],+ };+}++/** The theme to render: the chosen one, or Default when it is not a built-in theme. */+export function activeTheme(prefs: Pick<AppearancePreferences, "theme">): Theme {+ return findBuiltInTheme(prefs.theme) ?? findBuiltInTheme(DEFAULT_THEME_ID)!;+}++const BOTH_MODES = ":root:not(.dark), :root.dark";++const declare = (variables: Record<string, string>) =>+ Object.entries(variables)+ .map(([name, value]) => `${name}: ${value};`)+ .join(" ");++/**+ * What the person chose on top of the theme: its option values, contrast+ * and motion. Written after the theme's CSS, with selectors that outrank+ * `.theme-light` and `.theme-dark`, so they hold whichever theme is active.+ */+export function appearanceStylesheet(theme: Theme, prefs: AppearancePreferences): string {+ const parts: string[] = [];+ const options = themeOptionVariables(theme, prefs.themeOptions[theme.id]);+ if (Object.keys(options.light).length > 0) {+ parts.push(`:root.theme-light { ${declare(options.light)} }`, `:root.theme-dark { ${declare(options.dark)} }`);+ }+ if (prefs.highContrast) {+ const toward = (share: number) =>+ `color-mix(in oklab, var(--foreground) ${share}%, var(--page-canvas))`;+ parts.push(+ `${BOTH_MODES} { --muted-foreground: ${toward(80)}; --faint-foreground: ${toward(62)}; --border: ${toward(22)}; --surface-border: ${toward(30)}; --input: ${toward(40)}; }`,+ );+ }+ if (prefs.reduceMotion) {+ parts.push(+ "*, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }",+ );+ }+ return parts.filter(Boolean).join("\n");+}++/** The theme's own CSS. */+export function appearanceThemeCss(theme: Theme): string {+ return theme.css ?? "";+}++/** Attributes for <html>: `data-theme` and the theme's options; `null` removes one. */+export function appearanceThemeAttributes(+ theme: Theme,+ prefs: AppearancePreferences,+): Record<string, string | null> {+ if (theme.id === DEFAULT_THEME_ID) return { [APPEARANCE_THEME_ATTR]: null };+ return {+ [APPEARANCE_THEME_ATTR]: theme.id,+ ...themeOptionAttributes(theme, prefs.themeOptions[theme.id]),+ };+}++interface AppearanceState extends AppearancePreferences {+ set: (patch: Partial<AppearancePreferences>) => void;+ setThemeOption: (themeId: string, optionId: string, value: ThemeOptionValue) => void;+ reset: () => void;+}++export const useAppearanceStore = create<AppearanceState>()(+ persist(+ (set) => ({+ ...DEFAULT_APPEARANCE,+ set: (patch) => set(patch),+ setThemeOption: (themeId, optionId, value) =>+ set((state) => ({+ themeOptions: {+ ...state.themeOptions,+ [themeId]: { ...state.themeOptions[themeId], [optionId]: value },+ },+ })),+ reset: () => set(DEFAULT_APPEARANCE),+ }),+ {+ name: APPEARANCE_STORAGE_KEY,+ storage: createJSONStorage(() => defaultStorage),+ partialize: (state) => sanitizeAppearance(state),+ merge: (persisted, current) => ({ ...current, ...sanitizeAppearance(persisted) }),+ },+ ),+);++/** The saved preferences without the store's actions. */+export function selectAppearance(state: AppearanceState): AppearancePreferences {+ return {+ theme: state.theme,+ themeOptions: state.themeOptions,+ uiFont: state.uiFont,+ uiCjkFont: state.uiCjkFont,+ fontSize: state.fontSize,+ contentFont: state.contentFont,+ contentCjkFont: state.contentCjkFont,+ contentSize: state.contentSize,+ contentLeading: state.contentLeading,+ codeFont: state.codeFont,+ density: state.density,+ reduceMotion: state.reduceMotion,+ highContrast: state.highContrast,+ };+}++const SYSTEM_REDUCED_MOTION = "(prefers-reduced-motion: reduce)";++function systemReducedMotion(): boolean {+ return typeof window !== "undefined" && window.matchMedia?.(SYSTEM_REDUCED_MOTION).matches === true;+}++function subscribeSystemReducedMotion(onChange: () => void): () => void {+ const query = typeof window !== "undefined" ? window.matchMedia?.(SYSTEM_REDUCED_MOTION) : undefined;+ query?.addEventListener?.("change", onChange);+ return () => query?.removeEventListener?.("change", onChange);+}++/**+ * Whether to skip motion: the Appearance switch or the system preference.+ * For animation driven from JS; CSS durations already follow both.+ */+export function useReducedMotion(): boolean {+ const reduceMotion = useAppearanceStore((state) => state.reduceMotion);+ const system = useSyncExternalStore(subscribeSystemReducedMotion, systemReducedMotion, () => false);+ return reduceMotion || system;+}++/** `useReducedMotion` read once, for code outside render. */+export function prefersReducedMotion(): boolean {+ return useAppearanceStore.getState().reduceMotion || systemReducedMotion();+}diff --git a/packages/core/appearance/local-fonts.ts b/packages/core/appearance/local-fonts.tsnew file mode 100644index 0000000000..2acd0f1a4d--- /dev/null+++ b/packages/core/appearance/local-fonts.ts@@ -0,0 +1,95 @@+import { create } from "zustand";++/** A family installed on this device, as `local:<family name>`. */+export type LocalFont = `local:${string}`;++const LOCAL_FAMILY = /^[\p{L}\p{N} ._-]{1,64}$/u;++/** `local:<family>` with a family name that is safe to quote in CSS. */+export function isLocalFont(value: unknown): value is LocalFont {+ return (+ typeof value === "string" &&+ value.startsWith("local:") &&+ LOCAL_FAMILY.test(value.slice(6)) &&+ value.slice(6).trim() === value.slice(6)+ );+}++export function localFontFamily(choice: LocalFont): string {+ return choice.slice(6);+}++/**+ * Font families installed on this device that can draw Han characters, for+ * the CJK font pickers. Uses the Local Font Access API: available in Desktop+ * and Chromium browsers (which ask for permission), absent elsewhere. Kept+ * in a store so the scan, and its permission prompt, runs once per session.+ */++type LocalFontsStatus = "idle" | "loading" | "ready" | "unavailable" | "error";++interface LocalFontsState {+ status: LocalFontsStatus;+ families: string[];+ load: () => Promise<void>;+}++type QueryLocalFonts = () => Promise<readonly { family: string }[]>;++function queryLocalFonts(): QueryLocalFonts | null {+ if (typeof window === "undefined") return null;+ const query = (window as unknown as { queryLocalFonts?: QueryLocalFonts }).queryLocalFonts;+ return typeof query === "function" ? query.bind(window) : null;+}++const PROBE = "永字";++/**+ * Whether `family` has its own Han glyphs: drawn with it first, the probe+ * differs from the generic fallback. Checked against two fallbacks so a+ * family that is itself the default for one of them still counts.+ */+function makeHanProbe(): ((family: string) => boolean) | null {+ const canvas = document.createElement("canvas");+ canvas.width = 48;+ canvas.height = 24;+ const ctx = canvas.getContext("2d", { willReadFrequently: true });+ if (!ctx) return null;+ ctx.textBaseline = "top";+ const draw = (font: string) => {+ ctx.clearRect(0, 0, canvas.width, canvas.height);+ ctx.font = `20px ${font}`;+ ctx.fillText(PROBE, 0, 0);+ return ctx.getImageData(0, 0, canvas.width, canvas.height).data;+ };+ const same = (a: Uint8ClampedArray, b: Uint8ClampedArray) => a.every((v, i) => v === b[i]);+ const fallbacks = ["sans-serif", "serif"].map((generic) => [generic, draw(generic)] as const);+ return (family) =>+ fallbacks.some(([generic, base]) => !same(draw(`"${family}", ${generic}`), base));+}++export const useLocalCjkFonts = create<LocalFontsState>()((set, get) => ({+ status: queryLocalFonts() ? "idle" : "unavailable",+ families: [],+ load: async () => {+ const { status } = get();+ if (status === "loading" || status === "ready") return;+ const query = queryLocalFonts();+ if (!query) {+ set({ status: "unavailable" });+ return;+ }+ set({ status: "loading" });+ try {+ const fonts = await query();+ const probe = makeHanProbe();+ const families = [...new Set(fonts.map((font) => font.family))]+ .filter((family) => isLocalFont(`local:${family}`))+ .filter((family) => (probe ? probe(family) : true))+ .sort((a, b) => a.localeCompare(b));+ set({ status: "ready", families });+ } catch {+ set({ status: "error" });+ }+ },+}));diff --git a/packages/core/appearance/reduced-motion.test.ts b/packages/core/appearance/reduced-motion.test.tsnew file mode 100644index 0000000000..258ecf5b49--- /dev/null+++ b/packages/core/appearance/reduced-motion.test.ts@@ -0,0 +1,63 @@+// @vitest-environment jsdom+import { act, renderHook } from "@testing-library/react";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import { prefersReducedMotion, useAppearanceStore, useReducedMotion } from "./index";++let systemReduces = false;+const listeners = new Set<() => void>();++function setSystem(reduces: boolean) {+ systemReduces = reduces;+ for (const listener of listeners) listener();+}++beforeEach(() => {+ systemReduces = false;+ listeners.clear();+ vi.stubGlobal("matchMedia", (query: string) => ({+ get matches() {+ return query === "(prefers-reduced-motion: reduce)" && systemReduces;+ },+ media: query,+ addEventListener: (_: string, listener: () => void) => listeners.add(listener),+ removeEventListener: (_: string, listener: () => void) => listeners.delete(listener),+ }));+ useAppearanceStore.getState().reset();+});++afterEach(() => {+ vi.unstubAllGlobals();+});++describe("reduced motion", () => {+ it("follows the Appearance switch while the system allows motion", () => {+ const { result } = renderHook(() => useReducedMotion());+ expect(result.current).toBe(false);+ expect(prefersReducedMotion()).toBe(false);++ act(() => useAppearanceStore.getState().set({ reduceMotion: true }));+ expect(result.current).toBe(true);+ expect(prefersReducedMotion()).toBe(true);++ act(() => useAppearanceStore.getState().set({ reduceMotion: false }));+ expect(result.current).toBe(false);+ });++ it("follows the system setting while the Appearance switch is off", () => {+ const { result } = renderHook(() => useReducedMotion());+ act(() => setSystem(true));+ expect(result.current).toBe(true);+ expect(prefersReducedMotion()).toBe(true);++ act(() => setSystem(false));+ expect(result.current).toBe(false);+ });++ it("stays reduced while either one asks for it", () => {+ setSystem(true);+ const { result } = renderHook(() => useReducedMotion());+ act(() => useAppearanceStore.getState().set({ reduceMotion: true }));+ act(() => setSystem(false));+ expect(result.current).toBe(true);+ });+});diff --git a/packages/core/appearance/theme-variables.ts b/packages/core/appearance/theme-variables.tsnew file mode 100644index 0000000000..7593747230--- /dev/null+++ b/packages/core/appearance/theme-variables.ts@@ -0,0 +1,360 @@+/**+ * The public CSS variables a theme may set. This list is the contract:+ * docs/theming.md is generated from it, and a test checks that every+ * variable with a `default` is read in the stylesheets as+ * `var(--name, default)`, so an unset variable renders exactly as before.+ *+ * Foundation tokens (colours, fonts, the text scale, button geometry) are+ * declared in packages/ui/styles/tokens.css and appearance.css; their+ * defaults are read from there. Everything else is never declared: the+ * component reads it with a fallback, which is why a theme can set it on+ * any ancestor (`.theme-dark`, a `data-mc` anchor) and have it apply.+ *+ * Renaming or removing a variable breaks themes. Keep the old name working+ * until the next THEME_API_VERSION.+ */++export type ThemeVariableSection =+ | "colors"+ | "status"+ | "shape"+ | "typography"+ | "controls"+ | "navigation"+ | "issues"+ | "editor"+ | "code";++export interface ThemeVariable {+ /** Without the leading `--`. */+ name: string;+ section: ThemeVariableSection;+ description: string;+ /** The fallback in the stylesheet. Absent for foundation tokens. */+ default?: string;+ /** Only when dark mode falls back to something else. */+ darkDefault?: string;+ /** For the docs, when the default is composed outside the stylesheets. */+ defaultText?: string;+}++export const THEME_VARIABLE_SECTIONS: Record<ThemeVariableSection, string> = {+ colors: "Colours and surfaces",+ status: "Status and priority",+ shape: "Shape and depth",+ typography: "Typography",+ controls: "Controls and overlays",+ navigation: "Navigation and page",+ issues: "Issues",+ editor: "Editor content",+ code: "Code",+};++type Entry = readonly [name: string, description: string, def?: string, darkDef?: string];++const DEFAULT_TEXT: Record<string, string> = {+ "font-ui": "Inter, or the Appearance choice",+ "font-cjk": "system CJK sans, or the Appearance choice",+ "font-content-latin": "`--font-ui`",+ "font-content-cjk": "`--font-cjk`",+ "font-mono": "Geist Mono",+ "button-primary": "`--primary`",+ "button-primary-foreground": "`--primary-foreground`",+ "button-primary-border": "`--button-primary`",+};++function section(name: ThemeVariableSection, entries: readonly Entry[]): ThemeVariable[] {+ return entries.map(([variable, description, def, darkDef]) => ({+ name: variable,+ section: name,+ description,+ ...(def === undefined ? {} : { default: def }),+ ...(darkDef === undefined ? {} : { darkDefault: darkDef }),+ ...(DEFAULT_TEXT[variable] ? { defaultText: DEFAULT_TEXT[variable] } : {}),+ }));+}++const COLORS: Entry[] = [+ ["app-shell", "The frame around the page: rail, desktop toolbar and tab bar."],+ ["page-canvas", "The page that lists, boards and conversations sit on."],+ ["surface", "Bounded content groups: cards, board cards, panels."],+ ["surface-foreground", "Text on a surface."],+ ["surface-raised", "Menus, popovers and dialogs."],+ ["surface-hover", "Row and card hover."],+ ["surface-selected", "Selected rows and the active nav item."],+ ["surface-selected-foreground", "Text on a selected row."],+ ["surface-border", "Hairline around surfaces and the page."],+ ["background", "Shadcn alias; follows `page-canvas` unless set."],+ ["foreground", "Body text."],+ ["card", "Shadcn alias; follows `surface` unless set."],+ ["card-foreground", "Text on a card."],+ ["popover", "Shadcn alias; follows `surface-raised` unless set."],+ ["popover-foreground", "Text in menus and popovers."],+ ["primary", "Primary buttons and strong marks; also used as text."],+ ["primary-foreground", "Text on primary."],+ ["secondary", "Secondary buttons."],+ ["secondary-foreground", "Text on secondary."],+ ["muted", "Quiet fills: group headers, code blocks, skeletons."],+ ["muted-foreground", "Secondary text. Must clear 4.5:1 on every surface."],+ ["faint-foreground", "Marks that are not text: chevrons, separators, empty-state icons."],+ ["accent", "Hover fill in menus and lists."],+ ["accent-foreground", "Text on accent."],+ ["border", "Dividers and table borders."],+ ["input", "Input borders."],+ ["ring", "Focus ring."],+ ["sidebar", "Sidebar background (shadcn sidebar)."],+ ["sidebar-foreground", "Sidebar text."],+ ["sidebar-primary", "Sidebar primary marks."],+ ["sidebar-primary-foreground", "Text on sidebar primary."],+ ["sidebar-accent", "Rail hover and active fill."],+ ["sidebar-accent-foreground", "Text on sidebar accent."],+ ["sidebar-border", "Sidebar borders."],+ ["sidebar-ring", "Sidebar focus ring."],+ ["brand", "Product colour: links, checkboxes, selection highlights."],+ ["brand-foreground", "Text on brand."],+ ["button-primary", "Primary button fill when it should differ from `primary`."],+ ["button-primary-foreground", "Primary button text."],+ ["button-primary-border", "Primary button border."],+ ["destructive", "Errors and destructive actions."],+ ["success", "Success states."],+ ["warning", "Warnings."],+ ["info", "Informational marks."],+ ["chart-1", "First chart series."],+ ["chart-2", "Second chart series."],+ ["chart-3", "Third chart series."],+ ["chart-4", "Fourth chart series."],+ ["chart-5", "Fifth chart series."],+ ["find-match", "In-page find match."],+ ["find-match-active", "The current find match."],+ ["find-match-foreground", "Text on a find match."],+ ["scrollbar-track", "Scrollbar track."],+ ["scrollbar-thumb", "Scrollbar thumb."],+ ["scrollbar-thumb-hover", "Scrollbar thumb on hover."],+];++const STATUS: Entry[] = [+ ["status-backlog", "Backlog status icon.", "var(--muted-foreground)"],+ ["status-todo", "Todo status icon.", "var(--muted-foreground)"],+ ["status-in-progress", "In progress status icon.", "var(--warning)"],+ ["status-in-review", "In review status icon.", "var(--success)"],+ ["status-done", "Done status icon.", "var(--info)"],+ ["status-blocked", "Blocked status icon.", "var(--destructive)"],+ ["status-cancelled", "Cancelled status icon.", "var(--muted-foreground)"],+ ["priority-urgent", "Urgent priority icon and badge.", "var(--destructive)"],+ ["priority-high", "High priority icon and badge."],+ ["priority-medium", "Medium priority icon and badge.", "var(--warning)"],+ ["priority-low", "Low priority icon and badge.", "var(--info)"],+ ["priority-none", "No-priority icon.", "var(--muted-foreground)"],+];++const SHAPE: Entry[] = [+ ["radius", "Base corner radius. Every `rounded-*` step and component radius below derives from it."],+ ["surface-shadow", "Resting shadow of cards and the page."],+ ["floating-shadow", "Dialogs and sheets."],+ ["menu-shadow", "Menus, selects and popovers."],+ ["tooltip", "Tooltip fill (dark in both modes)."],+ ["tooltip-shadow", "Tooltip shadow."],+ ["icon-stroke-width", "Stroke width of line icons.", "2"],+];++const TYPOGRAPHY: Entry[] = [+ ["font-ui", "Interface font. The Appearance page's choice wins over a theme's."],+ ["font-cjk", "Interface font for Chinese, Japanese and Korean."],+ ["font-content-latin", "Font for issue descriptions, comments, chat and documents."],+ ["font-content-cjk", "CJK font for that content."],+ ["font-mono", "Code font."],+ ["content-leading", "Line height of content paragraphs.", "1.625"],+ ["content-leading-cjk", "Line height of CJK content paragraphs.", "1.75"],+ ["text-micro", "Counters, badges, timestamps."],+ ["text-micro--line-height", "Line height of `text-micro`."],+ ["text-caption", "Chips, hints, tooltips, issue identifiers."],+ ["text-caption--line-height", "Line height of `text-caption`."],+ ["text-label", "Metadata rows, table headers, activity."],+ ["text-label--line-height", "Line height of `text-label`."],+ ["text-body", "Interface body text."],+ ["text-body--line-height", "Line height of `text-body`."],+ ["text-body-lg", "Dialog copy, onboarding prose."],+ ["text-body-lg--line-height", "Line height of `text-body-lg`."],+ ["text-title-sm", "Small headings."],+ ["text-title-sm--line-height", "Line height of `text-title-sm`."],+ ["text-title", "Section headings."],+ ["text-title--line-height", "Line height of `text-title`."],+ ["text-title-lg", "Card and dialog titles."],+ ["text-title-lg--line-height", "Line height of `text-title-lg`."],+ ["text-display-sm", "Page titles."],+ ["text-display-sm--line-height", "Line height of `text-display-sm`."],+ ["text-display", "Hero numbers and empty-state headlines."],+ ["text-display--line-height", "Line height of `text-display`."],+];++const CONTROLS: Entry[] = [+ ["button-radius", "Button corners.", "var(--radius)"],+ ["button-radius-sm", "Corners of extra-small and small buttons.", "calc(var(--radius) * 0.75)"],+ ["button-height-xs", "Extra-small button height."],+ ["button-height-sm", "Small button height."],+ ["button-height-default", "Default button height."],+ ["button-height-lg", "Large button height."],+ ["button-padding-xs", "Extra-small button side padding."],+ ["button-padding-sm", "Small button side padding."],+ ["button-padding-default", "Default button side padding."],+ ["button-padding-lg", "Large button side padding."],+ ["button-gap-xs", "Icon gap in extra-small buttons."],+ ["button-gap-sm", "Icon gap in small buttons."],+ ["button-gap-default", "Icon gap in default buttons."],+ ["button-gap-lg", "Icon gap in large buttons."],+ ["input-radius", "Inputs, textareas and select triggers.", "var(--radius)"],+ ["card-radius", "Cards.", "calc(var(--radius) * 1.5)"],+ ["menu-radius", "Dropdown, context and select menus.", "calc(var(--radius) * 1.5)"],+ ["menu-item-radius", "Items inside a menu.", "calc(var(--radius) * 0.75)"],+ ["menu-item-hover-background", "Highlighted menu item.", "var(--accent)"],+ ["menu-item-hover-color", "Text of the highlighted menu item.", "var(--accent-foreground)"],+ ["popover-radius", "Popovers.", "var(--radius)"],+ ["dialog-radius", "Dialogs and alert dialogs.", "calc(var(--radius) * 1.5)"],+ ["tooltip-radius", "Tooltips.", "var(--radius)"],+ ["avatar-radius", "Avatars. Set a length for square avatars.", "calc(infinity * 1px)"],+ ["label-radius", "Issue label chips.", "calc(infinity * 1px)"],+];++const NAVIGATION: Entry[] = [+ ["page-radius", "Corners of the page card inside the frame.", "calc(var(--radius) * 1.5)"],+ ["page-border-color", "Hairline around the page card.", "var(--surface-border)"],+ ["page-shadow", "Shadow of the page card.", "var(--surface-shadow)"],+ ["rail-item-radius", "Space buttons in the rail.", "calc(var(--radius) * 1.5)"],+ ["rail-item-color", "Rail button icon and label.", "var(--muted-foreground)"],+ ["rail-item-hover-background", "Rail button hover.", "color-mix(in oklab, var(--sidebar-accent) 60%, transparent)"],+ ["rail-item-active-background", "The current space.", "var(--sidebar-accent)"],+ ["rail-item-active-color", "Icon and label of the current space.", "var(--sidebar-accent-foreground)"],+ ["nav-item-height", "Minimum height of a row in the space panel.", "2rem"],+ ["nav-item-radius", "Rows in the space panel.", "var(--radius)"],+ ["nav-item-color", "Row text.", "var(--muted-foreground)"],+ ["nav-item-hover-background", "Row hover.", "var(--surface-hover)"],+ ["nav-item-hover-color", "Row text on hover.", "var(--foreground)"],+ ["nav-item-active-background", "The current row.", "var(--surface-selected)"],+ ["nav-item-active-color", "Text of the current row.", "var(--surface-selected-foreground)"],+];++const ISSUES: Entry[] = [+ ["issue-row-height", "Height of a row in the issue list."],+ ["issue-row-padding-x", "Side padding of an issue row.", "1rem"],+ ["issue-row-hover-background", "Issue row hover.", "var(--surface-hover)"],+ ["issue-row-selected-background", "Selected issue row.", "var(--surface-selected)"],+ ["issue-row-identifier-color", "Issue identifier (MUL-123) in a row.", "var(--muted-foreground)"],+ ["issue-group-header-height", "Status group header in the list.", "2.5rem"],+ ["issue-group-header-radius", "Corners of a group header.", "var(--radius)"],+ ["issue-group-header-background", "Group header fill.", "var(--muted)"],+ ["issue-group-header-hover-background", "Group header hover.", "var(--accent)"],+ ["board-column-radius", "Board columns.", "calc(var(--radius) * 1.5)"],+ ["board-column-background", "Board column fill.", "color-mix(in oklab, var(--muted) 40%, transparent)"],+ ["board-card-radius", "Board cards.", "var(--radius)"],+ ["board-card-background", "Board card fill.", "var(--surface)"],+ ["board-card-hover-background", "Board card hover.", "var(--surface-hover)"],+ ["board-card-border-color", "Board card border.", "var(--surface-border)"],+ ["board-card-shadow", "Board card shadow.", "var(--surface-shadow)"],+];++const HEADING_SIZES = [+ "var(--text-display-sm)",+ "var(--text-title)",+ "var(--text-body-lg)",+ "var(--text-body)",+ "var(--text-label)",+ "var(--text-caption)",+];+const HEADING_LEADING = ["1.3", "1.35", "1.4", "1.45", "1.5", "1.5"];++const HEADINGS: Entry[] = HEADING_SIZES.flatMap((size, index): Entry[] => {+ const level = index + 1;+ const h = `h${level}`;+ return [+ [`${h}-font`, `Font of level ${level} headings.`, "var(--font-content)"],+ [`${h}-size`, `Size of level ${level} headings.`, size],+ [`${h}-weight`, `Weight of level ${level} headings.`, "600"],+ [`${h}-style`, `\`italic\` for italic level ${level} headings.`, "normal"],+ [`${h}-variant`, `\`small-caps\` and other font variants.`, "normal"],+ [`${h}-letter-spacing`, `Tracking of level ${level} headings.`, "normal"],+ [`${h}-line-height`, `Line height of level ${level} headings.`, HEADING_LEADING[index]],+ [`${h}-color`, `Colour of level ${level} headings.`, level === 6 ? "var(--muted-foreground)" : "currentColor"],+ ];+});++const EDITOR: Entry[] = [+ ...HEADINGS,+ ["paragraph-spacing", "Space above and below paragraphs.", "0.625rem"],+ ["list-indent", "Indent of bulleted lists.", "1.25rem"],+ ["list-indent-ordered", "Indent of numbered lists.", "1.5rem"],+ ["list-item-spacing", "Space between list items.", "0.25rem"],+ ["list-marker-color", "Bullets and numbers.", "var(--muted-foreground)"],+ ["checkbox-size", "Task list checkboxes.", "0.95rem"],+ ["checkbox-color", "Checked checkbox fill.", "var(--brand)"],+ ["checklist-done-color", "Text of a completed task.", "var(--muted-foreground)"],+ ["link-color", "Links in content.", "var(--brand)"],+ ["link-decoration", "`underline` or `none`.", "underline"],+ ["link-decoration-color", "Link underline.", "color-mix(in srgb, var(--brand) 40%, transparent)"],+ ["link-decoration-color-hover", "Link underline on hover.", "var(--brand)"],+ ["link-underline-offset", "Gap between text and underline.", "2px"],+ ["mention-color", "@mentions.", "var(--primary)"],+ ["mention-weight", "Weight of @mentions.", "600"],+ ["bold-weight", "Bold text.", "600"],+ ["bold-color", "Colour of bold text.", "currentColor"],+ ["italic-color", "Colour of italic text.", "currentColor"],+ ["strikethrough-color", "Colour of struck-through text.", "var(--muted-foreground)"],+ ["highlight-background", "`==highlighted==` text.", "color-mix(in srgb, #facc15 45%, transparent)"],+ ["highlight-radius", "Corners of highlighted text.", "0.2em"],+ ["blockquote-border-width", "Quote bar width.", "3px"],+ ["blockquote-border-color", "Quote bar colour.", "color-mix(in srgb, var(--muted-foreground) 30%, transparent)"],+ ["blockquote-padding", "Space between the bar and the text.", "0.75rem"],+ ["blockquote-color", "Quote text.", "var(--muted-foreground)"],+ ["blockquote-background", "Quote fill.", "transparent"],+ ["blockquote-style", "`italic` or `normal`.", "italic"],+ ["hr-color", "Horizontal rules.", "var(--border)"],+ ["hr-thickness", "Horizontal rule thickness.", "1px"],+ ["table-border-width", "Table borders.", "1px"],+ ["table-border-color", "Table border colour.", "var(--border)"],+ ["table-radius", "Table corners.", "var(--radius)"],+ ["table-header-background", "Header row fill.", "color-mix(in srgb, var(--muted) 50%, transparent)"],+ ["table-header-color", "Header text.", "var(--muted-foreground)"],+ ["table-header-weight", "Header weight.", "500"],+ ["table-row-hover-background", "Row hover.", "color-mix(in srgb, var(--muted) 30%, transparent)"],+ ["table-cell-padding", "Cell padding.", "0.5rem 0.75rem"],+];++const CODE: Entry[] = [+ ["code-font-size", "Inline code size.", "var(--text-body)"],+ ["code-background", "Inline code fill.", "color-mix(in srgb, var(--foreground) 3%, transparent)"],+ ["code-border-color", "Inline code border.", "color-mix(in srgb, var(--foreground) 5%, transparent)"],+ ["code-color", "Inline code text.", "color-mix(in srgb, var(--foreground) 75%, transparent)"],+ ["code-padding", "Inline code padding.", "0.125rem 0.375rem"],+ ["code-radius", "Inline code corners.", "var(--radius-sm)"],+ ["code-block-background", "Code block fill.", "var(--muted)"],+ ["code-block-border", "Code block border, e.g. `1px solid var(--border)`.", "none"],+ ["code-block-radius", "Code block corners.", "var(--radius)"],+ ["code-block-padding", "Code block padding.", "0.75rem 1rem"],+ ["code-block-color", "Code block text.", "var(--foreground)"],+ ["code-block-font-size", "Code block size.", "var(--text-label)"],+ ["code-block-line-height", "Code block line height.", "1.6"],+ ["code-keyword", "Keywords and built-ins.", "oklch(0.55 0.16 255)", "oklch(0.7 0.14 255)"],+ ["code-string", "Strings and added lines.", "oklch(0.55 0.14 155)", "oklch(0.7 0.14 155)"],+ ["code-comment", "Comments.", "var(--muted-foreground)"],+ ["code-number", "Numbers and literals.", "oklch(0.58 0.16 30)", "oklch(0.72 0.14 30)"],+ ["code-function", "Function and section names.", "oklch(0.55 0.14 280)", "oklch(0.72 0.12 280)"],+ ["code-property", "Attributes and properties.", "oklch(0.58 0.12 60)", "oklch(0.72 0.1 60)"],+ ["code-variable", "Variables.", "oklch(0.58 0.14 20)", "oklch(0.72 0.12 20)"],+ ["code-type", "Types and classes.", "oklch(0.55 0.14 200)", "oklch(0.72 0.12 200)"],+ ["code-deletion", "Removed lines.", "oklch(0.55 0.2 25)", "oklch(0.7 0.18 25)"],+ ["code-tag", "HTML and XML element names.", "oklch(0.55 0.16 255)", "oklch(0.72 0.14 255)"],+ ["code-punctuation", "HTML and XML brackets.", "var(--muted-foreground)"],+];++export const THEME_VARIABLES: readonly ThemeVariable[] = [+ ...section("colors", COLORS),+ ...section("status", STATUS),+ ...section("shape", SHAPE),+ ...section("typography", TYPOGRAPHY),+ ...section("controls", CONTROLS),+ ...section("navigation", NAVIGATION),+ ...section("issues", ISSUES),+ ...section("editor", EDITOR),+ ...section("code", CODE),+];++export const THEME_VARIABLE_NAMES: ReadonlySet<string> = new Set(THEME_VARIABLES.map((v) => v.name));diff --git a/packages/core/appearance/themes.ts b/packages/core/appearance/themes.tsnew file mode 100644index 0000000000..a010afbb76--- /dev/null+++ b/packages/core/appearance/themes.ts@@ -0,0 +1,270 @@+/**+ * A theme is a manifest that names it and declares its options, plus CSS that+ * overrides the public variables (./theme-variables) under `.theme-light` and+ * `.theme-dark` and may restyle the public anchors (./anchors).+ *+ * Only the built-in themes (./built-in-themes) exist for now. They are written+ * as token tables so the contrast test can read them, and compiled to that+ * CSS. docs/theming.md is the reference; keep it in step with this file.+ */++/** Bumped only for changes that would break existing themes. */+export const THEME_API_VERSION = 1;++/** Text a theme shows on the Appearance page: one string, or one per locale. */+export type LocalizedText = string | Readonly<Record<string, string>>;++/**+ * Options a theme declares in its manifest, rendered on the Appearance page+ * (the types follow Obsidian's Style Settings). `toggle` and `select` become+ * `data-theme-option-<id>` on <html>; the others set the variable `--<id>`+ * for both modes, or per mode for `color`.+ */+interface ThemeOptionBase {+ id: string;+ label: LocalizedText;+ description?: LocalizedText;+}++/** Starts a group of options. */+export interface ThemeHeadingOption extends ThemeOptionBase {+ type: "heading";+}++/** On: the attribute is present with the value `on`. Off: it is absent. */+export interface ThemeToggleOption extends ThemeOptionBase {+ type: "toggle";+ default: boolean;+}++/** The attribute carries the chosen value. */+export interface ThemeSelectOption extends ThemeOptionBase {+ type: "select";+ default: string;+ choices: readonly { value: string; label: LocalizedText; swatch?: string }[];+}++/** A hex colour per mode. */+export interface ThemeColorOption extends ThemeOptionBase {+ type: "color";+ default: ThemedColor;+}++/** `slider` needs `min` and `max`; the value is written with `unit` appended. */+export interface ThemeNumberOption extends ThemeOptionBase {+ type: "number" | "slider";+ default: number;+ min?: number;+ max?: number;+ step?: number;+ unit?: string;+}++/** Free text: a CSS value for `text`, a font stack for `font`. */+export interface ThemeTextOption extends ThemeOptionBase {+ type: "text" | "font";+ default: string;+}++/** A choice between CSS values. */+export interface ThemeVariableSelectOption extends ThemeOptionBase {+ type: "variable-select";+ default: string;+ choices: readonly { value: string; label: LocalizedText }[];+}++export type ThemeOption =+ | ThemeHeadingOption+ | ThemeToggleOption+ | ThemeSelectOption+ | ThemeColorOption+ | ThemeNumberOption+ | ThemeTextOption+ | ThemeVariableSelectOption;++export interface ThemedColor {+ light: string;+ dark: string;+}++/** manifest.json */+export interface ThemeManifest {+ apiVersion: typeof THEME_API_VERSION;+ id: string;+ name: string;+ /** Who made it; built-in themes name the product they follow. */+ author?: string;+ version?: string;+ description?: string;+ options?: readonly ThemeOption[];+}++/** A theme ready to apply: its manifest and CSS. */+export interface Theme extends ThemeManifest {+ css: string;+}++/** Variable name (without `--`) to value. */+export type ThemeTokens = Readonly<Record<string, string>>;++export interface BuiltInTheme extends Theme {+ tokens: { light: ThemeTokens; dark: ThemeTokens };+ /** Tokens for what sits on the frame: the rail, desktop toolbar and tab bar. */+ frame?: { light?: ThemeTokens; dark?: ThemeTokens };+}++const FRAME_ANCHORS = ':is([data-mc="app-rail"], [data-mc="window-toolbar"], [data-mc="tab-bar"])';++function declarations(tokens: ThemeTokens | undefined): string {+ return Object.entries(tokens ?? {})+ .map(([name, value]) => `--${name}: ${value};`)+ .join(" ");+}++/** The CSS a token table stands for. */+export function themeTokensCss(theme: Pick<BuiltInTheme, "tokens" | "frame">): string {+ const blocks: string[] = [];+ const add = (selector: string, body: string) => {+ if (body) blocks.push(`${selector} { ${body} }`);+ };+ add(".theme-light", declarations(theme.tokens.light));+ add(".theme-dark", declarations(theme.tokens.dark));+ add(`.theme-light ${FRAME_ANCHORS}`, declarations(theme.frame?.light));+ add(`.theme-dark ${FRAME_ANCHORS}`, declarations(theme.frame?.dark));+ return blocks.join("\n");+}++const SAFE_VALUE = /^[\w\s#.,%()/+-]+$/;+const UNSAFE_FUNCTION = /\b(url|image|image-set|cross-fade|element|expression|attr|env|src)\s*\(/i;++/** A token value a theme may set: colours, lengths, shadows and var() references only. */+export function isSafeThemeValue(value: unknown): value is string {+ return (+ typeof value === "string" &&+ value.length > 0 &&+ value.length <= 200 &&+ SAFE_VALUE.test(value) &&+ !UNSAFE_FUNCTION.test(value)+ );+}++const FONT_VAR = /var\(--[a-z0-9-]+\)/g;+const SAFE_FONT_VALUE = /^[\p{L}\p{N} "',._-]+$/u;++/** A font stack: family names, quoted or not, and var() references to other stacks. */+export function isSafeFontValue(value: unknown): value is string {+ if (typeof value !== "string" || value.length === 0 || value.length > 300) return false;+ const rest = value.replace(FONT_VAR, "x");+ return SAFE_FONT_VALUE.test(rest) && (rest.split('"').length - 1) % 2 === 0 && (rest.split("'").length - 1) % 2 === 0;+}++const MODE_SELECTOR = /^(?::root|html)?\.theme-(light|dark)$/;++/**+ * The variables a theme sets directly on `.theme-light` and `.theme-dark`,+ * for previews. Only values that would pass as a token are returned.+ */+export function themeModeVariables(css: string): { light: Record<string, string>; dark: Record<string, string> } {+ const out = { light: {} as Record<string, string>, dark: {} as Record<string, string> };+ const clean = css.replace(/\/\*[\s\S]*?\*\//g, "");+ for (const rule of clean.matchAll(/([^{}]+)\{([^{}]*)\}/g)) {+ const modes = rule[1]!+ .split(",")+ .map((selector) => MODE_SELECTOR.exec(selector.trim())?.[1] as "light" | "dark" | undefined)+ .filter((mode) => mode !== undefined);+ for (const declaration of rule[2]!.matchAll(/--([a-z0-9-]+)\s*:\s*([^;]+)/gi)) {+ const value = declaration[2]!.trim();+ if (!isSafeThemeValue(value)) continue;+ for (const mode of modes) out[mode][declaration[1]!] = value;+ }+ }+ return out;+}++export const THEME_OPTION_ATTR_PREFIX = "data-theme-option-";++export type ThemeOptionValue = string | boolean | number | Readonly<Partial<ThemedColor>>;+export type ThemeOptionValues = Readonly<Record<string, ThemeOptionValue>>;++export const HEX_COLOR = /^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i;++/** The value an option has: the person's choice when it is still valid, else the default. */+export function themeOptionValue(option: ThemeOption, chosen: unknown): ThemeOptionValue {+ switch (option.type) {+ case "heading":+ return "";+ case "toggle":+ return typeof chosen === "boolean" ? chosen : option.default;+ case "select":+ case "variable-select":+ return typeof chosen === "string" && option.choices.some((c) => c.value === chosen) ? chosen : option.default;+ case "color": {+ const pick = (mode: keyof ThemedColor) => {+ const value = chosen && typeof chosen === "object" ? (chosen as Partial<ThemedColor>)[mode] : undefined;+ return typeof value === "string" && HEX_COLOR.test(value) ? value : option.default[mode];+ };+ return { light: pick("light"), dark: pick("dark") };+ }+ case "number":+ case "slider": {+ if (typeof chosen !== "number" || !Number.isFinite(chosen)) return option.default;+ return Math.min(option.max ?? Infinity, Math.max(option.min ?? -Infinity, chosen));+ }+ case "text":+ return isSafeThemeValue(chosen) ? chosen : option.default;+ case "font":+ return isSafeFontValue(chosen) ? chosen : option.default;+ }+}++/** The variables the theme's options set, per mode. */+export function themeOptionVariables(+ theme: ThemeManifest,+ chosen: ThemeOptionValues | undefined,+): { light: Record<string, string>; dark: Record<string, string> } {+ const out = { light: {} as Record<string, string>, dark: {} as Record<string, string> };+ for (const option of theme.options ?? []) {+ const name = `--${option.id}`;+ const value = themeOptionValue(option, chosen?.[option.id]);+ if (option.type === "color") {+ const color = value as ThemedColor;+ out.light[name] = color.light;+ out.dark[name] = color.dark;+ } else if (option.type === "number" || option.type === "slider") {+ out.light[name] = out.dark[name] = `${value}${option.unit ?? ""}`;+ } else if (option.type === "text" || option.type === "font" || option.type === "variable-select") {+ out.light[name] = out.dark[name] = value as string;+ }+ }+ return out;+}++/** `data-theme-option-*` attributes for <html>; `null` means absent. */+export function themeOptionAttributes(+ theme: ThemeManifest,+ chosen: ThemeOptionValues | undefined,+): Record<string, string | null> {+ const attributes: Record<string, string | null> = {};+ for (const option of theme.options ?? []) {+ if (option.type !== "toggle" && option.type !== "select") continue;+ const value = themeOptionValue(option, chosen?.[option.id]);+ attributes[`${THEME_OPTION_ATTR_PREFIX}${option.id}`] =+ value === true ? "on" : value === false ? null : String(value);+ }+ return attributes;+}++/** Picks the text for `locale`: exact match, then its language, then English, then any. */+export function localizedText(text: LocalizedText | undefined, locale: string): string {+ if (text === undefined) return "";+ if (typeof text === "string") return text;+ const language = locale.split("-")[0] ?? locale;+ return (+ text[locale] ??+ text[language] ??+ Object.entries(text).find(([key]) => key.startsWith(`${language}-`))?.[1] ??+ text.en ??+ Object.values(text)[0] ??+ ""+ );+}diff --git a/packages/core/issues/config/priority.ts b/packages/core/issues/config/priority.tsindex f0b5910bcf..61d6778d8f 100644--- a/packages/core/issues/config/priority.ts+++ b/packages/core/issues/config/priority.ts@@ -33,9 +33,9 @@ export const PRIORITY_CONFIG: Record<IssuePriority,{ label: string; bars: number; color: string; badgeBg: string; badgeText: string }> = {- urgent: { label: "Urgent", bars: 4, color: "text-destructive", badgeBg: "bg-destructive/10", badgeText: "text-destructive" },+ urgent: { label: "Urgent", bars: 4, color: "text-priority-urgent", badgeBg: "bg-priority-urgent/10", badgeText: "text-priority-urgent" },high: { label: "High", bars: 3, color: "text-priority-high", badgeBg: "bg-priority-high/10", badgeText: "text-priority-high" },- medium: { label: "Medium", bars: 2, color: "text-warning", badgeBg: "bg-warning/10", badgeText: "text-warning" },- low: { label: "Low", bars: 1, color: "text-info", badgeBg: "bg-info/10", badgeText: "text-info" },- none: { label: "No priority", bars: 0, color: "text-muted-foreground", badgeBg: "bg-muted", badgeText: "text-muted-foreground" },+ medium: { label: "Medium", bars: 2, color: "text-priority-medium", badgeBg: "bg-priority-medium/10", badgeText: "text-priority-medium" },+ low: { label: "Low", bars: 1, color: "text-priority-low", badgeBg: "bg-priority-low/10", badgeText: "text-priority-low" },+ none: { label: "No priority", bars: 0, color: "text-priority-none", badgeBg: "bg-muted", badgeText: "text-priority-none" },};diff --git a/packages/core/package.json b/packages/core/package.jsonindex 8748221238..d5fe9116c4 100644--- a/packages/core/package.json+++ b/packages/core/package.json@@ -17,6 +17,7 @@"./attachments/deliverables": "./attachments/deliverables.ts","./attachments/image-sequence": "./attachments/image-sequence.ts","./api": "./api/index.ts",+ "./appearance": "./appearance/index.ts","./api/client": "./api/client.ts","./api/schema": "./api/schema.ts","./api/schemas": "./api/schemas.ts",diff --git a/packages/eslint-config/base.js b/packages/eslint-config/base.jsindex 59fb66a34d..d6eb38f57a 100644--- a/packages/eslint-config/base.js+++ b/packages/eslint-config/base.js@@ -24,6 +24,14 @@ export const ICON_LIBRARY_IMPORT_PATTERNS = [},];+// motion's hook reads only the system setting; the core one also honours the+// Appearance page's Reduce motion switch.+export const REDUCED_MOTION_IMPORT = {+ name: "motion/react",+ importNames: ["useReducedMotion"],+ message: "Use useReducedMotion from @multica/core/appearance: it also honours the Appearance setting.",+};+/** @type {import("eslint").Linter.Config[]} */export default [eslint.configs.recommended,@@ -55,6 +63,7 @@ export default [peerDependencies: true,}],"no-restricted-imports": ["error", {+ paths: [REDUCED_MOTION_IMPORT],patterns: ICON_LIBRARY_IMPORT_PATTERNS,}],},diff --git a/packages/ui/components/ui/alert-dialog.tsx b/packages/ui/components/ui/alert-dialog.tsxindex f91b67c4ea..4797b74e57 100644--- a/packages/ui/components/ui/alert-dialog.tsx+++ b/packages/ui/components/ui/alert-dialog.tsx@@ -52,7 +52,7 @@ function AlertDialogContent({data-slot="alert-dialog-content"data-size={size}className={cn(- "group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full grid-cols-1 -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-surface-raised p-4 text-popover-foreground shadow-[var(--floating-shadow)] ring-1 ring-surface-border duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",+ "group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full grid-cols-1 -translate-x-1/2 -translate-y-1/2 gap-4 rounded-dialog bg-surface-raised p-4 text-popover-foreground shadow-[var(--floating-shadow)] ring-1 ring-surface-border duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",className)}{...props}diff --git a/packages/ui/components/ui/avatar.tsx b/packages/ui/components/ui/avatar.tsxindex c6eabdd776..a99d53aa4b 100644--- a/packages/ui/components/ui/avatar.tsx+++ b/packages/ui/components/ui/avatar.tsx@@ -17,7 +17,7 @@ function Avatar({data-slot="avatar"data-size={size}className={cn(- "group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten",+ "group/avatar relative flex size-8 shrink-0 rounded-avatar select-none after:absolute after:inset-0 after:rounded-avatar after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten",className)}{...props}@@ -30,7 +30,7 @@ function AvatarImage({ className, ...props }: AvatarPrimitive.Image.Props) {<AvatarPrimitive.Imagedata-slot="avatar-image"className={cn(- "aspect-square size-full rounded-full object-cover",+ "aspect-square size-full rounded-avatar object-cover",className)}{...props}@@ -46,7 +46,7 @@ function AvatarFallback({<AvatarPrimitive.Fallbackdata-slot="avatar-fallback"className={cn(- "flex size-full items-center justify-center rounded-full bg-muted text-body text-muted-foreground group-data-[size=sm]/avatar:text-caption",+ "flex size-full items-center justify-center rounded-avatar bg-muted text-body text-muted-foreground group-data-[size=sm]/avatar:text-caption",className)}{...props}@@ -59,7 +59,7 @@ function AvatarBadge({ className, ...props }: React.ComponentProps<"span">) {<spandata-slot="avatar-badge"className={cn(- "absolute right-0 bottom-0 z-10 inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground bg-blend-color ring-2 ring-background select-none",+ "absolute right-0 bottom-0 z-10 inline-flex items-center justify-center rounded-avatar bg-primary text-primary-foreground bg-blend-color ring-2 ring-background select-none","group-data-[size=sm]/avatar:size-2 group-data-[size=sm]/avatar:[&>svg]:hidden","group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2","group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2",@@ -91,7 +91,7 @@ function AvatarGroupCount({<divdata-slot="avatar-group-count"className={cn(- "relative flex size-8 shrink-0 items-center justify-center rounded-full bg-muted text-body text-muted-foreground ring-2 ring-background group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3",+ "relative flex size-8 shrink-0 items-center justify-center rounded-avatar bg-muted text-body text-muted-foreground ring-2 ring-background group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3",className)}{...props}diff --git a/packages/ui/components/ui/button.tsx b/packages/ui/components/ui/button.tsxindex 2e280d144a..4170c4082d 100644--- a/packages/ui/components/ui/button.tsx+++ b/packages/ui/components/ui/button.tsx@@ -6,7 +6,7 @@ import { cva, type VariantProps } from "class-variance-authority"import { cn } from "@multica/ui/lib/utils"const buttonVariants = cva(- "group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-body font-medium whitespace-nowrap transition-[color,background-color,border-color,box-shadow,transform] outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4.5",+ "group/button inline-flex shrink-0 items-center justify-center rounded-button border border-transparent bg-clip-padding text-body font-medium whitespace-nowrap transition-[color,background-color,border-color,box-shadow,transform] outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4.5",{variants: {variant: {@@ -45,14 +45,14 @@ const buttonVariants = cva(size: {default:"h-[var(--button-height-default)] gap-[var(--button-gap-default)] px-[var(--button-padding-default)] has-data-[icon=inline-end]:pr-[max(0px,calc(var(--button-padding-default)-0.125rem))] has-data-[icon=inline-start]:pl-[max(0px,calc(var(--button-padding-default)-0.125rem))]",- xs: "h-[var(--button-height-xs)] gap-[var(--button-gap-xs)] rounded-md px-[var(--button-padding-xs)] text-caption in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-[max(0px,calc(var(--button-padding-xs)-0.125rem))] has-data-[icon=inline-start]:pl-[max(0px,calc(var(--button-padding-xs)-0.125rem))] [&_svg:not([class*='size-'])]:size-3.5",- sm: "h-[var(--button-height-sm)] gap-[var(--button-gap-sm)] rounded-md px-[var(--button-padding-sm)] text-label in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-[max(0px,calc(var(--button-padding-sm)-0.25rem))] has-data-[icon=inline-start]:pl-[max(0px,calc(var(--button-padding-sm)-0.25rem))] [&_svg:not([class*='size-'])]:size-4",+ xs: "h-[var(--button-height-xs)] gap-[var(--button-gap-xs)] rounded-button-sm px-[var(--button-padding-xs)] text-caption in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-[max(0px,calc(var(--button-padding-xs)-0.125rem))] has-data-[icon=inline-start]:pl-[max(0px,calc(var(--button-padding-xs)-0.125rem))] [&_svg:not([class*='size-'])]:size-3.5",+ sm: "h-[var(--button-height-sm)] gap-[var(--button-gap-sm)] rounded-button-sm px-[var(--button-padding-sm)] text-label in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-[max(0px,calc(var(--button-padding-sm)-0.25rem))] has-data-[icon=inline-start]:pl-[max(0px,calc(var(--button-padding-sm)-0.25rem))] [&_svg:not([class*='size-'])]:size-4",lg: "h-[var(--button-height-lg)] gap-[var(--button-gap-lg)] px-[var(--button-padding-lg)] has-data-[icon=inline-end]:pr-[calc(var(--button-padding-lg)+0.125rem)] has-data-[icon=inline-start]:pl-[calc(var(--button-padding-lg)+0.125rem)]",icon: "size-[var(--button-height-default)]","icon-xs":- "size-[var(--button-height-xs)] rounded-md in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",+ "size-[var(--button-height-xs)] rounded-button-sm in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3","icon-sm":- "size-[var(--button-height-sm)] rounded-md in-data-[slot=button-group]:rounded-lg",+ "size-[var(--button-height-sm)] rounded-button-sm in-data-[slot=button-group]:rounded-lg","icon-lg": "size-[var(--button-height-lg)]",},},@@ -72,6 +72,7 @@ function Button({return (<ButtonPrimitivedata-slot="button"+ data-variant={variant}className={cn(buttonVariants({ variant, size, className }))}{...props}/>diff --git a/packages/ui/components/ui/card.tsx b/packages/ui/components/ui/card.tsxindex a68c9799fa..c69f515a1f 100644--- a/packages/ui/components/ui/card.tsx+++ b/packages/ui/components/ui/card.tsx@@ -12,7 +12,7 @@ function Card({data-slot="card"data-size={size}className={cn(- "group/card flex flex-col gap-4 overflow-hidden rounded-xl border border-surface-border bg-surface py-4 text-body text-surface-foreground shadow-[var(--surface-shadow)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:rounded-lg data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl data-[size=sm]:*:[img:first-child]:rounded-t-lg data-[size=sm]:*:[img:last-child]:rounded-b-lg",+ "group/card flex flex-col gap-4 overflow-hidden rounded-card border border-surface-border bg-surface py-4 text-body text-surface-foreground shadow-[var(--surface-shadow)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:rounded-lg data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl data-[size=sm]:*:[img:first-child]:rounded-t-lg data-[size=sm]:*:[img:last-child]:rounded-b-lg",className)}{...props}diff --git a/packages/ui/components/ui/context-menu.tsx b/packages/ui/components/ui/context-menu.tsxindex f12426b965..acb571db5c 100644--- a/packages/ui/components/ui/context-menu.tsx+++ b/packages/ui/components/ui/context-menu.tsx@@ -54,7 +54,7 @@ function ContextMenuContent({><ContextMenuPrimitive.Popupdata-slot="context-menu-content"- className={cn("z-50 max-h-(--available-height) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-xl bg-surface-raised p-1.5 text-popover-foreground shadow-[var(--menu-shadow)] ring-1 ring-surface-border duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className )}+ className={cn("z-50 max-h-(--available-height) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-menu bg-surface-raised p-1.5 text-popover-foreground shadow-[var(--menu-shadow)] ring-1 ring-surface-border duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className )}{...props}/></ContextMenuPrimitive.Positioner>@@ -103,7 +103,7 @@ function ContextMenuItem({data-inset={inset}data-variant={variant}className={cn(- "group/context-menu-item relative flex cursor-default items-center gap-2 rounded-md px-2 py-1.5 text-body outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",+ "group/context-menu-item relative flex cursor-default items-center gap-2 rounded-menu-item px-2 py-1.5 text-body outline-hidden select-none focus:bg-menu-item-hover focus:text-menu-item-hover-foreground data-inset:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",className)}{...props}@@ -130,7 +130,7 @@ function ContextMenuSubTrigger({data-slot="context-menu-sub-trigger"data-inset={inset}className={cn(- "flex cursor-default items-center gap-2 rounded-md px-2 py-1.5 text-body outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-8 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",+ "flex cursor-default items-center gap-2 rounded-menu-item px-2 py-1.5 text-body outline-hidden select-none focus:bg-menu-item-hover focus:text-menu-item-hover-foreground data-inset:pl-8 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",className)}{...props}@@ -167,7 +167,7 @@ function ContextMenuCheckboxItem({data-slot="context-menu-checkbox-item"data-inset={inset}className={cn(- "relative flex cursor-default items-center gap-2 rounded-md py-1.5 pr-8 pl-2 text-body outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-8 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",+ "relative flex cursor-default items-center gap-2 rounded-menu-item py-1.5 pr-8 pl-2 text-body outline-hidden select-none focus:bg-menu-item-hover focus:text-menu-item-hover-foreground data-inset:pl-8 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",className)}checked={checked}@@ -208,7 +208,7 @@ function ContextMenuRadioItem({data-slot="context-menu-radio-item"data-inset={inset}className={cn(- "relative flex cursor-default items-center gap-2 rounded-md py-1.5 pr-8 pl-2 text-body outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-8 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",+ "relative flex cursor-default items-center gap-2 rounded-menu-item py-1.5 pr-8 pl-2 text-body outline-hidden select-none focus:bg-menu-item-hover focus:text-menu-item-hover-foreground data-inset:pl-8 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",className)}{...props}diff --git a/packages/ui/components/ui/dialog.tsx b/packages/ui/components/ui/dialog.tsxindex b7edec9db0..31312a45ac 100644--- a/packages/ui/components/ui/dialog.tsx+++ b/packages/ui/components/ui/dialog.tsx@@ -62,7 +62,7 @@ function DialogContent({// fits is unaffected. `overflow-auto` shares tailwind-merge's// conflict group with `overflow-hidden`, so a dialog that manages// its own scrolling still opts out by passing that.- "fixed top-1/2 left-1/2 z-50 grid max-h-[calc(100dvh-2rem)] w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 overflow-auto rounded-xl bg-surface-raised p-4 text-body text-popover-foreground shadow-[var(--floating-shadow)] ring-1 ring-surface-border data-open:duration-[var(--dialog-enter-duration)] data-closed:duration-[var(--dialog-exit-duration)] data-open:ease-[var(--dialog-enter-easing)] data-closed:ease-[var(--dialog-exit-easing)] motion-reduce:animate-none! outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",+ "fixed top-1/2 left-1/2 z-50 grid max-h-[calc(100dvh-2rem)] w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 overflow-auto rounded-dialog bg-surface-raised p-4 text-body text-popover-foreground shadow-[var(--floating-shadow)] ring-1 ring-surface-border data-open:duration-[var(--dialog-enter-duration)] data-closed:duration-[var(--dialog-exit-duration)] data-open:ease-[var(--dialog-enter-easing)] data-closed:ease-[var(--dialog-exit-easing)] motion-reduce:animate-none! outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",className)}{...props}diff --git a/packages/ui/components/ui/dropdown-menu.tsx b/packages/ui/components/ui/dropdown-menu.tsxindex c26d123a49..ecfcad5b10 100644--- a/packages/ui/components/ui/dropdown-menu.tsx+++ b/packages/ui/components/ui/dropdown-menu.tsx@@ -53,7 +53,7 @@ function DropdownMenuContent({e.stopPropagation()onClick?.(e)}}- className={cn("z-50 max-h-(--available-height) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-xl bg-surface-raised p-1.5 text-popover-foreground shadow-[var(--menu-shadow)] ring-1 ring-surface-border duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95", className )}+ className={cn("z-50 max-h-(--available-height) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-menu bg-surface-raised p-1.5 text-popover-foreground shadow-[var(--menu-shadow)] ring-1 ring-surface-border duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95", className )}{...props}/></MenuPrimitive.Positioner>@@ -100,7 +100,7 @@ function DropdownMenuItem({data-inset={inset}data-variant={variant}className={cn(- "group/dropdown-menu-item relative flex cursor-default items-center gap-2 rounded-md px-2 py-1.5 text-body outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",+ "group/dropdown-menu-item relative flex cursor-default items-center gap-2 rounded-menu-item px-2 py-1.5 text-body outline-hidden select-none focus:bg-menu-item-hover focus:text-menu-item-hover-foreground data-inset:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",className)}{...props}@@ -125,7 +125,7 @@ function DropdownMenuSubTrigger({data-slot="dropdown-menu-sub-trigger"data-inset={inset}className={cn(- "flex cursor-default items-center gap-2 rounded-md px-2 py-1.5 text-body outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-8 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",+ "flex cursor-default items-center gap-2 rounded-menu-item px-2 py-1.5 text-body outline-hidden select-none focus:bg-menu-item-hover focus:text-menu-item-hover-foreground data-inset:pl-8 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",className)}{...props}@@ -147,7 +147,7 @@ function DropdownMenuSubContent({return (<DropdownMenuContentdata-slot="dropdown-menu-sub-content"- className={cn("w-auto min-w-[96px] rounded-xl bg-surface-raised p-1.5 text-popover-foreground shadow-[var(--menu-shadow)] ring-1 ring-surface-border duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className )}+ className={cn("w-auto min-w-[96px] rounded-menu bg-surface-raised p-1.5 text-popover-foreground shadow-[var(--menu-shadow)] ring-1 ring-surface-border duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className )}align={align}alignOffset={alignOffset}side={side}@@ -171,7 +171,7 @@ function DropdownMenuCheckboxItem({data-slot="dropdown-menu-checkbox-item"data-inset={inset}className={cn(- "relative flex cursor-default items-center gap-2 rounded-md py-1.5 pr-8 pl-2 text-body outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-8 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",+ "relative flex cursor-default items-center gap-2 rounded-menu-item py-1.5 pr-8 pl-2 text-body outline-hidden select-none focus:bg-menu-item-hover focus:text-menu-item-hover-foreground data-inset:pl-8 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",className)}checked={checked}@@ -219,7 +219,7 @@ function DropdownMenuRadioItem({data-inset={inset}closeOnClick={closeOnClick}className={cn(- "relative flex cursor-default items-center gap-2 rounded-md py-1.5 pr-8 pl-2 text-body outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-8 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",+ "relative flex cursor-default items-center gap-2 rounded-menu-item py-1.5 pr-8 pl-2 text-body outline-hidden select-none focus:bg-menu-item-hover focus:text-menu-item-hover-foreground data-inset:pl-8 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",className)}{...props}diff --git a/packages/ui/components/ui/input.tsx b/packages/ui/components/ui/input.tsxindex d34594342f..926037671c 100644--- a/packages/ui/components/ui/input.tsx+++ b/packages/ui/components/ui/input.tsx@@ -9,7 +9,7 @@ function Input({ className, type, ...props }: React.ComponentProps<"input">) {type={type}data-slot="input"className={cn(- "h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-title-sm transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-body file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-body dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",+ "h-8 w-full min-w-0 rounded-input border border-input bg-transparent px-2.5 py-1 text-title-sm transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-body file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-body dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",className)}{...props}diff --git a/packages/ui/components/ui/popover.tsx b/packages/ui/components/ui/popover.tsxindex 3016eb91e9..24d9fb221d 100644--- a/packages/ui/components/ui/popover.tsx+++ b/packages/ui/components/ui/popover.tsx@@ -45,7 +45,7 @@ function PopoverContent({<PopoverPrimitive.Popupdata-slot="popover-content"className={cn(- "z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-lg bg-surface-raised p-2.5 text-body text-popover-foreground shadow-[var(--menu-shadow)] ring-1 ring-surface-border outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",+ "z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-popover bg-surface-raised p-2.5 text-body text-popover-foreground shadow-[var(--menu-shadow)] ring-1 ring-surface-border outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",className)}{...props}diff --git a/packages/ui/components/ui/select.tsx b/packages/ui/components/ui/select.tsxindex b42673aa7e..964726921c 100644--- a/packages/ui/components/ui/select.tsx+++ b/packages/ui/components/ui/select.tsx@@ -56,7 +56,7 @@ function SelectTrigger({data-slot="select-trigger"data-size={size}className={cn(- "flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-body whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-md *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4.5",+ "flex w-fit items-center justify-between gap-1.5 rounded-input border border-input bg-transparent py-2 pr-2 pl-2.5 text-body whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-md *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4.5",className)}{...props}@@ -98,7 +98,7 @@ function SelectContent({<SelectPrimitive.Popupdata-slot="select-content"data-align-trigger={alignItemWithTrigger}- className={cn("relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-xl bg-surface-raised text-popover-foreground shadow-[var(--menu-shadow)] ring-1 ring-surface-border duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className )}+ className={cn("relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-menu bg-surface-raised text-popover-foreground shadow-[var(--menu-shadow)] ring-1 ring-surface-border duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className )}{...props}><SelectScrollUpButton />@@ -132,7 +132,7 @@ function SelectItem({<SelectPrimitive.Itemdata-slot="select-item"className={cn(- "relative flex w-full cursor-default items-center gap-2 rounded-md py-1.5 pr-8 pl-2 text-body outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",+ "relative flex w-full cursor-default items-center gap-2 rounded-menu-item py-1.5 pr-8 pl-2 text-body outline-hidden select-none focus:bg-menu-item-hover focus:text-menu-item-hover-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",className)}{...props}diff --git a/packages/ui/components/ui/textarea.tsx b/packages/ui/components/ui/textarea.tsxindex 6f129d33e8..7ea7b0b723 100644--- a/packages/ui/components/ui/textarea.tsx+++ b/packages/ui/components/ui/textarea.tsx@@ -7,7 +7,7 @@ function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {<textareadata-slot="textarea"className={cn(- "flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-title-sm transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-body dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",+ "flex field-sizing-content min-h-16 w-full rounded-input border border-input bg-transparent px-2.5 py-2 text-title-sm transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-body dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",className)}{...props}diff --git a/packages/ui/components/ui/tooltip.tsx b/packages/ui/components/ui/tooltip.tsxindex 9ae4e6e958..310305f7eb 100644--- a/packages/ui/components/ui/tooltip.tsx+++ b/packages/ui/components/ui/tooltip.tsx@@ -94,7 +94,7 @@ function TooltipContent({<TooltipPrimitive.Popupdata-slot="tooltip-content"className={cn(- "dark z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-lg bg-(--tooltip-fill) px-2.5 py-1 text-caption text-foreground shadow-(--tooltip-elevation) has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",+ "dark z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-tooltip bg-(--tooltip-fill) px-2.5 py-1 text-caption text-foreground shadow-(--tooltip-elevation) has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",className)}{...props}diff --git a/packages/ui/lib/utils.ts b/packages/ui/lib/utils.tsindex f56c18a2e6..eb60be108f 100644--- a/packages/ui/lib/utils.ts+++ b/packages/ui/lib/utils.ts@@ -16,6 +16,28 @@ import { extendTailwindMerge } from "tailwind-merge"*/const twMerge = extendTailwindMerge({extend: {+ // Component radii from packages/ui/styles/theme-variables.css.+ theme: {+ radius: [+ "page",+ "card",+ "menu",+ "menu-item",+ "popover",+ "dialog",+ "tooltip",+ "input",+ "button",+ "button-sm",+ "avatar",+ "nav-item",+ "rail-item",+ "label",+ "issue-group-header",+ "board-column",+ "board-card",+ ],+ },classGroups: {"font-size": [{diff --git a/packages/ui/package.json b/packages/ui/package.jsonindex a929006056..bb21decd0b 100644--- a/packages/ui/package.json+++ b/packages/ui/package.json@@ -27,6 +27,8 @@"./icons": "./icons/index.ts","./i18n-types": "./types/i18next.ts","./styles/tokens.css": "./styles/tokens.css",+ "./styles/theme-variables.css": "./styles/theme-variables.css",+ "./styles/appearance.css": "./styles/appearance.css","./styles/base.css": "./styles/base.css"},"dependencies": {diff --git a/packages/ui/styles/appearance.css b/packages/ui/styles/appearance.cssnew file mode 100644index 0000000000..14bd99bd7d--- /dev/null+++ b/packages/ui/styles/appearance.css@@ -0,0 +1,80 @@+/* Appearance: what themes and type preferences need beyond tokens.css.+ *+ * Theme tokens are data (packages/core/appearance/themes.ts) and arrive as a+ * generated stylesheet; a theme's own CSS arrives as a second one. This file+ * holds the fixed parts both rely on: the CJK families, the content type+ * stack and the primary button fill. Import after tokens.css. */++/* ── Type families the Appearance settings can pick ─────────────────────────+ * CJK families per locale, mirroring the sans chains in each app's+ * globals.css: Simplified first by default, Traditional for zh-TW, Japanese+ * Mincho for ja. Kai has no Japanese counterpart and falls back to Mincho. */++:root {+ --font-cjk-serif: "Songti SC", "STSong", "Source Han Serif SC", "Noto Serif CJK SC",+ "Noto Serif SC", "SimSun", "Apple Myungjo", "Noto Serif CJK KR", serif;+ --font-cjk-kai: "LXGW WenKai", "LXGW WenKai Screen", "Kaiti SC", "STKaiti", "KaiTi",+ "Kaiti TC", "BiauKai", var(--font-cjk-serif);+}++html[lang|="ja"] {+ --font-cjk-serif: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif CJK JP",+ "Noto Serif JP", "Songti SC", "SimSun", serif;+ --font-cjk-kai: var(--font-cjk-serif);+}++html[lang="zh-TW"] {+ --font-cjk-serif: "Songti TC", "Source Han Serif TC", "Noto Serif CJK TC", "PMingLiU",+ "Songti SC", "Noto Serif CJK SC", serif;+ --font-cjk-kai: "LXGW WenKai TC", "Kaiti TC", "BiauKai", "DFKai-SB", "LXGW WenKai",+ "Kaiti SC", var(--font-cjk-serif);+}++/* ── Content type ───────────────────────────────────────────────────────────+ * Issue descriptions, comments, chat and documents render under+ * .rich-text-editor and can have their own faces, size and line height+ * (Appearance > Content text). Each falls back to the interface setting.+ * The text tokens are redeclared here because a custom property that uses+ * var() is resolved where it is declared, so --content-scale has to be read+ * on this element rather than on :root. */++:root {+ --font-content: var(--font-content-latin, var(--font-ui, var(--font-ui-inter))),+ var(--font-content-cjk, var(--font-cjk, var(--font-cjk-sans)));+}++.rich-text-editor {+ --content-size: var(--content-scale, var(--font-scale, 1));+ --text-micro: calc(11px * var(--content-size));+ --text-micro--line-height: calc(15px * var(--content-size));+ --text-caption: calc(12px * var(--content-size));+ --text-caption--line-height: calc(16px * var(--content-size));+ --text-label: calc(13px * var(--content-size));+ --text-label--line-height: calc(18px * var(--content-size));+ --text-body: calc(14px * var(--content-size));+ --text-body--line-height: calc(20px * var(--content-size));+ --text-body-lg: calc(15px * var(--content-size));+ --text-body-lg--line-height: calc(22px * var(--content-size));+ --text-title-sm: calc(16px * var(--content-size));+ --text-title-sm--line-height: calc(24px * var(--content-size));+ --text-title: calc(18px * var(--content-size));+ --text-title--line-height: calc(28px * var(--content-size));+ --text-display-sm: calc(24px * var(--content-size));+ --text-display-sm--line-height: calc(32px * var(--content-size));+ font-family: var(--font-content);+}++/* ── Primary button fill ────────────────────────────────────────────────────+ * --primary also paints text (`text-primary`), so a theme whose button colour+ * would fail as text sets --button-primary instead. Only active under a+ * theme; the default theme keeps the button's own classes. */++:root[data-theme] [data-slot="button"][data-variant="default"] {+ background-color: var(--button-primary, var(--primary));+ color: var(--button-primary-foreground, var(--primary-foreground));+ border-color: var(--button-primary-border, transparent);+}++:root[data-theme] [data-slot="button"][data-variant="default"]:not(:disabled):hover {+ background-color: color-mix(in oklab, var(--button-primary, var(--primary)) 90%, var(--foreground));+}diff --git a/packages/ui/styles/theme-variables.css b/packages/ui/styles/theme-variables.cssnew file mode 100644index 0000000000..ef363d59f9--- /dev/null+++ b/packages/ui/styles/theme-variables.css@@ -0,0 +1,70 @@+/* Component theme variables (docs/theming.md, "Components" and "Product").+ *+ * Themes set public names such as --menu-radius or --issue-row-hover-background;+ * components read them through these Tailwind aliases. Nothing here declares+ * the public names: each alias carries the default as a var() fallback and is+ * inlined into the utility, so it resolves on the element that uses it. A+ * default declared on :root would be resolved there instead and stop+ * following tokens a theme restates further down (Pop's frame, a status+ * block's ink). Keep this file in step with packages/core/appearance/theme-variables.ts. */++@theme inline {+ --radius-page: var(--page-radius, calc(var(--radius) * 1.5));+ --radius-card: var(--card-radius, calc(var(--radius) * 1.5));+ --radius-menu: var(--menu-radius, calc(var(--radius) * 1.5));+ --radius-menu-item: var(--menu-item-radius, calc(var(--radius) * 0.75));+ --radius-popover: var(--popover-radius, var(--radius));+ --radius-dialog: var(--dialog-radius, calc(var(--radius) * 1.5));+ --radius-tooltip: var(--tooltip-radius, var(--radius));+ --radius-input: var(--input-radius, var(--radius));+ --radius-button: var(--button-radius, var(--radius));+ --radius-button-sm: var(--button-radius-sm, calc(var(--radius) * 0.75));+ --radius-avatar: var(--avatar-radius, calc(infinity * 1px));+ --radius-nav-item: var(--nav-item-radius, var(--radius));+ --radius-rail-item: var(--rail-item-radius, calc(var(--radius) * 1.5));+ --radius-label: var(--label-radius, calc(infinity * 1px));+ --radius-issue-group-header: var(--issue-group-header-radius, var(--radius));+ --radius-board-column: var(--board-column-radius, calc(var(--radius) * 1.5));+ --radius-board-card: var(--board-card-radius, var(--radius));++ --color-page-border: var(--page-border-color, var(--surface-border));+ --color-menu-item-hover: var(--menu-item-hover-background, var(--accent));+ --color-menu-item-hover-foreground: var(--menu-item-hover-color, var(--accent-foreground));+ --color-nav-item: var(--nav-item-color, var(--muted-foreground));+ --color-nav-item-hover: var(--nav-item-hover-background, var(--surface-hover));+ --color-nav-item-hover-foreground: var(--nav-item-hover-color, var(--foreground));+ --color-nav-item-active: var(--nav-item-active-background, var(--surface-selected));+ --color-nav-item-active-foreground: var(--nav-item-active-color, var(--surface-selected-foreground));+ --color-rail-item: var(--rail-item-color, var(--muted-foreground));+ --color-rail-item-hover: var(--rail-item-hover-background, color-mix(in oklab, var(--sidebar-accent) 60%, transparent));+ --color-rail-item-active: var(--rail-item-active-background, var(--sidebar-accent));+ --color-rail-item-active-foreground: var(--rail-item-active-color, var(--sidebar-accent-foreground));++ --color-issue-row-hover: var(--issue-row-hover-background, var(--surface-hover));+ --color-issue-row-selected: var(--issue-row-selected-background, var(--surface-selected));+ --color-issue-row-identifier: var(--issue-row-identifier-color, var(--muted-foreground));+ --color-issue-group-header: var(--issue-group-header-background, var(--muted));+ --color-issue-group-header-hover: var(--issue-group-header-hover-background, var(--accent));+ --color-board-column: var(--board-column-background, color-mix(in oklab, var(--muted) 40%, transparent));+ --color-board-card: var(--board-card-background, var(--surface));+ --color-board-card-hover: var(--board-card-hover-background, var(--surface-hover));+ --color-board-card-border: var(--board-card-border-color, var(--surface-border));++ --color-status-backlog: var(--status-backlog, var(--muted-foreground));+ --color-status-todo: var(--status-todo, var(--muted-foreground));+ --color-status-in-progress: var(--status-in-progress, var(--warning));+ --color-status-in-review: var(--status-in-review, var(--success));+ --color-status-done: var(--status-done, var(--info));+ --color-status-blocked: var(--status-blocked, var(--destructive));+ --color-status-cancelled: var(--status-cancelled, var(--muted-foreground));+ --color-priority-urgent: var(--priority-urgent, var(--destructive));+ --color-priority-medium: var(--priority-medium, var(--warning));+ --color-priority-low: var(--priority-low, var(--info));+ --color-priority-none: var(--priority-none, var(--muted-foreground));+}++/* Icon stroke: only glyphs drawn at the default width follow it, so a call+ site that asks for a specific stroke keeps it. */+svg.icon[stroke-width="2"] {+ stroke-width: var(--icon-stroke-width, 2);+}diff --git a/packages/ui/styles/tokens.css b/packages/ui/styles/tokens.cssindex 7395597187..d9e843e48c 100644--- a/packages/ui/styles/tokens.css+++ b/packages/ui/styles/tokens.css@@ -90,41 +90,44 @@* block needs to override it.** Landing-page display type (rem/clamp, 2.2-6.4rem) is marketing typography on- * a separate ramp and stays out of this scale on purpose. */+ * a separate ramp and stays out of this scale on purpose.+ *+ * --font-scale is the Appearance font size (unset = 1). It multiplies sizes and+ * line-heights only, so a larger size never changes spacing or layout. */@theme {/* counters, badges, timestamps, overline labels */- --text-micro: 11px;- --text-micro--line-height: 15px;+ --text-micro: calc(11px * var(--font-scale, 1));+ --text-micro--line-height: calc(15px * var(--font-scale, 1));/* chips, shortcut hints, tooltips, helper text under a field, issueidentifiers — was text-xs. Not for text people read in place:that is label. */- --text-caption: 12px;- --text-caption--line-height: 16px;+ --text-caption: calc(12px * var(--font-scale, 1));+ --text-caption--line-height: calc(16px * var(--font-scale, 1));/* text read in place beside body copy: activity entries, commenttimestamps, property panel rows, table headers, metadata rows */- --text-label: 13px;- --text-label--line-height: 18px;+ --text-label: calc(13px * var(--font-scale, 1));+ --text-label--line-height: calc(18px * var(--font-scale, 1));/* UI body, the workhorse — was text-sm */- --text-body: 14px;- --text-body--line-height: 20px;+ --text-body: calc(14px * var(--font-scale, 1));+ --text-body--line-height: calc(20px * var(--font-scale, 1));/* roomier body: dialog copy, onboarding prose */- --text-body-lg: 15px;- --text-body-lg--line-height: 22px;+ --text-body-lg: calc(15px * var(--font-scale, 1));+ --text-body-lg--line-height: calc(22px * var(--font-scale, 1));/* small headings — was text-base */- --text-title-sm: 16px;- --text-title-sm--line-height: 24px;+ --text-title-sm: calc(16px * var(--font-scale, 1));+ --text-title-sm--line-height: calc(24px * var(--font-scale, 1));/* section headings — was text-lg */- --text-title: 18px;- --text-title--line-height: 28px;+ --text-title: calc(18px * var(--font-scale, 1));+ --text-title--line-height: calc(28px * var(--font-scale, 1));/* card and dialog titles — was text-xl */- --text-title-lg: 20px;- --text-title-lg--line-height: 28px;+ --text-title-lg: calc(20px * var(--font-scale, 1));+ --text-title-lg--line-height: calc(28px * var(--font-scale, 1));/* page titles — was text-2xl */- --text-display-sm: 24px;- --text-display-sm--line-height: 32px;+ --text-display-sm: calc(24px * var(--font-scale, 1));+ --text-display-sm--line-height: calc(32px * var(--font-scale, 1));/* hero numbers and empty-state headlines — was text-3xl (30px) */- --text-display: 36px;- --text-display--line-height: 40px;+ --text-display: calc(36px * var(--font-scale, 1));+ --text-display--line-height: calc(40px * var(--font-scale, 1));}:root {diff --git a/packages/views/chat/components/chat-input.tsx b/packages/views/chat/components/chat-input.tsxindex 7d9ec29958..2c85f9cbb2 100644--- a/packages/views/chat/components/chat-input.tsx+++ b/packages/views/chat/components/chat-input.tsx@@ -657,6 +657,7 @@ export function ChatInput({><divdata-slot="chat-input-surface"+ data-mc="chat-input"{...(uploadEnabled ? dropZoneProps : {})}className={cn(// max-h-96 is the absolute ceiling on top of the wrapper's 50%: on adiff --git a/packages/views/chat/components/chat-message-list.tsx b/packages/views/chat/components/chat-message-list.tsxindex 0ff41ce9c1..1a2f8fbc99 100644--- a/packages/views/chat/components/chat-message-list.tsx+++ b/packages/views/chat/components/chat-message-list.tsx@@ -393,6 +393,8 @@ export function ChatMessageList({itemContent={(_, item) => (<divclassName={cn(CHAT_COLUMN, "py-2")}+ data-mc="chat-message"+ data-role={item.kind === "live" ? "assistant" : item.message.role}{...(item.key === liveEndKey ? { [LIVE_END_ROW_ATTR]: "" } : {})}><MessageBubblediff --git a/packages/views/chat/components/chat-window.tsx b/packages/views/chat/components/chat-window.tsxindex 0f1807af1c..17422447af 100644--- a/packages/views/chat/components/chat-window.tsx+++ b/packages/views/chat/components/chat-window.tsx@@ -15,6 +15,7 @@ import {import { toast } from "sonner";import { useWorkspaceId } from "@multica/core/hooks";import { useAuthStore } from "@multica/core/auth";+import { useReducedMotion } from "@multica/core/appearance";import { agentListOptions, memberListOptions } from "@multica/core/workspace/queries";import { projectListOptions } from "@multica/core/projects/queries";import { canAssignAgent } from "../../issues/components/pickers/assignee-picker";@@ -734,6 +735,7 @@ export function ChatWindow() {const isExpanded = useChatStore((s) => s.isExpanded);const { renderWidth, renderHeight, isAtMax, boundsReady, isDragging, toggleExpand, startDrag } = useChatResize(windowRef);+ const reduceMotion = useReducedMotion();const { contentReady, markContentReady } = useChatOpenReveal(isOpen);const isVisible = isOpen && (isExpanded || boundsReady) && contentReady;@@ -807,9 +809,12 @@ export function ChatWindow() {? t(($) => $.window.restore_tooltip): t(($) => $.window.expand_tooltip);const minimizeLabel = t(($) => $.window.minimize_tooltip);+ const sizeTransition =+ isDragging || reduceMotion ? { duration: 0 } : { type: "spring" as const, duration: 0.3, bounce: 0 };return (<motion.div+ data-mc="chat-window"ref={windowRef}inert={!isOpen}aria-hidden={!isOpen}@@ -821,8 +826,8 @@ export function ChatWindow() {...motionSize,}}transition={{- width: isDragging ? { duration: 0 } : { type: "spring", duration: 0.3, bounce: 0 },- height: isDragging ? { duration: 0 } : { type: "spring", duration: 0.3, bounce: 0 },+ width: sizeTransition,+ height: sizeTransition,opacity: { duration: 0.15 },}}>diff --git a/packages/views/common/appearance-sync.test.tsx b/packages/views/common/appearance-sync.test.tsxnew file mode 100644index 0000000000..d8b2a9f948--- /dev/null+++ b/packages/views/common/appearance-sync.test.tsx@@ -0,0 +1,123 @@+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import { act, cleanup, render } from "@testing-library/react";+import {+ APPEARANCE_STORAGE_KEY,+ DEFAULT_APPEARANCE,+ useAppearanceStore,+} from "@multica/core/appearance";+import { AppearanceSync } from "./appearance-sync";++const html = () => document.documentElement;+const sheet = () => document.getElementById("multica-appearance");+const themeCss = () => document.getElementById("multica-theme-css");++describe("AppearanceSync", () => {+ beforeEach(() => {+ localStorage.clear();+ useAppearanceStore.setState(DEFAULT_APPEARANCE);+ });+ afterEach(cleanup);++ it("leaves <html> untouched for the defaults", () => {+ render(<AppearanceSync />);+ expect(html().hasAttribute("data-theme")).toBe(false);+ expect(html().getAttribute("style") ?? "").toBe("");+ expect(sheet()).toBeNull();+ expect(themeCss()).toBeNull();+ });++ it("marks the mode on <html> for theme CSS, following the dark class", async () => {+ const { unmount } = render(<AppearanceSync />);+ expect(html().classList.contains("theme-light")).toBe(true);+ html().classList.add("dark");+ await act(async () => {});+ expect(html().classList.contains("theme-dark")).toBe(true);+ expect(html().classList.contains("theme-light")).toBe(false);+ html().classList.remove("dark");+ await act(async () => {});+ expect(html().classList.contains("theme-light")).toBe(true);+ unmount();+ expect(html().classList.contains("theme-light")).toBe(false);+ });++ it("marks the platform and window focus on <html>", () => {+ const { unmount } = render(<AppearanceSync />);+ expect(html().classList.contains("is-web")).toBe(true);+ act(() => {+ vi.spyOn(document, "hasFocus").mockReturnValue(false);+ window.dispatchEvent(new Event("blur"));+ });+ expect(html().classList.contains("is-focused")).toBe(false);+ act(() => {+ vi.spyOn(document, "hasFocus").mockReturnValue(true);+ window.dispatchEvent(new Event("focus"));+ });+ expect(html().classList.contains("is-focused")).toBe(true);+ unmount();+ expect(html().classList.contains("is-web")).toBe(false);+ expect(html().classList.contains("is-focused")).toBe(false);+ });++ it("mirrors the theme, its options, type and density onto <html>", () => {+ render(<AppearanceSync />);+ act(() => {+ const { set, setThemeOption } = useAppearanceStore.getState();+ set({ theme: "pop", highContrast: true, uiFont: "serif", fontSize: 15, contentCjkFont: "serif", density: "comfortable" });+ setThemeOption("pop", "status-blocks", false);+ });+ expect(html().getAttribute("data-theme")).toBe("pop");+ expect(html().getAttribute("data-theme-option-signal")).toBe("yellow");+ expect(html().hasAttribute("data-theme-option-status-blocks")).toBe(false);+ expect(html().getAttribute("data-theme-option-outlined-chips")).toBe("on");+ expect(html().style.getPropertyValue("--font-ui")).toBe("var(--font-ui-serif)");+ expect(html().style.getPropertyValue("--font-content-cjk")).toBe("var(--font-cjk-serif)");+ expect(html().style.getPropertyValue("--font-scale")).toBe(String(15 / 14));+ expect(html().style.getPropertyValue("--issue-row-height")).toBe("42px");+ expect(themeCss()?.textContent).toContain("--button-primary:");+ expect(themeCss()?.textContent).toContain('[data-mc="issue-group-header"]');+ expect(sheet()?.textContent).toContain("--muted-foreground: color-mix(");++ act(() => useAppearanceStore.getState().set({ theme: "github" }));+ expect(html().hasAttribute("data-theme-option-signal")).toBe(false);+ expect(themeCss()?.textContent).not.toContain('[data-mc="issue-group-header"]');+ expect(themeCss()!.compareDocumentPosition(sheet()!) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();++ act(() => useAppearanceStore.getState().reset());+ expect(html().hasAttribute("data-theme")).toBe(false);+ expect(html().style.getPropertyValue("--font-ui")).toBe("");+ expect(sheet()).toBeNull();+ expect(themeCss()).toBeNull();+ });++ it("keeps the adjustments after a theme stylesheet created later", () => {+ useAppearanceStore.setState({ highContrast: true });+ render(<AppearanceSync />);+ act(() => useAppearanceStore.getState().set({ theme: "notion" }));+ expect(themeCss()!.compareDocumentPosition(sheet()!) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();+ });++ it("clears everything when the product UI unmounts", () => {+ useAppearanceStore.setState({ theme: "pop", highContrast: true, codeFont: "system" });+ const { unmount } = render(<AppearanceSync />);+ expect(html().getAttribute("data-theme")).toBe("pop");+ expect(sheet()).not.toBeNull();+ unmount();+ expect(html().hasAttribute("data-theme")).toBe(false);+ expect(html().hasAttribute("data-theme-option-signal")).toBe(false);+ expect(html().style.getPropertyValue("--font-mono")).toBe("");+ expect(sheet()).toBeNull();+ expect(themeCss()).toBeNull();+ });++ it("follows changes saved by another window", async () => {+ render(<AppearanceSync />);+ localStorage.setItem(+ APPEARANCE_STORAGE_KEY,+ JSON.stringify({ state: { theme: "notion" }, version: 0 }),+ );+ await act(async () => {+ window.dispatchEvent(new StorageEvent("storage", { key: APPEARANCE_STORAGE_KEY }));+ });+ expect(html().getAttribute("data-theme")).toBe("notion");+ });+});diff --git a/packages/views/common/appearance-sync.tsx b/packages/views/common/appearance-sync.tsxnew file mode 100644index 0000000000..db67891150--- /dev/null+++ b/packages/views/common/appearance-sync.tsx@@ -0,0 +1,145 @@+"use client";++import { useEffect, useLayoutEffect } from "react";+import { useShallow } from "zustand/react/shallow";+import {+ APPEARANCE_STORAGE_KEY,+ APPEARANCE_THEME_ATTR,+ THEME_OPTION_ATTR_PREFIX,+ activeTheme,+ appearanceRootVariables,+ appearanceStylesheet,+ appearanceThemeAttributes,+ appearanceThemeCss,+ selectAppearance,+ useAppearanceStore,+} from "@multica/core/appearance";+import { getShortcutPlatform, getShortcutRuntime } from "@multica/core/shortcuts";++const STYLE_ELEMENT_ID = "multica-appearance";+const THEME_CSS_ELEMENT_ID = "multica-theme-css";++/** Creates, updates or removes a `<style>` at the end of <head>. */+function writeStyle(id: string, css: string) {+ let style = document.getElementById(id);+ if (!css) {+ style?.remove();+ return;+ }+ if (!style) {+ style = document.createElement("style");+ style.id = id;+ document.head.appendChild(style);+ }+ if (style.textContent !== css) style.textContent = css;+}++/** The adjustments go after the theme's CSS, whichever was created first. */+function orderStyles() {+ const theme = document.getElementById(THEME_CSS_ELEMENT_ID);+ const adjustments = document.getElementById(STYLE_ELEMENT_ID);+ if (theme && adjustments && adjustments.compareDocumentPosition(theme) & Node.DOCUMENT_POSITION_FOLLOWING) {+ document.head.appendChild(adjustments);+ }+}++/** `theme-light` / `theme-dark` on <html>, following the `dark` class the mode switch sets. */+function useModeClasses() {+ useLayoutEffect(() => {+ const root = document.documentElement;+ const sync = () => {+ const dark = root.classList.contains("dark");+ if (root.classList.contains("theme-dark") !== dark) root.classList.toggle("theme-dark", dark);+ if (root.classList.contains("theme-light") === dark) root.classList.toggle("theme-light", !dark);+ };+ sync();+ const observer = new MutationObserver(sync);+ observer.observe(root, { attributes: true, attributeFilter: ["class"] });+ return () => {+ observer.disconnect();+ root.classList.remove("theme-light", "theme-dark");+ };+ }, []);+}++/** `is-desktop` / `is-web`, `mod-<os>` and `is-focused` on <html>, for theme CSS. */+function useStateClasses() {+ useLayoutEffect(() => {+ const root = document.documentElement;+ const platform = getShortcutPlatform();+ const fixed = [+ getShortcutRuntime() === "desktop" ? "is-desktop" : "is-web",+ ...(platform === "unknown" ? [] : [`mod-${platform}`]),+ ];+ root.classList.add(...fixed);+ const focus = () => root.classList.toggle("is-focused", document.hasFocus());+ focus();+ window.addEventListener("focus", focus);+ window.addEventListener("blur", focus);+ return () => {+ window.removeEventListener("focus", focus);+ window.removeEventListener("blur", focus);+ root.classList.remove(...fixed, "is-focused");+ };+ }, []);+}++function clearThemeAttributes(root: HTMLElement) {+ root.removeAttribute(APPEARANCE_THEME_ATTR);+ for (const name of root.getAttributeNames()) {+ if (name.startsWith(THEME_OPTION_ATTR_PREFIX)) root.removeAttribute(name);+ }+}++/**+ * Mirrors the appearance preferences onto `<html>`: the mode as+ * `theme-light` / `theme-dark`, the theme and its options as attributes, the+ * theme's CSS and the adjustments on top of it as two generated+ * stylesheets after the app's own, fonts, size and density as inline+ * variables. Mount it only around the product UI:+ * unmounting clears all of it, so pages outside it (web's landing and auth+ * pages) keep the default look. Changes made in another window or tab follow+ * via the storage event.+ */+export function AppearanceSync() {+ const prefs = useAppearanceStore(useShallow(selectAppearance));+ useModeClasses();+ useStateClasses();++ useLayoutEffect(() => {+ const root = document.documentElement;+ const theme = activeTheme(prefs);++ clearThemeAttributes(root);+ for (const [name, value] of Object.entries(appearanceThemeAttributes(theme, prefs))) {+ if (value !== null) root.setAttribute(name, value);+ }++ const variables = appearanceRootVariables(prefs);+ for (const [name, value] of Object.entries(variables)) {+ if (value === null) root.style.removeProperty(name);+ else root.style.setProperty(name, value);+ }++ writeStyle(THEME_CSS_ELEMENT_ID, appearanceThemeCss(theme));+ writeStyle(STYLE_ELEMENT_ID, appearanceStylesheet(theme, prefs));+ orderStyles();++ return () => {+ clearThemeAttributes(root);+ for (const name of Object.keys(variables)) root.style.removeProperty(name);+ document.getElementById(STYLE_ELEMENT_ID)?.remove();+ document.getElementById(THEME_CSS_ELEMENT_ID)?.remove();+ };+ }, [prefs]);++ useEffect(() => {+ const onStorage = (event: StorageEvent) => {+ if (event.key === APPEARANCE_STORAGE_KEY) void useAppearanceStore.persist.rehydrate();+ };+ window.addEventListener("storage", onStorage);+ return () => window.removeEventListener("storage", onStorage);+ }, []);++ return null;+}diff --git a/packages/views/common/theme-anchors.test.ts b/packages/views/common/theme-anchors.test.tsnew file mode 100644index 0000000000..b044f7c4fd--- /dev/null+++ b/packages/views/common/theme-anchors.test.ts@@ -0,0 +1,66 @@+import { readFileSync, readdirSync, statSync } from "node:fs";+import { join, relative } from "node:path";+import { describe, expect, it } from "vitest";+import { THEME_ANCHORS, THEME_PUBLIC_SLOTS } from "@multica/core/appearance";++/**+ * The theme anchors are a public contract (docs/theming.md). This keeps the+ * registry, the source and the docs in step: every listed anchor is still+ * rendered, nothing renders an unlisted one, and the docs mention each+ * anchor and slot.+ */++const REPO = join(__dirname, "../../..");+const SOURCE_ROOTS = ["packages/views", "packages/ui/components", "apps/desktop/src/renderer", "apps/web/app", "apps/web/components"];++function sourceFiles(dir: string, out: string[] = []): string[] {+ let entries: string[];+ try {+ entries = readdirSync(dir);+ } catch {+ return out;+ }+ for (const entry of entries) {+ if (entry === "node_modules" || entry.startsWith(".")) continue;+ const path = join(dir, entry);+ if (statSync(path).isDirectory()) sourceFiles(path, out);+ else if (/\.tsx?$/.test(entry) && !/\.test\.tsx?$/.test(entry)) out.push(path);+ }+ return out;+}++const files = SOURCE_ROOTS.flatMap((root) => sourceFiles(join(REPO, root)));+const used = new Map<string, string[]>();+for (const file of files) {+ const text = readFileSync(file, "utf8");+ for (const match of text.matchAll(/(?:data-mc=|"data-mc":\s*)"([a-z-]+)"/g)) {+ used.set(match[1]!, [...(used.get(match[1]!) ?? []), relative(REPO, file)]);+ }+}+const docs = readFileSync(join(REPO, "docs/theming.md"), "utf8");++describe("theme anchors", () => {+ it("renders every registered anchor somewhere", () => {+ const missing = Object.keys(THEME_ANCHORS).filter((name) => !used.has(name));+ expect(missing).toEqual([]);+ });++ it("only renders registered anchors", () => {+ const unknown = [...used.keys()].filter((name) => !(name in THEME_ANCHORS));+ expect(unknown).toEqual([]);+ });++ it("keeps every public slot on a UI primitive", () => {+ const ui = sourceFiles(join(REPO, "packages/ui/components")).map((f) => readFileSync(f, "utf8")).join("\n");+ const missing = THEME_PUBLIC_SLOTS.filter((slot) => !ui.includes(`data-slot="${slot}"`));+ expect(missing).toEqual([]);+ });++ it("documents every anchor and slot", () => {+ const names = [+ ...Object.keys(THEME_ANCHORS).map((name) => `data-mc="${name}"`),+ ...THEME_PUBLIC_SLOTS.map((slot) => `\`${slot}\``),+ ];+ expect(names.filter((name) => !docs.includes(name))).toEqual([]);+ });+});diff --git a/packages/views/common/theme-variables.test.ts b/packages/views/common/theme-variables.test.tsnew file mode 100644index 0000000000..231f131fc4--- /dev/null+++ b/packages/views/common/theme-variables.test.ts@@ -0,0 +1,134 @@+import { readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";+import { join } from "node:path";+import { describe, expect, it } from "vitest";+import {+ THEME_VARIABLES,+ THEME_VARIABLE_NAMES,+ THEME_VARIABLE_SECTIONS,+ type ThemeVariable,+} from "@multica/core/appearance";++/**+ * THEME_VARIABLES is the public contract for themes. This keeps it honest:+ * each variable is read where the registry says, with the default it+ * documents, and the reference table in docs/theming.md is generated from+ * it. Run with UPDATE_THEME_DOCS=1 to rewrite the table.+ */++const REPO = join(__dirname, "../../..");+const read = (path: string) => readFileSync(join(REPO, path), "utf8");++/** Stylesheets whose fallbacks are public variables. */+const THEMED_CSS = [+ "packages/ui/styles/theme-variables.css",+ "packages/views/editor/styles/prose.css",+ "packages/views/editor/styles/code.css",+];+/** Fallbacks in those files that belong to the app, not to themes. */+const INTERNAL = new Set(["content-scale", "font-scale", "code-gutter-bg", "line-digits", "font-ui", "font-cjk"]);++function sourceFiles(dir: string, out: string[] = []): string[] {+ let entries: string[];+ try {+ entries = readdirSync(dir);+ } catch {+ return out;+ }+ for (const entry of entries) {+ if (entry === "node_modules" || entry.startsWith(".")) continue;+ const path = join(dir, entry);+ if (statSync(path).isDirectory()) sourceFiles(path, out);+ else if (/\.(tsx?|css)$/.test(entry) && !/\.test\.tsx?$/.test(entry)) out.push(path);+ }+ return out;+}++const squash = (value: string) => value.replace(/\s+/g, "");+const themedCss = THEMED_CSS.map(read).join("\n");+const sources = ["packages/views", "packages/ui", "packages/core/issues", "apps/desktop/src/renderer/src"]+ .flatMap((root) => sourceFiles(join(REPO, root)))+ .map((file) => readFileSync(file, "utf8"))+ .join("\n");+const corpus = squash(sources);+const foundationCss = ["tokens.css", "appearance.css"].map((f) => read(`packages/ui/styles/${f}`)).join("\n");++function block(css: string, selector: string): string {+ const start = css.indexOf(`\n${selector} {`);+ if (start < 0) return "";+ return css.slice(start, css.indexOf("\n}", start));+}++const LIGHT = block(foundationCss, ":root") + block(foundationCss, "@theme");+const DARK = block(foundationCss, ".dark");++function declared(css: string, name: string): string | undefined {+ const match = new RegExp(`--${name}:\\s*([^;]+);`).exec(css);+ return match?.[1]?.replace(/\s+/g, " ").trim();+}++function defaults(variable: ThemeVariable): string {+ if (variable.defaultText) return variable.defaultText;+ const light = variable.default ?? declared(LIGHT, variable.name);+ const dark = variable.darkDefault ?? (variable.default === undefined ? declared(DARK, variable.name) : undefined);+ if (light === undefined) return "unset";+ return dark && dark !== light ? `\`${light}\` / \`${dark}\`` : `\`${light}\``;+}++const escape = (text: string) => text.replace(/\|/g, "\\|");++function referenceTables(): string {+ const parts: string[] = [];+ for (const [key, title] of Object.entries(THEME_VARIABLE_SECTIONS)) {+ const rows = THEME_VARIABLES.filter((v) => v.section === key);+ parts.push(`### ${title}`, "", "| Variable | Default (light / dark) | Use |", "| --- | --- | --- |");+ for (const v of rows) parts.push(`| \`--${v.name}\` | ${escape(defaults(v))} | ${escape(v.description)} |`);+ parts.push("");+ }+ return parts.join("\n");+}++const START = "<!-- theme-variables:start (generated by packages/views/common/theme-variables.test.ts) -->";+const END = "<!-- theme-variables:end -->";++describe("theme variables", () => {+ it("has no duplicates", () => {+ expect(THEME_VARIABLE_NAMES.size).toBe(THEME_VARIABLES.length);+ });++ it("reads every component variable with its documented default", () => {+ const missing = THEME_VARIABLES.flatMap((v) =>+ [v.default, v.darkDefault]+ .filter((def): def is string => def !== undefined)+ .filter((def) => !corpus.includes(squash(`var(--${v.name},${def})`)))+ .map((def) => `--${v.name}: ${def}`),+ );+ expect(missing).toEqual([]);+ });++ it("declares every foundation token", () => {+ const missing = THEME_VARIABLES.filter((v) => v.default === undefined && !v.defaultText)+ .filter((v) => !declared(foundationCss, v.name) && !sources.includes(`--${v.name}`))+ .map((v) => v.name);+ expect(missing).toEqual([]);+ });++ it("registers every variable the themed stylesheets read", () => {+ const read = [...themedCss.matchAll(/var\(--([a-z0-9-]+),/g)].map((m) => m[1]!);+ const unknown = [...new Set(read)].filter((name) => !THEME_VARIABLE_NAMES.has(name) && !INTERNAL.has(name));+ expect(unknown).toEqual([]);+ });++ it("keeps the reference in docs/theming.md generated", () => {+ const docs = read("docs/theming.md");+ const start = docs.indexOf(START);+ const end = docs.indexOf(END);+ expect(start, "docs/theming.md is missing the generated reference markers").toBeGreaterThanOrEqual(0);+ const expected = `${START}\n\n${referenceTables()}\n${END}`;+ const current = docs.slice(start, end + END.length);+ if (process.env.UPDATE_THEME_DOCS && current !== expected) {+ writeFileSync(join(REPO, "docs/theming.md"), docs.slice(0, start) + expected + docs.slice(end + END.length));+ return;+ }+ expect(current).toBe(expected);+ });+});diff --git a/packages/views/editor/attachment-preview-modal.tsx b/packages/views/editor/attachment-preview-modal.tsxindex 0f99d62b16..356eb52446 100644--- a/packages/views/editor/attachment-preview-modal.tsx+++ b/packages/views/editor/attachment-preview-modal.tsx@@ -20,7 +20,8 @@ import {type ReactNode,} from "react";import { createPortal } from "react-dom";-import { AnimatePresence, motion, useReducedMotion } from "motion/react";+import { AnimatePresence, motion } from "motion/react";+import { useReducedMotion } from "@multica/core/appearance";import { toast } from "sonner";import {PreviewTooLargeError,@@ -449,7 +450,7 @@ export function AttachmentPreviewModal({}: AttachmentPreviewModalProps & { onExitComplete?: () => void }) {const download = useDownloadAttachment();const cdnDomain = useConfigStore((s) => s.cdnDomain);- const shouldReduceMotion = useReducedMotion() ?? false;+ const shouldReduceMotion = useReducedMotion();const state = normalize(source);// useWorkspaceSlug (not useWorkspacePaths) — returns null outside a// workspace route instead of throwing, so the new-tab button just hides.diff --git a/packages/views/editor/content-editor.tsx b/packages/views/editor/content-editor.tsxindex ecbb54e985..3667881796 100644--- a/packages/views/editor/content-editor.tsx+++ b/packages/views/editor/content-editor.tsx@@ -697,6 +697,7 @@ const ContentEditor = forwardRef<ContentEditorRef, ContentEditorProps>(},attributes: {class: cn("flex-1 rich-text-editor text-body outline-none", className),+ "data-mc": "content",...(ariaLabel ? { role: "textbox", "aria-label": ariaLabel, "aria-multiline": "true" } : {}),},},diff --git a/packages/views/editor/styles/code.css b/packages/views/editor/styles/code.cssindex a3b29a2dd2..9c794c1777 100644--- a/packages/views/editor/styles/code.css+++ b/packages/views/editor/styles/code.css@@ -11,12 +11,12 @@font-family: var(--font-mono, ui-monospace, monospace);font-variant-ligatures: none;font-feature-settings: "liga" 0;- font-size: var(--text-body);- background: color-mix(in srgb, var(--foreground) 3%, transparent);- border: 1px solid color-mix(in srgb, var(--foreground) 5%, transparent);- color: color-mix(in srgb, var(--foreground) 75%, transparent);- padding: 0.125rem 0.375rem;- border-radius: var(--radius-sm);+ font-size: var(--code-font-size, var(--text-body));+ background: var(--code-background, color-mix(in srgb, var(--foreground) 3%, transparent));+ border: 1px solid var(--code-border-color, color-mix(in srgb, var(--foreground) 5%, transparent));+ color: var(--code-color, color-mix(in srgb, var(--foreground) 75%, transparent));+ padding: var(--code-padding, 0.125rem 0.375rem);+ border-radius: var(--code-radius, var(--radius-sm));box-decoration-break: clone;-webkit-box-decoration-break: clone;line-height: 2;@@ -28,9 +28,10 @@ pre.rich-text-editor {font-family: var(--font-mono, ui-monospace, monospace);font-variant-ligatures: none;font-feature-settings: "liga" 0;- background: var(--muted);- border-radius: var(--radius);- padding: 0.75rem 1rem;+ background: var(--code-block-background, var(--muted));+ border: var(--code-block-border, none);+ border-radius: var(--code-block-radius, var(--radius));+ padding: var(--code-block-padding, 0.75rem 1rem);margin: 0.75rem 0;/* Long lines wrap, matching the editable code block (its NodeViewContentsets an inline pre-wrap). Without this, readonly blocks scroll while@@ -46,10 +47,10 @@ pre.rich-text-editor code {font-feature-settings: "liga" 0;background: none;border: none;- color: var(--foreground);+ color: var(--code-block-color, var(--foreground));padding: 0;- font-size: var(--text-label);- line-height: 1.6;+ font-size: var(--code-block-font-size, var(--text-label));+ line-height: var(--code-block-line-height, 1.6);}/* Syntax highlighting — lowlight (hljs). Scoped to the editor surface, to the@@ -59,67 +60,67 @@ pre.rich-text-editor code {colours as the file's source. */:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-keyword,:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-selector-tag,-:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-built_in { color: oklch(0.55 0.16 255); }+:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-built_in { color: var(--code-keyword, oklch(0.55 0.16 255)); }:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-string,-:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-addition { color: oklch(0.55 0.14 155); }+:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-addition { color: var(--code-string, oklch(0.55 0.14 155)); }:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-comment,-:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-quote { color: var(--muted-foreground); font-style: italic; }+:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-quote { color: var(--code-comment, var(--muted-foreground)); font-style: italic; }:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-number,-:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-literal { color: oklch(0.58 0.16 30); }+:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-literal { color: var(--code-number, oklch(0.58 0.16 30)); }:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-title,:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-section,-:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-title\.function_ { color: oklch(0.55 0.14 280); }+:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-title\.function_ { color: var(--code-function, oklch(0.55 0.14 280)); }:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-attr,-:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-attribute { color: oklch(0.58 0.12 60); }+:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-attribute { color: var(--code-property, oklch(0.58 0.12 60)); }:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-variable,-:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-template-variable { color: oklch(0.58 0.14 20); }+:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-template-variable { color: var(--code-variable, oklch(0.58 0.14 20)); }:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-type,-:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-title\.class_ { color: oklch(0.55 0.14 200); }+:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-title\.class_ { color: var(--code-type, oklch(0.55 0.14 200)); }-:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-deletion { color: oklch(0.55 0.2 25); }+:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-deletion { color: var(--code-deletion, oklch(0.55 0.2 25)); }:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-meta { color: var(--muted-foreground); }/* XML / HTML — lowlight emits .hljs-tag for `<` `>` brackets and .hljs-namefor the element name. Without these rules, HTML source renders mostly inthe default text color and looks unhighlighted. */-:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-tag { color: var(--muted-foreground); }-:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-name { color: oklch(0.55 0.16 255); }+:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-tag { color: var(--code-punctuation, var(--muted-foreground)); }+:is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-name { color: var(--code-tag, oklch(0.55 0.16 255)); }/* Dark mode overrides */.dark :is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-keyword,.dark :is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-selector-tag,-.dark :is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-built_in { color: oklch(0.7 0.14 255); }+.dark :is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-built_in { color: var(--code-keyword, oklch(0.7 0.14 255)); }.dark :is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-string,-.dark :is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-addition { color: oklch(0.7 0.14 155); }+.dark :is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-addition { color: var(--code-string, oklch(0.7 0.14 155)); }.dark :is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-number,-.dark :is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-literal { color: oklch(0.72 0.14 30); }+.dark :is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-literal { color: var(--code-number, oklch(0.72 0.14 30)); }.dark :is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-title,.dark :is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-section,-.dark :is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-title\.function_ { color: oklch(0.72 0.12 280); }+.dark :is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-title\.function_ { color: var(--code-function, oklch(0.72 0.12 280)); }.dark :is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-attr,-.dark :is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-attribute { color: oklch(0.72 0.1 60); }+.dark :is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-attribute { color: var(--code-property, oklch(0.72 0.1 60)); }.dark :is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-variable,-.dark :is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-template-variable { color: oklch(0.72 0.12 20); }+.dark :is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-template-variable { color: var(--code-variable, oklch(0.72 0.12 20)); }.dark :is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-type,-.dark :is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-title\.class_ { color: oklch(0.72 0.12 200); }+.dark :is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-title\.class_ { color: var(--code-type, oklch(0.72 0.12 200)); }-.dark :is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-deletion { color: oklch(0.7 0.18 25); }+.dark :is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-deletion { color: var(--code-deletion, oklch(0.7 0.18 25)); }-.dark :is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-name { color: oklch(0.72 0.14 255); }+.dark :is(.rich-text-editor, .transcript-code, .structured-tree) .hljs-name { color: var(--code-tag, oklch(0.72 0.14 255)); }/* Numbered lines — CodeBlockStatic with `lineNumbers` (the attachment viewer'scode, text and log files). A whole document rather than a block insidediff --git a/packages/views/editor/styles/prose.css b/packages/views/editor/styles/prose.cssindex 5ebb690b10..acc9d1825f 100644--- a/packages/views/editor/styles/prose.css+++ b/packages/views/editor/styles/prose.css@@ -53,27 +53,42 @@display cut, which is tighter than the text cut. Weight stops at 600 so h1sits on the same weight as the issue title above it. */.rich-text-editor h1 {- font-size: var(--text-display-sm);- font-weight: 600;+ font-family: var(--h1-font, var(--font-content));+ font-size: var(--h1-size, var(--text-display-sm));+ font-weight: var(--h1-weight, 600);+ font-style: var(--h1-style, normal);+ font-variant: var(--h1-variant, normal);+ letter-spacing: var(--h1-letter-spacing, normal);+ color: var(--h1-color, currentColor);margin-top: 1.5rem;margin-bottom: 0.5rem;- line-height: 1.3;+ line-height: var(--h1-line-height, 1.3);}.rich-text-editor h2 {- font-size: var(--text-title);- font-weight: 600;+ font-family: var(--h2-font, var(--font-content));+ font-size: var(--h2-size, var(--text-title));+ font-weight: var(--h2-weight, 600);+ font-style: var(--h2-style, normal);+ font-variant: var(--h2-variant, normal);+ letter-spacing: var(--h2-letter-spacing, normal);+ color: var(--h2-color, currentColor);margin-top: 1.5rem;margin-bottom: 0.5rem;- line-height: 1.35;+ line-height: var(--h2-line-height, 1.35);}.rich-text-editor h3 {- font-size: var(--text-body-lg);- font-weight: 600;+ font-family: var(--h3-font, var(--font-content));+ font-size: var(--h3-size, var(--text-body-lg));+ font-weight: var(--h3-weight, 600);+ font-style: var(--h3-style, normal);+ font-variant: var(--h3-variant, normal);+ letter-spacing: var(--h3-letter-spacing, normal);+ color: var(--h3-color, currentColor);margin-top: 1rem;margin-bottom: 0.5rem;- line-height: 1.4;+ line-height: var(--h3-line-height, 1.4);}/* h4–h6: Markdown allows six levels and both renderers now emit all of them@@ -82,35 +97,49 @@steps the scale still has — body (14) bold, label (13), caption (12) muted —so a deep heading stays legible without competing with h1–h3. */.rich-text-editor h4 {- font-size: var(--text-body);- font-weight: 600;+ font-family: var(--h4-font, var(--font-content));+ font-size: var(--h4-size, var(--text-body));+ font-weight: var(--h4-weight, 600);+ font-style: var(--h4-style, normal);+ font-variant: var(--h4-variant, normal);+ letter-spacing: var(--h4-letter-spacing, normal);+ color: var(--h4-color, currentColor);margin-top: 1rem;margin-bottom: 0.5rem;- line-height: 1.45;+ line-height: var(--h4-line-height, 1.45);}.rich-text-editor h5 {- font-size: var(--text-label);- font-weight: 600;+ font-family: var(--h5-font, var(--font-content));+ font-size: var(--h5-size, var(--text-label));+ font-weight: var(--h5-weight, 600);+ font-style: var(--h5-style, normal);+ font-variant: var(--h5-variant, normal);+ letter-spacing: var(--h5-letter-spacing, normal);+ color: var(--h5-color, currentColor);margin-top: 1rem;margin-bottom: 0.5rem;- line-height: 1.5;+ line-height: var(--h5-line-height, 1.5);}.rich-text-editor h6 {- font-size: var(--text-caption);- font-weight: 600;- color: var(--muted-foreground);+ font-family: var(--h6-font, var(--font-content));+ font-size: var(--h6-size, var(--text-caption));+ font-weight: var(--h6-weight, 600);+ font-style: var(--h6-style, normal);+ font-variant: var(--h6-variant, normal);+ letter-spacing: var(--h6-letter-spacing, normal);+ color: var(--h6-color, var(--muted-foreground));margin-top: 1rem;margin-bottom: 0.5rem;- line-height: 1.5;+ line-height: var(--h6-line-height, 1.5);}/* Paragraphs */.rich-text-editor p {- margin-top: 0.625rem;- margin-bottom: 0.625rem;- line-height: 1.625;+ margin-top: var(--paragraph-spacing, 0.625rem);+ margin-bottom: var(--paragraph-spacing, 0.625rem);+ line-height: var(--content-leading, 1.625);}/* First child should not have top margin */@@ -126,24 +155,24 @@/* Lists */.rich-text-editor ul {list-style-type: disc;- padding-inline-start: 1.25rem;+ padding-inline-start: var(--list-indent, 1.25rem);padding-inline-end: 0.5rem;margin: 0.5rem 0;}.rich-text-editor ol {list-style-type: decimal;- padding-inline-start: 1.5rem;+ padding-inline-start: var(--list-indent-ordered, 1.5rem);margin: 0.5rem 0;}.rich-text-editor li {- margin: 0.25rem 0;- line-height: 1.625;+ margin: var(--list-item-spacing, 0.25rem) 0;+ line-height: var(--content-leading, 1.625);}.rich-text-editor li + li {- margin-top: 0.25rem;+ margin-top: var(--list-item-spacing, 0.25rem);}/* Han, kana and Hangul fill the whole em square and carry no ascender or@@ -152,11 +181,11 @@language people write their issues and comments in. Table cells are listedso editable cells (text in a <p>) and readonly cells (bare text) stay equal. */.rich-text-editor :is(p, li, th, td):is(:lang(zh), :lang(ja), :lang(ko)) {- line-height: 1.75;+ line-height: var(--content-leading-cjk, 1.75);}.rich-text-editor li::marker {- color: var(--muted-foreground);+ color: var(--list-marker-color, var(--muted-foreground));}/* Remove paragraph margins inside list items (Tiptap wraps li content in <p>) */@@ -235,9 +264,9 @@/* Shared: checkbox appearance. */.rich-text-editor input[type="checkbox"] {- width: 0.95rem;- height: 0.95rem;- accent-color: var(--brand);+ width: var(--checkbox-size, 0.95rem);+ height: var(--checkbox-size, 0.95rem);+ accent-color: var(--checkbox-color, var(--brand));cursor: pointer;}@@ -277,7 +306,7 @@/* Completed editor item: muted text (no strikethrough), matching Linear. TheNodeView keeps `data-checked` on the <li> (but not data-type). */.rich-text-editor ul[data-type="taskList"] > li[data-checked="true"] > div {- color: var(--muted-foreground);+ color: var(--checklist-done-color, var(--muted-foreground));}/* --- Readonly (remark-gfm) --- */@@ -308,7 +337,7 @@reset keeps a completed parent from bleeding its muted color into the(independently evaluated) nested items below it. */.rich-text-editor li.task-list-item:has(> input:checked) {- color: var(--muted-foreground);+ color: var(--checklist-done-color, var(--muted-foreground));}.rich-text-editor li.task-list-item:has(> input:checked) .contains-task-list {@@ -319,8 +348,8 @@.rich-text-editor .tableWrapper {overflow-x: auto;margin: 1rem 0;- border: 1px solid var(--border);- border-radius: var(--radius);+ border: var(--table-border-width, 1px) solid var(--table-border-color, var(--border));+ border-radius: var(--table-radius, var(--radius));}.rich-text-editor table {@@ -342,11 +371,11 @@<tbody>, so the tr:has(> th) arm covers the editable table. */.rich-text-editor thead,.rich-text-editor tr:has(> th) {- background: color-mix(in srgb, var(--muted) 50%, transparent);+ background: var(--table-header-background, color-mix(in srgb, var(--muted) 50%, transparent));}.rich-text-editor tbody tr {- border-top: 1px solid var(--border);+ border-top: var(--table-border-width, 1px) solid var(--table-border-color, var(--border));}/* Tiptap tables have no <thead>, so their header row is tbody's first row —@@ -357,7 +386,7 @@}.rich-text-editor tr:hover td {- background: color-mix(in srgb, var(--muted) 30%, transparent);+ background: var(--table-row-hover-background, color-mix(in srgb, var(--muted) 30%, transparent));transition: background 0.15s;}@@ -365,7 +394,7 @@.rich-text-editor td {text-align: left;vertical-align: top;- padding: 0.5rem 0.75rem;+ padding: var(--table-cell-padding, 0.5rem 0.75rem);/* Chinese text may break between any two characters, so a column of itreports a one-character minimum and gets squeezed to that wheneveranother column wants the space. */@@ -375,14 +404,14 @@(which carries 1.625); the readonly render keeps bare text in the cell,which otherwise inherits the host's text-body line-height (~1.43) andmakes every readonly cell 2.5px shorter per line. */- line-height: 1.625;+ line-height: var(--content-leading, 1.625);}/* The header label sets its column's minimum width rather than wrapping. */.rich-text-editor th {font-size: var(--text-label);- font-weight: 500;- color: var(--muted-foreground);+ font-weight: var(--table-header-weight, 500);+ color: var(--table-header-color, var(--muted-foreground));white-space: nowrap;}@@ -508,11 +537,13 @@/* Blockquotes */.rich-text-editor blockquote {- border-left: 3px solid color-mix(in srgb, var(--muted-foreground) 30%, transparent);- padding-left: 0.75rem;+ border-left: var(--blockquote-border-width, 3px) solid+ var(--blockquote-border-color, color-mix(in srgb, var(--muted-foreground) 30%, transparent));+ padding-left: var(--blockquote-padding, 0.75rem);margin: 0.625rem 0;- color: var(--muted-foreground);- font-style: italic;+ color: var(--blockquote-color, var(--muted-foreground));+ background: var(--blockquote-background, transparent);+ font-style: var(--blockquote-style, italic);}.rich-text-editor blockquote p {@@ -537,21 +568,21 @@/* Horizontal rules */.rich-text-editor hr {border: none;- border-top: 1px solid var(--border);+ border-top: var(--hr-thickness, 1px) solid var(--hr-color, var(--border));margin: 1rem 0;}/* Links */.rich-text-editor a {- color: var(--brand);- text-decoration: underline;- text-decoration-color: color-mix(in srgb, var(--brand) 40%, transparent);- text-underline-offset: 2px;+ color: var(--link-color, var(--brand));+ text-decoration-line: var(--link-decoration, underline);+ text-decoration-color: var(--link-decoration-color, color-mix(in srgb, var(--brand) 40%, transparent));+ text-underline-offset: var(--link-underline-offset, 2px);cursor: pointer;}.rich-text-editor a:hover {- text-decoration-color: var(--brand);+ text-decoration-color: var(--link-decoration-color-hover, var(--brand));}/* Mention chips — inline cards that sit within text flow. The chip already@@ -571,8 +602,8 @@/* Mentions */.rich-text-editor .mention {- color: var(--primary);- font-weight: 600;+ color: var(--mention-color, var(--primary));+ font-weight: var(--mention-weight, 600);text-decoration: none;margin: 0 0.125rem;}@@ -587,17 +618,19 @@/* Strong / emphasis */.rich-text-editor strong {- font-weight: 600;+ font-weight: var(--bold-weight, 600);+ color: var(--bold-color, currentColor);}.rich-text-editor em {font-style: italic;+ color: var(--italic-color, currentColor);}.rich-text-editor s,.rich-text-editor del {text-decoration: line-through;- color: var(--muted-foreground);+ color: var(--strikethrough-color, var(--muted-foreground));}/* Text highlight (`==text==` → <mark>). Single yellow tint that stays legible@@ -605,9 +638,9 @@color so highlighted links/code remain readable. box-decoration-break clonesthe background across wrapped lines (same approach as inline code above). */.rich-text-editor mark {- background-color: color-mix(in srgb, #facc15 45%, transparent);+ background-color: var(--highlight-background, color-mix(in srgb, #facc15 45%, transparent));color: inherit;- border-radius: 0.2em;+ border-radius: var(--highlight-radius, 0.2em);padding: 0 0.15em;box-decoration-break: clone;-webkit-box-decoration-break: clone;diff --git a/packages/views/eslint.config.mjs b/packages/views/eslint.config.mjsindex 011093e3c9..53cf35290e 100644--- a/packages/views/eslint.config.mjs+++ b/packages/views/eslint.config.mjs@@ -1,5 +1,5 @@import reactConfig from "@multica/eslint-config/react";-import { ICON_LIBRARY_IMPORT_PATTERNS } from "@multica/eslint-config/base";+import { ICON_LIBRARY_IMPORT_PATTERNS, REDUCED_MOTION_IMPORT } from "@multica/eslint-config/base";import { NO_ROUND_CONTROLS } from "@multica/eslint-config/control-shape";import i18next from "eslint-plugin-i18next";import {@@ -50,7 +50,7 @@ export default ["no-restricted-imports": ["error",{- paths: STORE_FACTORY_IMPORTS,+ paths: [...STORE_FACTORY_IMPORTS, REDUCED_MOTION_IMPORT],patterns: ICON_LIBRARY_IMPORT_PATTERNS,},],diff --git a/packages/views/inbox/components/inbox-list-item.tsx b/packages/views/inbox/components/inbox-list-item.tsxindex 7b2e4d7a96..f4796c83d3 100644--- a/packages/views/inbox/components/inbox-list-item.tsx+++ b/packages/views/inbox/components/inbox-list-item.tsx@@ -100,6 +100,8 @@ export function InboxListItem({// are invalid HTML that screen readers cannot reach. `role="button"` plus// the Enter/Space handler keeps the row's own keyboard behavior.<div+ data-mc="inbox-item"+ data-read={item.read === true ? "true" : "false"}role="button"tabIndex={0}onClick={(e) => {diff --git a/packages/views/issues/components/board-card.tsx b/packages/views/issues/components/board-card.tsxindex af6e2a2d80..764990da0b 100644--- a/packages/views/issues/components/board-card.tsx+++ b/packages/views/issues/components/board-card.tsx@@ -198,7 +198,12 @@ export const BoardCardContent = memo(function BoardCardContent({const showRightMeta = !!showStartDate || !!showDueDate || !!showChildProgress || showUpdatedHint;return (- <div className="rounded-lg border-[0.5px] border-surface-border bg-surface py-3 px-2.5 shadow-[var(--surface-shadow)] transition-colors group-hover/card:border-foreground/15 group-hover/card:bg-surface-hover group-data-[popup-open]/card:border-foreground/15 group-data-[popup-open]/card:bg-surface-hover group-data-[peeked]/card:ring-2 group-data-[peeked]/card:ring-brand/50">+ <div+ data-mc="board-card"+ data-status={issue.status}+ data-priority={issue.priority}+ data-assignee-type={issue.assignee_type ?? "none"}+ className="rounded-board-card border-[0.5px] border-board-card-border bg-board-card py-3 px-2.5 shadow-[var(--board-card-shadow,var(--surface-shadow))] transition-colors group-hover/card:border-foreground/15 group-hover/card:bg-board-card-hover group-data-[popup-open]/card:border-foreground/15 group-data-[popup-open]/card:bg-board-card-hover group-data-[peeked]/card:ring-2 group-data-[peeked]/card:ring-brand/50">{/* Row 1: priority + identifier (left), agent activity + assignee (right) */}<div className="flex items-center justify-between gap-2"><div className="flex items-center gap-1.5 min-w-0">diff --git a/packages/views/issues/components/board-column.tsx b/packages/views/issues/components/board-column.tsxindex 7d4cadec21..aef4daf6a3 100644--- a/packages/views/issues/components/board-column.tsx+++ b/packages/views/issues/components/board-column.tsx@@ -202,8 +202,9 @@ export const BoardColumn = memo(function BoardColumn({return (<div+ data-mc="board-column"style={{ width: BOARD_COL_WIDTH }}- className={`group/column relative flex shrink-0 flex-col rounded-xl bg-muted/40 p-2 ${+ className={`group/column relative flex shrink-0 flex-col rounded-board-column bg-board-column p-2 ${hint ? "ring-2 ring-brand/30" : ""}`}>diff --git a/packages/views/issues/components/comment-card.tsx b/packages/views/issues/components/comment-card.tsxindex ef0957395e..dcdbf14f25 100644--- a/packages/views/issues/components/comment-card.tsx+++ b/packages/views/issues/components/comment-card.tsx@@ -1110,6 +1110,8 @@ function CommentCardImpl({of its own. */}{!isDeletedComment(reply) && (<div+ data-mc="comment-reply"+ data-author-type={reply.actor_type}id={`comment-${reply.id}`}className={cn("border-t border-border/50 transition-colors duration-700",@@ -1185,7 +1187,7 @@ function CommentCardImpl({// overflow-clip (not -hidden) clips the rounded corners WITHOUT creating a// scroll container, so the sticky collapse affordances below resolve to the// timeline's scroll parent instead of this card. See PR #3623.- <Card ref={annotation.cardRef} {...annotation.captureProps} className="!py-0 !gap-0 overflow-clip transition-colors duration-700">+ <Card data-mc="comment" data-author-type={entry.actor_type} ref={annotation.cardRef} {...annotation.captureProps} className="!py-0 !gap-0 overflow-clip transition-colors duration-700">{annotation.popup}{onCollapseResolved && (<buttondiff --git a/packages/views/issues/components/comment-input.tsx b/packages/views/issues/components/comment-input.tsxindex 100cdc53c7..8d0f586e6f 100644--- a/packages/views/issues/components/comment-input.tsx+++ b/packages/views/issues/components/comment-input.tsx@@ -231,6 +231,7 @@ function CommentInput({ issueId, onSubmit, onAccepted, onEditAnnotation, annotathasAllMembersMention={triggerPreview.hasAllMembersMention} draftContent={composedContent} onActionChange={setAction} />,})}<div+ data-mc="comment-composer"{...dropZoneProps}className="relative flex flex-col rounded-lg bg-card pb-8 ring-1 ring-border">diff --git a/packages/views/issues/components/issue-detail.test.tsx b/packages/views/issues/components/issue-detail.test.tsxindex 15de96e45d..962f104481 100644--- a/packages/views/issues/components/issue-detail.test.tsx+++ b/packages/views/issues/components/issue-detail.test.tsx@@ -2348,7 +2348,7 @@ describe("IssueDetail (shared)", () => {});const icon = statusChangeIcon("In Review");expect(icon.style.color).toBe("");- expect(icon.getAttribute("class")).toContain("text-success");+ expect(icon.getAttribute("class")).toContain("text-status-in-review");});it("truncates the trailing activity block to the most recent 8 entries with a show-more toggle", async () => {diff --git a/packages/views/issues/components/issue-peek.tsx b/packages/views/issues/components/issue-peek.tsxindex af801ce844..6e55903a37 100644--- a/packages/views/issues/components/issue-peek.tsx+++ b/packages/views/issues/components/issue-peek.tsx@@ -1,7 +1,8 @@"use client";import { memo, useEffect, useMemo, useRef, useState, type ReactNode, type RefObject } from "react";-import { AnimatePresence, motion, useIsPresent, useReducedMotion } from "motion/react";+import { AnimatePresence, motion, useIsPresent } from "motion/react";+import { useReducedMotion } from "@multica/core/appearance";import { ChevronDown, ChevronUp, Maximize2, X } from "@multica/ui/icons";import { Button, buttonVariants } from "@multica/ui/components/ui/button";import {@@ -141,7 +142,7 @@ const IssuePeekPanel = memo(function IssuePeekPanel({ issueId }: { issueId: stri// False while the exit animation plays: the closing panel no longer takes// clicks or keys, so the board is usable the moment the peek is dismissed.const isPresent = useIsPresent();- const reduceMotion = useReducedMotion() ?? false;+ const reduceMotion = useReducedMotion();return (<motion.aside@@ -216,7 +217,7 @@ function IssuePeekFollow({}) {const actions = useIssuePeekActions()!;const position = useIssuePeekPosition();- const reduceMotion = useReducedMotion() ?? false;+ const reduceMotion = useReducedMotion();// Read through a ref so the listener is bound once, not on every step.const positionRef = useRef(position);diff --git a/packages/views/issues/components/list-row.tsx b/packages/views/issues/components/list-row.tsxindex 9b146c4abe..507c1d947d 100644--- a/packages/views/issues/components/list-row.tsx+++ b/packages/views/issues/components/list-row.tsx@@ -90,14 +90,18 @@ function ListRowContent({<divref={containerRef}data-slot="issue-list-row"+ data-mc="issue-row"+ data-status={issue.status}+ data-priority={issue.priority}+ data-assignee-type={issue.assignee_type ?? "none"}{...{ [PEEK_TARGET_ATTR]: issue.id }}data-peeked={peeked ? "" : undefined}style={containerStyle}{...containerProps}- className={`group/row flex h-[var(--issue-row-height)] items-center gap-2 px-4 text-body transition-colors ${+ className={`group/row flex h-[var(--issue-row-height)] items-center gap-2 px-[var(--issue-row-padding-x,1rem)] text-body transition-colors ${selected- ? "bg-surface-selected hover:not-data-[popup-open]:bg-surface-selected data-[popup-open]:bg-surface-selected"- : "hover:not-data-[popup-open]:bg-surface-hover data-[popup-open]:bg-surface-hover"+ ? "bg-issue-row-selected hover:not-data-[popup-open]:bg-issue-row-selected data-[popup-open]:bg-issue-row-selected"+ : "hover:not-data-[popup-open]:bg-issue-row-hover data-[popup-open]:bg-issue-row-hover"} ${PEEKED_ROW_CLASS} ${isDragging ? "opacity-30" : ""}`}><div@@ -125,7 +129,7 @@ function ListRowContent({className={`flex flex-1 items-center gap-2 min-w-0 ${isDragging ? "pointer-events-none" : ""}`}{...peekLinkProps}>- <span className="min-w-16 shrink-0 text-caption text-muted-foreground">+ <span className="min-w-16 shrink-0 text-caption text-issue-row-identifier">{issue.identifier}</span><IssueAgentActivityIndicator issueId={issue.id} />diff --git a/packages/views/issues/components/list-view.tsx b/packages/views/issues/components/list-view.tsxindex a90753ead7..3eba1bf998 100644--- a/packages/views/issues/components/list-view.tsx+++ b/packages/views/issues/components/list-view.tsx@@ -596,7 +596,10 @@ function StatusAccordionItem({return (<Accordion.Item value={status} ref={dragEnabled ? setDroppableRef : undefined}><Accordion.Header- className={`group/header sticky top-0 z-10 flex h-10 items-center rounded-lg bg-muted transition-colors hover:bg-accent ${+ data-slot="issue-group-header"+ data-mc="issue-group-header"+ data-status={status}+ className={`group/header sticky top-0 z-10 flex h-[var(--issue-group-header-height,2.5rem)] items-center rounded-issue-group-header bg-issue-group-header transition-colors hover:bg-issue-group-header-hover ${isOver && !isExpanded? "ring-2 ring-brand/25 bg-accent/15": ""diff --git a/packages/views/issues/components/pickers/status-picker.test.tsx b/packages/views/issues/components/pickers/status-picker.test.tsxindex a1ae78da36..1ad8be9c58 100644--- a/packages/views/issues/components/pickers/status-picker.test.tsx+++ b/packages/views/issues/components/pickers/status-picker.test.tsx@@ -96,7 +96,7 @@ afterEach(() => {describe("StatusPicker trigger color", () => {// The bug: the trigger read the catalog entry's raw color while the list read// the resolved one, so a built-in rendered as the server's seeded #22c55e in- // one and as the `text-success` token in the other — the same status in two+ // one and as the `text-status-in-review` token in the other — the same status in two// visibly different greens, side by side. (MUL-6440)it("paints a built-in from the token, exactly like its row in the list", () => {catalogEntries = [IN_REVIEW, { ...QA, icon: "slash" }];@@ -111,8 +111,8 @@ describe("StatusPicker trigger color", () => {// the token and produces the two-greens mismatch.expect(trigger?.getAttribute("style")).toBeNull();expect(row?.getAttribute("style")).toBeNull();- expect(trigger?.getAttribute("class")).toContain("text-success");- expect(row?.getAttribute("class")).toContain("text-success");+ expect(trigger?.getAttribute("class")).toContain("text-status-in-review");+ expect(row?.getAttribute("class")).toContain("text-status-in-review");});// The other half of the same rule: a CUSTOM status has no token to fall backdiff --git a/packages/views/issues/components/priority-icon.tsx b/packages/views/issues/components/priority-icon.tsxindex 0db110d17b..34260bcb30 100644--- a/packages/views/issues/components/priority-icon.tsx+++ b/packages/views/issues/components/priority-icon.tsx@@ -24,8 +24,9 @@ export function PriorityIcon({if (!cfg || priority === "none") {return (<svg+ data-mc="priority-icon"viewBox="0 0 16 16"- className={`h-3.5 w-3.5 ${inheritColor ? "" : "text-muted-foreground"} shrink-0 ${className}`}+ className={`h-3.5 w-3.5 ${inheritColor ? "" : "text-priority-none"} shrink-0 ${className}`}fill="none"stroke="currentColor"strokeWidth="1.5"@@ -39,6 +40,7 @@ export function PriorityIcon({if (priority === "urgent") {return (<svg+ data-mc="priority-icon"viewBox="0 0 16 16"className={`h-3.5 w-3.5 ${inheritColor ? "" : cfg.color} shrink-0 ${className}`}fill="none"@@ -63,6 +65,7 @@ export function PriorityIcon({const BAR_HEIGHTS = [6, 9, 12];return (<svg+ data-mc="priority-icon"viewBox="0 0 16 16"className={`h-3.5 w-3.5 ${inheritColor ? "" : cfg.color} shrink-0 ${className}`}fill="currentColor"diff --git a/packages/views/issues/components/status-icon.test.tsx b/packages/views/issues/components/status-icon.test.tsxindex 1c2116ea48..affbf1661e 100644--- a/packages/views/issues/components/status-icon.test.tsx+++ b/packages/views/issues/components/status-icon.test.tsx@@ -41,6 +41,6 @@ describe("issue icons", () => {const { container } = render(<PriorityIcon priority="unexpected_priority" />);const icon = container.querySelector("svg");- expect(icon).toHaveClass("text-muted-foreground");+ expect(icon).toHaveClass("text-priority-none");});});diff --git a/packages/views/issues/components/status-icon.tsx b/packages/views/issues/components/status-icon.tsxindex d27ab5b6b9..867ef9e5e8 100644--- a/packages/views/issues/components/status-icon.tsx+++ b/packages/views/issues/components/status-icon.tsx@@ -168,13 +168,13 @@ const ICON_RENDERERS: Record<IssueStatusIcon, () => React.ReactNode> = {};const BUILT_IN_ICON_COLOR: Record<BuiltInIssueStatus, string> = {- backlog: "text-muted-foreground",- todo: "text-muted-foreground",- in_progress: "text-warning",- in_review: "text-success",- done: "text-info",- blocked: "text-destructive",- cancelled: "text-muted-foreground",+ backlog: "text-status-backlog",+ todo: "text-status-todo",+ in_progress: "text-status-in-progress",+ in_review: "text-status-in-review",+ done: "text-status-done",+ blocked: "text-status-blocked",+ cancelled: "text-status-cancelled",};// Public component@@ -215,6 +215,7 @@ export function StatusIcon({return (<svg+ data-mc="status-icon"viewBox="0 0 14 14"fill="none"style={useCustomColor ? { color: color ?? undefined } : undefined}diff --git a/packages/views/issues/components/thread-minimap.tsx b/packages/views/issues/components/thread-minimap.tsxindex 85878791d1..93d5de1bf8 100644--- a/packages/views/issues/components/thread-minimap.tsx+++ b/packages/views/issues/components/thread-minimap.tsx@@ -3,6 +3,7 @@ import { CheckCircle2, ChevronRight } from "@multica/ui/icons";import type { TimelineEntry } from "@multica/core/types";import { isDeletedComment } from "@multica/core/issues/comment-deletion";import { useActorName } from "@multica/core/workspace/hooks";+import { useReducedMotion } from "@multica/core/appearance";import { cn } from "@multica/ui/lib/utils";import { ActorAvatar } from "@multica/ui/components/common/actor-avatar";import { resolvePublicFileUrl } from "@multica/core/workspace/avatar-url";@@ -408,7 +409,11 @@ export function ThreadMinimap({// per frame. The same rect pass selects the corresponding outline row.const waveRafRef = useRef(0);const pointerYRef = useRef<number | null>(null);- const reducedMotionRef = useRef(false);+ const reducedMotion = useReducedMotion();+ const reducedMotionRef = useRef(reducedMotion);+ useEffect(() => {+ reducedMotionRef.current = reducedMotion;+ }, [reducedMotion]);const [preview, setPreview] = useState<PreviewAnchor | null>(null);const previewRef = useRef<PreviewAnchor | null>(null);@@ -424,7 +429,6 @@ export function ThreadMinimap({}, []);useEffect(() => {- reducedMotionRef.current = window.matchMedia("(prefers-reduced-motion: reduce)").matches;return () => {if (waveRafRef.current) cancelAnimationFrame(waveRafRef.current);if (openTimerRef.current !== null) window.clearTimeout(openTimerRef.current);diff --git a/packages/views/labels/label-chip.tsx b/packages/views/labels/label-chip.tsxindex 0aeb1899c3..0033060e7d 100644--- a/packages/views/labels/label-chip.tsx+++ b/packages/views/labels/label-chip.tsx@@ -59,11 +59,13 @@ export function LabelChip({ label, onRemove, className, fullName }: LabelChipProreturn (<spandata-slot="label-chip"+ data-mc="label-chip"+ data-color={label.color}// `min-w-0` lets the chip shrink when it is a flex item in a width-capped// container (the create toolbar's label pill). Without it the chip keeps// its content width and the parent clips it mid-shape; with it the inner// name truncates and the chip keeps its rounded ends.- className={`inline-flex min-w-0 items-center gap-1 rounded-full px-2 py-0.5 text-caption font-medium ${className ?? ""}`}+ className={`inline-flex min-w-0 items-center gap-1 rounded-label px-2 py-0.5 text-caption font-medium ${className ?? ""}`}style={{ backgroundColor: label.color, color: textColor }}// aria-label exposes the full name to screen readers when the span// visually truncates; sighted users get it from the hover tooltip,diff --git a/packages/views/layout/animated-right-sidebar.tsx b/packages/views/layout/animated-right-sidebar.tsxindex 450c40f5d6..330fef31ca 100644--- a/packages/views/layout/animated-right-sidebar.tsx+++ b/packages/views/layout/animated-right-sidebar.tsx@@ -9,6 +9,7 @@ import {type RefObject,} from "react";import { motion } from "motion/react";+import { useReducedMotion } from "@multica/core/appearance";import type { Layout, PanelSize } from "react-resizable-panels";import {isEditableShortcutTarget,@@ -132,6 +133,7 @@ export function AnimatedRightSidebar({className?: string;contentClassName?: string;}) {+ const reduceMotion = useReducedMotion();return (<motion.divanimate={{ opacity: open ? 1 : 0, x: open ? 0 : 12 }}@@ -147,7 +149,7 @@ export function AnimatedRightSidebar({className,)}initial={false}- transition={motionEnabled ? rightSidebarTransition : { duration: 0 }}+ transition={motionEnabled && !reduceMotion ? rightSidebarTransition : { duration: 0 }}><div className={contentClassName}>{children}</div></motion.div>diff --git a/packages/views/layout/app-rail.tsx b/packages/views/layout/app-rail.tsxindex ea1f7d2e1d..3da5246cde 100644--- a/packages/views/layout/app-rail.tsx+++ b/packages/views/layout/app-rail.tsx@@ -157,7 +157,7 @@ function RailSpaceLink({draggable={false}aria-current={active ? "page" : undefined}{...peekHandlers}- className="group relative flex size-12 flex-col items-center justify-center gap-1 rounded-xl text-muted-foreground transition-colors outline-none hover:bg-sidebar-accent/60 hover:text-sidebar-accent-foreground focus-visible:outline-2 focus-visible:outline-ring aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-sidebar-accent-foreground"+ className="group relative flex size-12 flex-col items-center justify-center gap-1 rounded-rail-item text-rail-item transition-colors outline-none hover:bg-rail-item-hover hover:text-rail-item-active-foreground focus-visible:outline-2 focus-visible:outline-ring aria-[current=page]:bg-rail-item-active aria-[current=page]:font-medium aria-[current=page]:text-rail-item-active-foreground"><Icon className="size-5" /><span className="max-w-full truncate px-0.5 text-micro leading-[14px]">{label}</span>@@ -278,6 +278,7 @@ export function AppRail({<navaria-label={t(($) => $.rail.label)}data-slot="app-rail"+ data-mc="app-rail"className={cn("flex h-full w-14 shrink-0 flex-col items-center overflow-y-auto overflow-x-hidden pt-[15px] pb-2.5 [scrollbar-width:none]",className,diff --git a/packages/views/layout/collection-list/collection-batch-bar.tsx b/packages/views/layout/collection-list/collection-batch-bar.tsxindex 30d2190ad0..bee088b91b 100644--- a/packages/views/layout/collection-list/collection-batch-bar.tsx+++ b/packages/views/layout/collection-list/collection-batch-bar.tsx@@ -1,7 +1,8 @@"use client";import type { ReactNode } from "react";-import { AnimatePresence, motion, useReducedMotion } from "motion/react";+import { AnimatePresence, motion } from "motion/react";+import { useReducedMotion } from "@multica/core/appearance";import { X } from "@multica/ui/icons";import { cn } from "@multica/ui/lib/utils";import { TooltipHint } from "@multica/ui/components/common/tooltip-hint";@@ -29,7 +30,7 @@ export function CollectionBatchBar({children: ReactNode;}) {const { t } = useT("layout");- const reduceMotion = useReducedMotion() ?? false;+ const reduceMotion = useReducedMotion();const offset = reduceMotion ? "translateY(0)" : "translateY(8px)";return (diff --git a/packages/views/layout/dashboard-layout.tsx b/packages/views/layout/dashboard-layout.tsxindex b9d37352d0..81f0f17dd4 100644--- a/packages/views/layout/dashboard-layout.tsx+++ b/packages/views/layout/dashboard-layout.tsx@@ -2,6 +2,7 @@import type { ReactNode } from "react";import { SidebarProvider } from "@multica/ui/components/ui/sidebar";+import { AppearanceSync } from "../common/appearance-sync";import { ModalRegistry } from "../modals/registry";import { SourceBackfillModal } from "../onboarding";import { AppRail } from "./app-rail";@@ -29,7 +30,7 @@ interface DashboardLayoutProps {*/export function AppShellCard({ children }: { children: ReactNode }) {return (- <main className="relative flex min-w-0 flex-1 flex-row overflow-hidden bg-page-canvas md:my-2 md:mr-2 md:rounded-xl md:shadow-[var(--surface-shadow)] md:ring-1 md:ring-surface-border">+ <main data-mc="page" className="relative flex min-w-0 flex-1 flex-row overflow-hidden bg-page-canvas md:my-2 md:mr-2 md:rounded-page md:shadow-[var(--page-shadow,var(--surface-shadow))] md:ring-1 md:ring-page-border"><SpacePanel /><div className="relative flex min-w-0 flex-1 flex-col overflow-hidden">{children}</div></main>@@ -42,30 +43,33 @@ export function DashboardLayout({loadingIndicator,}: DashboardLayoutProps) {return (- <DashboardGuard- loadingFallback={- <div className="flex h-svh items-center justify-center">- {loadingIndicator}- </div>- }- >- <SidebarProvider className="h-svh bg-app-shell [--sidebar-wrapper-fill:var(--app-shell)]">- <AppShellProvider>- <ShellRouteDataPrefetch>- <GlobalShortcuts />- <WorkspacePresencePrefetch />- <AppRail className="hidden md:flex" />- <CompactNavSheet />- <AppShellCard>- <NavigationProgress />- {children}- <ModalRegistry />- <SourceBackfillModal />- {extra}- </AppShellCard>- </ShellRouteDataPrefetch>- </AppShellProvider>- </SidebarProvider>- </DashboardGuard>+ <>+ <AppearanceSync />+ <DashboardGuard+ loadingFallback={+ <div className="flex h-svh items-center justify-center">+ {loadingIndicator}+ </div>+ }+ >+ <SidebarProvider className="h-svh bg-app-shell [--sidebar-wrapper-fill:var(--app-shell)]">+ <AppShellProvider>+ <ShellRouteDataPrefetch>+ <GlobalShortcuts />+ <WorkspacePresencePrefetch />+ <AppRail className="hidden md:flex" />+ <CompactNavSheet />+ <AppShellCard>+ <NavigationProgress />+ {children}+ <ModalRegistry />+ <SourceBackfillModal />+ {extra}+ </AppShellCard>+ </ShellRouteDataPrefetch>+ </AppShellProvider>+ </SidebarProvider>+ </DashboardGuard>+ </>);}diff --git a/packages/views/layout/panel-nav.tsx b/packages/views/layout/panel-nav.tsxindex af1b1e21dd..4cb5adc940 100644--- a/packages/views/layout/panel-nav.tsx+++ b/packages/views/layout/panel-nav.tsx@@ -148,12 +148,17 @@ export function PanelList({}export const PANEL_ROW_CLASS =- "flex min-h-8 w-full items-center gap-2.5 rounded-lg px-3 py-1.5 text-left text-body transition-colors outline-none focus-visible:outline-2 focus-visible:outline-ring";+ "flex min-h-[var(--nav-item-height,2rem)] w-full items-center gap-2.5 rounded-nav-item px-3 py-1.5 text-left text-body transition-colors outline-none focus-visible:outline-2 focus-visible:outline-ring";++/** The `nav-item` theme anchor; every row with an active state carries it. */+export function panelRowAnchor(active: boolean) {+ return { "data-mc": "nav-item", "data-active": active ? "true" : "false" } as const;+}export function panelRowStateClass(active: boolean) {return active- ? "bg-surface-selected text-surface-selected-foreground hover:bg-surface-selected"- : "text-muted-foreground hover:bg-surface-hover hover:text-foreground";+ ? "bg-nav-item-active text-nav-item-active-foreground hover:bg-nav-item-active"+ : "text-nav-item hover:bg-nav-item-hover hover:text-nav-item-hover-foreground";}export function PanelCount({ value, className }: { value: number; className?: string }) {@@ -197,6 +202,7 @@ export function PanelLink({newTabTitle={label}aria-current={active ? "page" : undefined}onClick={onNavigate}+ {...panelRowAnchor(active)}className={cn(PANEL_ROW_CLASS,panelRowStateClass(active),diff --git a/packages/views/layout/panels/pinned-section.tsx b/packages/views/layout/panels/pinned-section.tsxindex f57497d84d..9ec99836c8 100644--- a/packages/views/layout/panels/pinned-section.tsx+++ b/packages/views/layout/panels/pinned-section.tsx@@ -31,7 +31,7 @@ import { IssueActionsContextMenu } from "../../issues/actions";import { useStatusLabel } from "../../issues/utils/status-label";import { ProjectIcon } from "../../projects/components/project-icon";import { useT } from "../../i18n";-import { PANEL_ROW_CLASS, PanelList, PanelSection, isPathWithin, panelRowStateClass } from "../panel-nav";+import { PANEL_ROW_CLASS, PanelList, PanelSection, isPathWithin, panelRowAnchor, panelRowStateClass } from "../panel-nav";import { useDragClickGuard } from "../use-drag-click-guard";import {ISSUE_ROW_LINK_CLASS,@@ -230,6 +230,7 @@ function SortablePinItem({const row = (<div+ {...panelRowAnchor(active)}className={cn(PANEL_ROW_CLASS,panelRowStateClass(active),diff --git a/packages/views/layout/panels/sidebar-tree.tsx b/packages/views/layout/panels/sidebar-tree.tsxindex 0cca8755ad..107e8a4414 100644--- a/packages/views/layout/panels/sidebar-tree.tsx+++ b/packages/views/layout/panels/sidebar-tree.tsx@@ -28,7 +28,7 @@ import { selectIssueTasks } from "../../issues/surface/activity";import { useStatusLabel } from "../../issues/utils/status-label";import { DeferredPopup } from "../../common/deferred-popup";import { useT, useTimeAgo } from "../../i18n";-import { PANEL_ROW_CLASS, panelRowStateClass } from "../panel-nav";+import { PANEL_ROW_CLASS, panelRowAnchor, panelRowStateClass } from "../panel-nav";/** A working agent's issue title: dimmer at rest and a wider highlight than* the default shimmer, so the sweep reads at sidebar size. */@@ -99,6 +99,7 @@ export const TreeRow = forwardRef<HTMLAnchorElement, TreeRowProps>(function Treereturn (<div{...rowProps}+ {...panelRowAnchor(active)}ref={rowRef}data-located={located && !active ? "" : undefined}className={cn(@@ -528,6 +529,7 @@ const SidebarIssueRow = memo(function SidebarIssueRow({return (<IssueActionsContextMenu issue={issue}><div+ {...panelRowAnchor(active)}ref={rowRef}className={cn(TREE_CHILD_ROW_CLASS, panelRowStateClass(active), issueRowMenuOpenClass(active), "relative")}>diff --git a/packages/views/layout/panels/views-section.tsx b/packages/views/layout/panels/views-section.tsxindex bb99ab14ed..f0b1dcc49c 100644--- a/packages/views/layout/panels/views-section.tsx+++ b/packages/views/layout/panels/views-section.tsx@@ -62,7 +62,7 @@ import { UnreadViewIcon } from "../../issue-views/unread-view-icon";import { useBuiltinViewNavigation } from "../../issue-views/builtin-views";import { useNavigation } from "../../navigation";import { useT } from "../../i18n";-import { PANEL_ROW_CLASS, PanelCount, PanelLink, PanelList, PanelSection, isPathWithin, panelRowStateClass } from "../panel-nav";+import { PANEL_ROW_CLASS, PanelCount, PanelLink, PanelList, PanelSection, isPathWithin, panelRowAnchor, panelRowStateClass } from "../panel-nav";import { useDragClickGuard } from "../use-drag-click-guard";import { SidebarIssueList, TREE_ROW_BUTTON_CLASS, TreeRow } from "./sidebar-tree";@@ -566,7 +566,7 @@ function SavedViewRow({if (renaming) {return (- <div className={cn(PANEL_ROW_CLASS, panelRowStateClass(active), "py-1")}>+ <div {...panelRowAnchor(active)} className={cn(PANEL_ROW_CLASS, panelRowStateClass(active), "py-1")}><Layers className="size-4 shrink-0" /><ViewNameInputinitial={view.name}diff --git a/packages/views/layout/space-panel.tsx b/packages/views/layout/space-panel.tsxindex a529ae94ee..952bdffa47 100644--- a/packages/views/layout/space-panel.tsx+++ b/packages/views/layout/space-panel.tsx@@ -1,6 +1,6 @@"use client";-import { useRef } from "react";+import { useEffect, useRef } from "react";import type { AppSpaceId } from "@multica/core/paths";import { cn } from "@multica/ui/lib/utils";import { useSidebar } from "@multica/ui/components/ui/sidebar";@@ -46,6 +46,12 @@ export function SpacePanel() {const shell = useAppShell();const { open, isCompact } = useSidebar();const panelRef = useRef<HTMLElement>(null);+ useEffect(() => {+ // Public state hook for themes (docs/theming.md).+ const root = document.documentElement;+ root.classList.toggle("is-sidebar-collapsed", !open);+ return () => root.classList.remove("is-sidebar-collapsed");+ }, [open]);if (!shell) return null;if (isCompact) return <KeptRowsRelease />;@@ -63,6 +69,7 @@ export function SpacePanel() {key={space}ref={panelRef}data-slot="space-panel"+ data-mc="sidebar"data-state={open ? "expanded" : "collapsed"}inert={!open}className={cn(diff --git a/packages/views/locales/en/settings.json b/packages/views/locales/en/settings.jsonindex 1d1759b54a..471ba34912 100644--- a/packages/views/locales/en/settings.json+++ b/packages/views/locales/en/settings.json@@ -159,12 +159,6 @@"toast_saved": "Changes saved"},"preferences": {- "theme": {- "title": "Theme",- "light": "Light",- "dark": "Dark",- "system": "System"- },"language": {"title": "Language","english": "English",@@ -196,7 +190,6 @@},"comments_title": "Comments & chat","region_title": "Language & region",- "appearance_title": "Appearance","issue_fields_title": "Fields shown when creating issues","issue_fields": {"field": "Field",@@ -205,6 +198,105 @@"unsupported": "Not available when creating with an agent"}},+ "appearance": {+ "reset": "Reset to defaults",+ "color": {+ "title": "Color"+ },+ "mode": {+ "title": "Mode",+ "light": "Light",+ "dark": "Dark",+ "system": "System"+ },+ "theme": {+ "title": "Theme",+ "description": "Colors, borders, shadows and corners across the app.",+ "default": "Default",+ "pop": "Pop"+ },+ "theme_options": {+ "title": "Theme options",+ "description": "Provided by {{name}}.",+ "reset": "Reset options"+ },+ "ui_text": {+ "title": "Interface text",+ "description": "Menus, buttons, lists, the sidebar and headings."+ },+ "latin_font": {+ "title": "Latin font"+ },+ "ui_font": {+ "inter": "Default",+ "system": "System",+ "serif": "Serif",+ "mono": "Monospace"+ },+ "cjk_font": {+ "title": "CJK font",+ "description": "Chinese characters; Japanese and Korean follow it.",+ "sans": "Sans",+ "serif": "Serif",+ "kai": "Kai",+ "built_in": "Built in",+ "local": "On this device",+ "load_local": "Show fonts on this device…",+ "loading": "Looking for fonts…",+ "none": "No fonts with Chinese characters on this device.",+ "load_failed": "Couldn't read this device's fonts.",+ "sample": "永和九年 汉字"+ },+ "follow_ui": "Same as interface",+ "theme_font": "Theme font",+ "font_size": {+ "title": "Font size",+ "description": "Scales text only. Spacing and layout stay the same.",+ "value": "{{size}} px",+ "default": "{{size}} px · Default"+ },+ "content_text": {+ "title": "Content text",+ "description": "Issue descriptions, comments, chat and documents.",+ "sample": "Descriptions and comments are read in full, so they can use a font made for reading while lists and buttons stay compact."+ },+ "code_font": {+ "title": "Code font",+ "description": "Code blocks, inline code and logs.",+ "geist": "Default",+ "jetbrains": "Ligatures",+ "system": "System monospace"+ },+ "content_size": {+ "title": "Font size",+ "description": "Only content text; the interface keeps its size.",+ "follow": "Same as interface ({{size}} px)"+ },+ "content_leading": {+ "title": "Line height",+ "compact": "Compact",+ "default": "Default",+ "relaxed": "Relaxed"+ },+ "layout": {+ "title": "Layout and accessibility"+ },+ "density": {+ "title": "Density",+ "description": "Row height in issue lists and search.",+ "compact": "Compact",+ "default": "Default",+ "comfortable": "Comfortable"+ },+ "reduce_motion": {+ "title": "Reduce motion",+ "description": "Turn off animations and transitions. When off, your system setting still applies."+ },+ "high_contrast": {+ "title": "Increase contrast",+ "description": "Darker secondary text and stronger borders."+ }+ },"shortcuts": {"title": "Keyboard Shortcuts","description": "Click a shortcut, then press a new combination. Saved on this device.",@@ -396,6 +488,7 @@"tabs": {"profile": "Profile","preferences": "Preferences",+ "appearance": "Appearance","shortcuts": "Shortcuts","issue": "Issue","notifications": "Notifications",diff --git a/packages/views/locales/es/settings.json b/packages/views/locales/es/settings.jsonindex a9f2d095e2..852c0a4a14 100644--- a/packages/views/locales/es/settings.json+++ b/packages/views/locales/es/settings.json@@ -141,12 +141,6 @@"toast_saved": "Cambios guardados"},"preferences": {- "theme": {- "title": "Tema",- "light": "Claro",- "dark": "Oscuro",- "system": "Sistema"- },"language": {"title": "Idioma","english": "English",@@ -177,7 +171,6 @@"hint": "Solo establece el valor predeterminado. Puedes cambiarlo para cualquier mensaje antes de enviarlo."},"comments_title": "Comentarios",- "appearance_title": "Apariencia","issue_fields": {"field": "Campo","manual": "Creación manual",@@ -187,6 +180,105 @@"issue_fields_title": "Campos al crear tareas","region_title": "Idioma y región"},+ "appearance": {+ "reset": "Restablecer valores predeterminados",+ "color": {+ "title": "Color"+ },+ "mode": {+ "title": "Modo",+ "light": "Claro",+ "dark": "Oscuro",+ "system": "Sistema"+ },+ "theme": {+ "title": "Tema",+ "description": "Colores, bordes, sombras y esquinas de toda la app.",+ "default": "Predeterminado",+ "pop": "Pop"+ },+ "theme_options": {+ "title": "Opciones del tema",+ "description": "Las ofrece {{name}}.",+ "reset": "Restablecer opciones"+ },+ "ui_text": {+ "title": "Texto de la interfaz",+ "description": "Menús, botones, listas, la barra lateral y los títulos."+ },+ "latin_font": {+ "title": "Fuente latina"+ },+ "ui_font": {+ "inter": "Predeterminada",+ "system": "Sistema",+ "serif": "Serif",+ "mono": "Monoespaciada"+ },+ "cjk_font": {+ "title": "Fuente CJK",+ "description": "Caracteres chinos; el japonés y el coreano lo siguen.",+ "sans": "Sans",+ "serif": "Serif",+ "kai": "Kai",+ "built_in": "Integradas",+ "local": "En este dispositivo",+ "load_local": "Mostrar las fuentes de este dispositivo…",+ "loading": "Buscando fuentes…",+ "none": "No hay fuentes con caracteres chinos en este dispositivo.",+ "load_failed": "No se pudieron leer las fuentes de este dispositivo.",+ "sample": "永和九年 漢字"+ },+ "follow_ui": "Igual que la interfaz",+ "theme_font": "Fuente del tema",+ "font_size": {+ "title": "Tamaño del texto",+ "description": "Solo agranda el texto. El espaciado y el diseño no cambian.",+ "value": "{{size}} px",+ "default": "{{size}} px · Predeterminado"+ },+ "content_text": {+ "title": "Texto del contenido",+ "description": "Descripciones de incidencias, comentarios, chat y documentos.",+ "sample": "Las descripciones y los comentarios se leen enteros, así que pueden usar una fuente pensada para leer mientras listas y botones siguen compactos."+ },+ "code_font": {+ "title": "Fuente del código",+ "description": "Bloques de código, código en línea y registros.",+ "geist": "Predeterminada",+ "jetbrains": "Ligaduras",+ "system": "Monoespaciada del sistema"+ },+ "content_size": {+ "title": "Tamaño de letra",+ "description": "Solo el texto del contenido; la interfaz mantiene su tamaño.",+ "follow": "Igual que la interfaz ({{size}} px)"+ },+ "content_leading": {+ "title": "Interlineado",+ "compact": "Compacto",+ "default": "Predeterminado",+ "relaxed": "Amplio"+ },+ "layout": {+ "title": "Diseño y accesibilidad"+ },+ "density": {+ "title": "Densidad",+ "description": "Altura de las filas en listas de incidencias y búsqueda.",+ "compact": "Compacta",+ "default": "Predeterminada",+ "comfortable": "Amplia"+ },+ "reduce_motion": {+ "title": "Reducir movimiento",+ "description": "Desactiva animaciones y transiciones. Si está desactivado, se sigue aplicando el ajuste del sistema."+ },+ "high_contrast": {+ "title": "Aumentar contraste",+ "description": "Texto secundario más oscuro y bordes más marcados."+ }+ },"shortcuts": {"title": "Atajos de teclado","description": "Haz clic en un atajo y pulsa una nueva combinación. Se guarda en este dispositivo.",@@ -378,6 +470,7 @@"tabs": {"profile": "Perfil","preferences": "Preferencias",+ "appearance": "Apariencia","shortcuts": "Atajos","issue": "Tarea","notifications": "Notificaciones",diff --git a/packages/views/locales/fr/settings.json b/packages/views/locales/fr/settings.jsonindex afbe8bac6b..b2e21f7d62 100644--- a/packages/views/locales/fr/settings.json+++ b/packages/views/locales/fr/settings.json@@ -159,12 +159,6 @@"toast_saved": "Modifications enregistrées"},"preferences": {- "theme": {- "title": "Thème",- "light": "Clair",- "dark": "Sombre",- "system": "Système"- },"language": {"title": "Langue","english": "English",@@ -196,7 +190,6 @@},"comments_title": "Commentaires et discussion","region_title": "Langue et région",- "appearance_title": "Apparence","issue_fields_title": "Champs affichés à la création de tâches","issue_fields": {"field": "Champ",@@ -205,6 +198,105 @@"unsupported": "Indisponible lors de la création avec un agent"}},+ "appearance": {+ "reset": "Rétablir les valeurs par défaut",+ "color": {+ "title": "Couleur"+ },+ "mode": {+ "title": "Mode",+ "light": "Clair",+ "dark": "Sombre",+ "system": "Système"+ },+ "theme": {+ "title": "Thème",+ "description": "Couleurs, bordures, ombres et coins de toute l’app.",+ "default": "Par défaut",+ "pop": "Pop"+ },+ "theme_options": {+ "title": "Options du thème",+ "description": "Proposées par {{name}}.",+ "reset": "Réinitialiser les options"+ },+ "ui_text": {+ "title": "Texte de l’interface",+ "description": "Menus, boutons, listes, barre latérale et titres."+ },+ "latin_font": {+ "title": "Police latine"+ },+ "ui_font": {+ "inter": "Par défaut",+ "system": "Système",+ "serif": "Serif",+ "mono": "Chasse fixe"+ },+ "cjk_font": {+ "title": "Police CJK",+ "description": "Caractères chinois ; le japonais et le coréen suivent ce réglage.",+ "sans": "Sans",+ "serif": "Serif",+ "kai": "Kai",+ "built_in": "Intégrées",+ "local": "Sur cet appareil",+ "load_local": "Afficher les polices de cet appareil…",+ "loading": "Recherche des polices…",+ "none": "Aucune police avec des caractères chinois sur cet appareil.",+ "load_failed": "Impossible de lire les polices de cet appareil.",+ "sample": "永和九年 漢字"+ },+ "follow_ui": "Comme l’interface",+ "theme_font": "Police du thème",+ "font_size": {+ "title": "Taille du texte",+ "description": "Agrandit uniquement le texte. Les espacements et la mise en page restent identiques.",+ "value": "{{size}} px",+ "default": "{{size}} px · Par défaut"+ },+ "content_text": {+ "title": "Texte du contenu",+ "description": "Descriptions de tickets, commentaires, chat et documents.",+ "sample": "Les descriptions et commentaires se lisent en entier : ils peuvent utiliser une police faite pour la lecture, tandis que listes et boutons restent compacts."+ },+ "code_font": {+ "title": "Police du code",+ "description": "Blocs de code, code en ligne et journaux.",+ "geist": "Par défaut",+ "jetbrains": "Ligatures",+ "system": "Chasse fixe système"+ },+ "content_size": {+ "title": "Taille du texte",+ "description": "Seulement le texte du contenu ; l’interface garde sa taille.",+ "follow": "Comme l’interface ({{size}} px)"+ },+ "content_leading": {+ "title": "Interligne",+ "compact": "Serré",+ "default": "Par défaut",+ "relaxed": "Aéré"+ },+ "layout": {+ "title": "Mise en page et accessibilité"+ },+ "density": {+ "title": "Densité",+ "description": "Hauteur des lignes dans les listes de tickets et la recherche.",+ "compact": "Compacte",+ "default": "Par défaut",+ "comfortable": "Aérée"+ },+ "reduce_motion": {+ "title": "Réduire les animations",+ "description": "Désactive les animations et transitions. Désactivé, le réglage du système s’applique toujours."+ },+ "high_contrast": {+ "title": "Augmenter le contraste",+ "description": "Texte secondaire plus foncé et bordures plus marquées."+ }+ },"shortcuts": {"title": "Raccourcis clavier","description": "Cliquez sur un raccourci, puis appuyez sur une nouvelle combinaison. Enregistré sur cet appareil.",@@ -396,6 +488,7 @@"tabs": {"profile": "Profil","preferences": "Préférences",+ "appearance": "Apparence","shortcuts": "Raccourcis","issue": "Tâche","notifications": "Notifications",diff --git a/packages/views/locales/ja/settings.json b/packages/views/locales/ja/settings.jsonindex 56ea1c1528..e88807e1c9 100644--- a/packages/views/locales/ja/settings.json+++ b/packages/views/locales/ja/settings.json@@ -157,12 +157,6 @@"toast_saved": "変更を保存しました"},"preferences": {- "theme": {- "title": "テーマ",- "light": "ライト",- "dark": "ダーク",- "system": "システム"- },"language": {"title": "言語","english": "English",@@ -194,7 +188,6 @@},"comments_title": "コメントとチャット","region_title": "言語と地域",- "appearance_title": "外観","issue_fields_title": "タスク作成時に表示するフィールド","issue_fields": {"field": "フィールド",@@ -203,6 +196,105 @@"unsupported": "エージェントでの作成では使用できません"}},+ "appearance": {+ "reset": "デフォルトに戻す",+ "color": {+ "title": "カラー"+ },+ "mode": {+ "title": "モード",+ "light": "ライト",+ "dark": "ダーク",+ "system": "システム"+ },+ "theme": {+ "title": "テーマ",+ "description": "アプリ全体の色、枠線、影、角丸。",+ "default": "デフォルト",+ "pop": "ポップ"+ },+ "theme_options": {+ "title": "テーマのオプション",+ "description": "{{name}} が提供しています。",+ "reset": "オプションをリセット"+ },+ "ui_text": {+ "title": "インターフェースの文字",+ "description": "メニュー、ボタン、リスト、サイドバー、見出し。"+ },+ "latin_font": {+ "title": "欧文フォント"+ },+ "ui_font": {+ "inter": "デフォルト",+ "system": "システム",+ "serif": "セリフ",+ "mono": "等幅"+ },+ "cjk_font": {+ "title": "和文フォント",+ "description": "漢字の字形。仮名とハングルもこれに従います。",+ "sans": "ゴシック",+ "serif": "明朝",+ "kai": "楷書",+ "built_in": "標準",+ "local": "このデバイス",+ "load_local": "このデバイスのフォントを表示…",+ "loading": "フォントを探しています…",+ "none": "このデバイスに漢字を含むフォントはありません。",+ "load_failed": "このデバイスのフォントを読み込めませんでした。",+ "sample": "永和九年 いろは"+ },+ "follow_ui": "インターフェースと同じ",+ "theme_font": "テーマのフォント",+ "font_size": {+ "title": "文字サイズ",+ "description": "文字だけを拡大します。余白とレイアウトは変わりません。",+ "value": "{{size}} px",+ "default": "{{size}} px · デフォルト"+ },+ "content_text": {+ "title": "本文の文字",+ "description": "課題の説明、コメント、チャット、ドキュメントの本文。",+ "sample": "説明やコメントはじっくり読むものなので、読みやすい書体にできます。リストやボタンはコンパクトなままです。"+ },+ "code_font": {+ "title": "コードフォント",+ "description": "コードブロック、インラインコード、ログ。",+ "geist": "デフォルト",+ "jetbrains": "合字",+ "system": "システム等幅"+ },+ "content_size": {+ "title": "文字サイズ",+ "description": "本文だけ。インターフェースは変わりません。",+ "follow": "インターフェースと同じ({{size}} px)"+ },+ "content_leading": {+ "title": "行の高さ",+ "compact": "詰める",+ "default": "標準",+ "relaxed": "ゆったり"+ },+ "layout": {+ "title": "レイアウトとアクセシビリティ"+ },+ "density": {+ "title": "表示密度",+ "description": "課題リストと検索結果の行の高さ。",+ "compact": "コンパクト",+ "default": "標準",+ "comfortable": "ゆったり"+ },+ "reduce_motion": {+ "title": "視差効果を減らす",+ "description": "アニメーションとトランジションをオフにします。オフでもシステム設定は適用されます。"+ },+ "high_contrast": {+ "title": "コントラストを上げる",+ "description": "補助テキストを濃く、枠線をはっきりさせます。"+ }+ },"shortcuts": {"title": "キーボードショートカット","description": "ショートカットをクリックし、新しいキーを押します。このデバイスに保存されます。",@@ -394,6 +486,7 @@"tabs": {"profile": "プロフィール","preferences": "環境設定",+ "appearance": "外観","shortcuts": "ショートカット","issue": "タスク","notifications": "通知",diff --git a/packages/views/locales/ko/settings.json b/packages/views/locales/ko/settings.jsonindex 34d6460f06..bdd2de4950 100644--- a/packages/views/locales/ko/settings.json+++ b/packages/views/locales/ko/settings.json@@ -157,12 +157,6 @@"toast_saved": "변경사항을 저장했습니다"},"preferences": {- "theme": {- "title": "테마",- "light": "라이트",- "dark": "다크",- "system": "시스템"- },"language": {"title": "언어","english": "English",@@ -194,7 +188,6 @@},"comments_title": "댓글 및 채팅","region_title": "언어 및 지역",- "appearance_title": "모양","issue_fields_title": "태스크 생성 시 표시할 필드","issue_fields": {"field": "필드",@@ -203,6 +196,105 @@"unsupported": "에이전트로 생성할 때는 사용할 수 없습니다"}},+ "appearance": {+ "reset": "기본값으로 재설정",+ "color": {+ "title": "색상"+ },+ "mode": {+ "title": "모드",+ "light": "라이트",+ "dark": "다크",+ "system": "시스템"+ },+ "theme": {+ "title": "테마",+ "description": "앱 전체의 색상, 테두리, 그림자, 모서리.",+ "default": "기본",+ "pop": "팝"+ },+ "theme_options": {+ "title": "테마 옵션",+ "description": "{{name}}에서 제공해요.",+ "reset": "옵션 초기화"+ },+ "ui_text": {+ "title": "인터페이스 글자",+ "description": "메뉴, 버튼, 목록, 사이드바, 제목."+ },+ "latin_font": {+ "title": "라틴 글꼴"+ },+ "ui_font": {+ "inter": "기본",+ "system": "시스템",+ "serif": "세리프",+ "mono": "고정폭"+ },+ "cjk_font": {+ "title": "CJK 글꼴",+ "description": "한자 글꼴. 일본어와 한국어도 이 설정을 따라요.",+ "sans": "고딕",+ "serif": "명조",+ "kai": "해서",+ "built_in": "기본",+ "local": "이 기기",+ "load_local": "이 기기의 글꼴 보기…",+ "loading": "글꼴을 찾는 중…",+ "none": "이 기기에 한자가 있는 글꼴이 없어요.",+ "load_failed": "이 기기의 글꼴을 읽을 수 없어요.",+ "sample": "永和九年 한글"+ },+ "follow_ui": "인터페이스와 같게",+ "theme_font": "테마 글꼴",+ "font_size": {+ "title": "글꼴 크기",+ "description": "텍스트만 확대합니다. 간격과 레이아웃은 그대로입니다.",+ "value": "{{size}} px",+ "default": "{{size}} px · 기본"+ },+ "content_text": {+ "title": "본문 글자",+ "description": "이슈 설명, 댓글, 채팅, 문서의 본문.",+ "sample": "설명과 댓글은 길게 읽으니 읽기 좋은 글꼴로 바꿀 수 있어요. 목록과 버튼은 그대로 촘촘하게 유지돼요."+ },+ "code_font": {+ "title": "코드 글꼴",+ "description": "코드 블록, 인라인 코드, 로그.",+ "geist": "기본",+ "jetbrains": "합자",+ "system": "시스템 고정폭"+ },+ "content_size": {+ "title": "글자 크기",+ "description": "본문만 바뀌고 인터페이스는 그대로예요.",+ "follow": "인터페이스와 같게 ({{size}}px)"+ },+ "content_leading": {+ "title": "줄 간격",+ "compact": "좁게",+ "default": "기본",+ "relaxed": "넓게"+ },+ "layout": {+ "title": "레이아웃 및 접근성"+ },+ "density": {+ "title": "밀도",+ "description": "이슈 목록과 검색 결과의 행 높이.",+ "compact": "좁게",+ "default": "기본",+ "comfortable": "넓게"+ },+ "reduce_motion": {+ "title": "동작 줄이기",+ "description": "애니메이션과 전환 효과를 끕니다. 꺼져 있어도 시스템 설정은 적용됩니다."+ },+ "high_contrast": {+ "title": "대비 높이기",+ "description": "보조 텍스트를 진하게, 테두리를 뚜렷하게 합니다."+ }+ },"shortcuts": {"title": "키보드 단축키","description": "단축키를 클릭하고 새 키 조합을 누르세요. 이 기기에 저장됩니다.",@@ -394,6 +486,7 @@"tabs": {"profile": "프로필","preferences": "환경설정",+ "appearance": "모양","shortcuts": "단축키","issue": "태스크","notifications": "알림",diff --git a/packages/views/locales/ru/settings.json b/packages/views/locales/ru/settings.jsonindex e3887c50d6..7e9545e8b0 100644--- a/packages/views/locales/ru/settings.json+++ b/packages/views/locales/ru/settings.json@@ -162,12 +162,6 @@"toast_saved": "Изменения сохранены"},"preferences": {- "theme": {- "title": "Тема",- "light": "Светлая",- "dark": "Тёмная",- "system": "Системная"- },"language": {"title": "Язык","english": "English",@@ -199,7 +193,6 @@},"comments_title": "Комментарии и чат","region_title": "Язык и регион",- "appearance_title": "Внешний вид","issue_fields_title": "Поля, отображаемые при создании задач","issue_fields": {"field": "Поле",@@ -208,6 +201,105 @@"unsupported": "Недоступно при создании с агентом"}},+ "appearance": {+ "reset": "Сбросить настройки",+ "color": {+ "title": "Цвет"+ },+ "mode": {+ "title": "Режим",+ "light": "Светлый",+ "dark": "Тёмный",+ "system": "Системный"+ },+ "theme": {+ "title": "Тема",+ "description": "Цвета, границы, тени и скругления во всём приложении.",+ "default": "По умолчанию",+ "pop": "Pop"+ },+ "theme_options": {+ "title": "Параметры темы",+ "description": "Предоставлено темой {{name}}.",+ "reset": "Сбросить параметры"+ },+ "ui_text": {+ "title": "Текст интерфейса",+ "description": "Меню, кнопки, списки, боковая панель и заголовки."+ },+ "latin_font": {+ "title": "Латинский шрифт"+ },+ "ui_font": {+ "inter": "По умолчанию",+ "system": "Системный",+ "serif": "С засечками",+ "mono": "Моноширинный"+ },+ "cjk_font": {+ "title": "Шрифт CJK",+ "description": "Китайские иероглифы; японский и корейский следуют этому выбору.",+ "sans": "Без засечек",+ "serif": "С засечками",+ "kai": "Кайшу",+ "built_in": "Встроенные",+ "local": "На этом устройстве",+ "load_local": "Показать шрифты на этом устройстве…",+ "loading": "Поиск шрифтов…",+ "none": "На этом устройстве нет шрифтов с китайскими иероглифами.",+ "load_failed": "Не удалось прочитать шрифты этого устройства.",+ "sample": "永和九年 汉字"+ },+ "follow_ui": "Как в интерфейсе",+ "theme_font": "Шрифт темы",+ "font_size": {+ "title": "Размер шрифта",+ "description": "Меняет только текст. Отступы и раскладка остаются прежними.",+ "value": "{{size}} px",+ "default": "{{size}} px · По умолчанию"+ },+ "content_text": {+ "title": "Текст содержимого",+ "description": "Описания задач, комментарии, чат и документы.",+ "sample": "Описания и комментарии читают целиком, поэтому для них можно выбрать шрифт для чтения, а списки и кнопки останутся компактными."+ },+ "code_font": {+ "title": "Шрифт кода",+ "description": "Блоки кода, встроенный код и журналы.",+ "geist": "По умолчанию",+ "jetbrains": "С лигатурами",+ "system": "Системный моноширинный"+ },+ "content_size": {+ "title": "Размер шрифта",+ "description": "Только текст содержимого; интерфейс сохраняет свой размер.",+ "follow": "Как в интерфейсе ({{size}} px)"+ },+ "content_leading": {+ "title": "Межстрочный интервал",+ "compact": "Плотный",+ "default": "По умолчанию",+ "relaxed": "Свободный"+ },+ "layout": {+ "title": "Макет и доступность"+ },+ "density": {+ "title": "Плотность",+ "description": "Высота строк в списках задач и поиске.",+ "compact": "Компактная",+ "default": "По умолчанию",+ "comfortable": "Свободная"+ },+ "reduce_motion": {+ "title": "Уменьшить движение",+ "description": "Отключает анимации и переходы. Когда выключено, действует системная настройка."+ },+ "high_contrast": {+ "title": "Повысить контраст",+ "description": "Более тёмный второстепенный текст и чёткие границы."+ }+ },"shortcuts": {"title": "Горячие клавиши","description": "Настройте действия продукта на этом устройстве. Нажмите на сочетание клавиш, затем введите новую комбинацию.",@@ -399,6 +491,7 @@"tabs": {"profile": "Профиль","preferences": "Настройки",+ "appearance": "Внешний вид","shortcuts": "Горячие клавиши","issue": "Задачи","notifications": "Уведомления",diff --git a/packages/views/locales/zh-Hans/settings.json b/packages/views/locales/zh-Hans/settings.jsonindex d9e86e566d..cb0fbf8394 100644--- a/packages/views/locales/zh-Hans/settings.json+++ b/packages/views/locales/zh-Hans/settings.json@@ -157,12 +157,6 @@"toast_saved": "更改已保存"},"preferences": {- "theme": {- "title": "主题",- "light": "浅色",- "dark": "深色",- "system": "跟随系统"- },"language": {"title": "语言","english": "English",@@ -194,7 +188,6 @@},"comments_title": "评论与聊天","region_title": "语言与地区",- "appearance_title": "外观","issue_fields_title": "创建任务时显示的字段","issue_fields": {"field": "字段",@@ -203,6 +196,105 @@"unsupported": "智能体创建时不支持此字段"}},+ "appearance": {+ "reset": "恢复默认",+ "color": {+ "title": "颜色"+ },+ "mode": {+ "title": "模式",+ "light": "浅色",+ "dark": "深色",+ "system": "跟随系统"+ },+ "theme": {+ "title": "主题",+ "description": "全局的颜色、边框、阴影和圆角。",+ "default": "默认",+ "pop": "波普"+ },+ "theme_options": {+ "title": "主题选项",+ "description": "由 {{name}} 提供。",+ "reset": "恢复主题默认"+ },+ "ui_text": {+ "title": "界面文字",+ "description": "菜单、按钮、列表、侧栏和标题。"+ },+ "latin_font": {+ "title": "西文字体"+ },+ "ui_font": {+ "inter": "默认",+ "system": "系统",+ "serif": "衬线",+ "mono": "等宽"+ },+ "cjk_font": {+ "title": "中文字体",+ "description": "汉字字形;日文、韩文跟着这里走。",+ "sans": "黑体",+ "serif": "宋体",+ "kai": "楷体",+ "built_in": "常用",+ "local": "本机字体",+ "load_local": "显示本机字体…",+ "loading": "正在查找字体…",+ "none": "这台设备上没有含汉字的字体。",+ "load_failed": "无法读取本机字体。",+ "sample": "永和九年,岁在癸丑"+ },+ "follow_ui": "跟随界面",+ "theme_font": "主题字体",+ "font_size": {+ "title": "字号",+ "description": "只放大文字,间距和布局不变。",+ "value": "{{size}} px",+ "default": "{{size}} px · 默认"+ },+ "content_text": {+ "title": "内容文字",+ "description": "任务描述、评论、对话和文档里的正文。",+ "sample": "描述和评论需要整段阅读,可以换成更适合阅读的字体;列表和按钮仍然保持紧凑。"+ },+ "code_font": {+ "title": "代码字体",+ "description": "代码块、行内代码和日志。",+ "geist": "默认",+ "jetbrains": "连字",+ "system": "系统等宽"+ },+ "content_size": {+ "title": "字号",+ "description": "只改内容文字,界面不变。",+ "follow": "跟随界面({{size}} px)"+ },+ "content_leading": {+ "title": "行高",+ "compact": "紧凑",+ "default": "标准",+ "relaxed": "宽松"+ },+ "layout": {+ "title": "布局与辅助功能"+ },+ "density": {+ "title": "信息密度",+ "description": "任务列表和搜索结果的行高。",+ "compact": "紧凑",+ "default": "标准",+ "comfortable": "宽松"+ },+ "reduce_motion": {+ "title": "减少动态效果",+ "description": "关闭动画和过渡。关掉时仍遵循系统设置。"+ },+ "high_contrast": {+ "title": "提高对比度",+ "description": "次要文字更深,边框更明显。"+ }+ },"shortcuts": {"title": "快捷键","description": "点击快捷键后按下新组合键;仅保存在本设备。",@@ -394,6 +486,7 @@"tabs": {"profile": "个人资料","preferences": "偏好设置",+ "appearance": "外观","shortcuts": "快捷键","issue": "任务","notifications": "通知",diff --git a/packages/views/locales/zh-Hant/settings.json b/packages/views/locales/zh-Hant/settings.jsonindex a842666df9..754b5800cc 100644--- a/packages/views/locales/zh-Hant/settings.json+++ b/packages/views/locales/zh-Hant/settings.json@@ -157,12 +157,6 @@"toast_saved": "更改已儲存"},"preferences": {- "theme": {- "title": "主題",- "light": "淺色",- "dark": "深色",- "system": "跟隨系統"- },"language": {"title": "語言","english": "English",@@ -194,7 +188,6 @@},"comments_title": "評論與聊天","region_title": "語言與地區",- "appearance_title": "外觀","issue_fields_title": "建立任務時顯示的欄位","issue_fields": {"field": "欄位",@@ -203,6 +196,105 @@"unsupported": "AI 代理建立時不支援此欄位"}},+ "appearance": {+ "reset": "恢復預設",+ "color": {+ "title": "顏色"+ },+ "mode": {+ "title": "模式",+ "light": "淺色",+ "dark": "深色",+ "system": "跟隨系統"+ },+ "theme": {+ "title": "主題",+ "description": "全域的顏色、邊框、陰影和圓角。",+ "default": "預設",+ "pop": "普普"+ },+ "theme_options": {+ "title": "主題選項",+ "description": "由 {{name}} 提供。",+ "reset": "恢復主題預設"+ },+ "ui_text": {+ "title": "介面文字",+ "description": "選單、按鈕、列表、側欄和標題。"+ },+ "latin_font": {+ "title": "西文字體"+ },+ "ui_font": {+ "inter": "預設",+ "system": "系統",+ "serif": "襯線",+ "mono": "等寬"+ },+ "cjk_font": {+ "title": "中文字體",+ "description": "漢字字形;日文、韓文跟著這裡走。",+ "sans": "黑體",+ "serif": "宋體",+ "kai": "楷體",+ "built_in": "常用",+ "local": "本機字體",+ "load_local": "顯示本機字體…",+ "loading": "正在尋找字體…",+ "none": "這台裝置上沒有含漢字的字體。",+ "load_failed": "無法讀取本機字體。",+ "sample": "永和九年,歲在癸丑"+ },+ "follow_ui": "跟隨介面",+ "theme_font": "主題字體",+ "font_size": {+ "title": "字級",+ "description": "只放大文字,間距和版面不變。",+ "value": "{{size}} px",+ "default": "{{size}} px · 預設"+ },+ "content_text": {+ "title": "內容文字",+ "description": "任務描述、留言、對話和文件裡的正文。",+ "sample": "描述和留言需要整段閱讀,可以換成更適合閱讀的字體;列表和按鈕仍然保持緊湊。"+ },+ "code_font": {+ "title": "程式碼字體",+ "description": "程式碼區塊、行內程式碼和日誌。",+ "geist": "預設",+ "jetbrains": "連字",+ "system": "系統等寬"+ },+ "content_size": {+ "title": "字級",+ "description": "只改內容文字,介面不變。",+ "follow": "跟隨介面({{size}} px)"+ },+ "content_leading": {+ "title": "行高",+ "compact": "緊湊",+ "default": "標準",+ "relaxed": "寬鬆"+ },+ "layout": {+ "title": "版面與輔助功能"+ },+ "density": {+ "title": "資訊密度",+ "description": "任務清單和搜尋結果的列高。",+ "compact": "緊湊",+ "default": "標準",+ "comfortable": "寬鬆"+ },+ "reduce_motion": {+ "title": "減少動態效果",+ "description": "關閉動畫和轉場。關閉時仍遵循系統設定。"+ },+ "high_contrast": {+ "title": "提高對比",+ "description": "次要文字更深,邊框更明顯。"+ }+ },"shortcuts": {"title": "快捷鍵","description": "點選快捷鍵後按下新組合鍵;僅儲存在本裝置。",@@ -394,6 +486,7 @@"tabs": {"profile": "個人資料","preferences": "偏好設定",+ "appearance": "外觀","shortcuts": "快捷鍵","issue": "任務","notifications": "通知",diff --git a/packages/views/onboarding/source-backfill-modal.tsx b/packages/views/onboarding/source-backfill-modal.tsxindex 07e5860142..6640bd1a74 100644--- a/packages/views/onboarding/source-backfill-modal.tsx+++ b/packages/views/onboarding/source-backfill-modal.tsx@@ -13,6 +13,7 @@ import {} from "@multica/ui/icons";import { toast } from "sonner";import { useAuthStore } from "@multica/core/auth";+import { prefersReducedMotion } from "@multica/core/appearance";import {agentCompletedIssueCountOptions,needsSourceBackfill,@@ -108,12 +109,9 @@ export function SourceBackfillModal() {// the modal floats in, so it doesn't feel like a hard block. Common// delight pattern — ~700ms is short enough that nobody starts an// interaction first but long enough that the workspace renders.- // Honour `prefers-reduced-motion: reduce`: those users have opted- // out of incidental animations, so open immediately.- const reducedMotion =- typeof window !== "undefined" &&- window.matchMedia?.("(prefers-reduced-motion: reduce)").matches === true;- if (reducedMotion) {+ // People who reduce motion have opted out of incidental animations,+ // so open immediately.+ if (prefersReducedMotion()) {openedForUserRef.current = user.id;setOpen(true);return;diff --git a/packages/views/package.json b/packages/views/package.jsonindex 11ded9d9e2..c8951def4a 100644--- a/packages/views/package.json+++ b/packages/views/package.json@@ -11,6 +11,7 @@"exports": {"./navigation": "./navigation/index.ts","./common/actor-avatar": "./common/actor-avatar.tsx",+ "./common/appearance-sync": "./common/appearance-sync.tsx","./common/cli-install-command": "./common/cli-install-command.tsx","./common/shortcut-keycaps": "./common/shortcut-keycaps.tsx","./editor": "./editor/index.ts",diff --git a/packages/views/rich-content/rich-content.tsx b/packages/views/rich-content/rich-content.tsxindex 54369bf480..5a1aa3f70b 100644--- a/packages/views/rich-content/rich-content.tsx+++ b/packages/views/rich-content/rich-content.tsx@@ -619,6 +619,7 @@ export const RichContent = memo(function RichContent({<divref={wrapperRef}data-rich-content=""+ data-mc="content"data-density={density}data-phase={phase}className={cn(diff --git a/packages/views/runtimes/components/connect-remote-dialog.tsx b/packages/views/runtimes/components/connect-remote-dialog.tsxindex 90948abd7f..9ad74e6fe3 100644--- a/packages/views/runtimes/components/connect-remote-dialog.tsx+++ b/packages/views/runtimes/components/connect-remote-dialog.tsx@@ -7,7 +7,8 @@ import {useState,type ReactNode,} from "react";-import { AnimatePresence, motion, useReducedMotion } from "motion/react";+import { AnimatePresence, motion } from "motion/react";+import { useReducedMotion } from "@multica/core/appearance";import { Check, ChevronRight, Copy, Terminal } from "@multica/ui/icons";import { useQuery, useQueryClient } from "@tanstack/react-query";import { useAuthStore } from "@multica/core/auth";@@ -62,7 +63,7 @@ function WorkspaceConnectDialog({ wsId, currentUserId, onClose }: {const slug = useWorkspaceSlug();const qc = useQueryClient();const navigation = useNavigation();- const shouldReduceMotion = useReducedMotion() ?? false;+ const shouldReduceMotion = useReducedMotion();const newRuntimeIdRef = useRef<string | null>(null);const initialDaemonIds = useRef<Set<string> | null>(null);const pendingInitialRefresh = useRef(false);diff --git a/packages/views/settings/components/appearance-tab.test.tsx b/packages/views/settings/components/appearance-tab.test.tsxnew file mode 100644index 0000000000..d4c955e254--- /dev/null+++ b/packages/views/settings/components/appearance-tab.test.tsx@@ -0,0 +1,215 @@+import type { ReactNode } from "react";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import { cleanup, render, screen, within } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { I18nProvider } from "@multica/core/i18n/react";+import { DEFAULT_APPEARANCE, useAppearanceStore, type Theme } from "@multica/core/appearance";+import enCommon from "../../locales/en/common.json";+import enSettings from "../../locales/en/settings.json";++const themeState = vi.hoisted(() => ({+ theme: "light",+ resolvedTheme: "light",+ setTheme: vi.fn(),+}));+vi.mock("@multica/ui/components/common/theme-provider", () => ({+ useTheme: () => themeState,+}));++/** A theme the next render treats as active, for option types no built-in theme uses. */+const testTheme = vi.hoisted(() => ({ current: null as Theme | null }));+vi.mock("@multica/core/appearance", async (importOriginal) => {+ const actual = await importOriginal<typeof import("@multica/core/appearance")>();+ return {+ ...actual,+ activeTheme: (prefs: { theme: string }) =>+ testTheme.current && prefs.theme === testTheme.current.id ? testTheme.current : actual.activeTheme(prefs),+ };+});++import { AppearanceTab } from "./appearance-tab";++const TEST_RESOURCES = { en: { common: enCommon, settings: enSettings } };++function Wrapper({ children }: { children: ReactNode }) {+ return (+ <I18nProvider locale="en" resources={TEST_RESOURCES}>+ {children}+ </I18nProvider>+ );+}++const group = (name: string) => screen.getByRole("group", { name });+const state = () => useAppearanceStore.getState();+const themeSelect = () => screen.getByRole("combobox", { name: "Theme" });++describe("AppearanceTab", () => {+ beforeEach(() => {+ themeState.theme = "light";+ themeState.resolvedTheme = "light";+ themeState.setTheme.mockClear();+ localStorage.clear();+ useAppearanceStore.setState(DEFAULT_APPEARANCE);+ testTheme.current = null;+ });+ afterEach(() => {+ cleanup();+ });++ it("switches the mode on this device", async () => {+ const user = userEvent.setup();+ render(<AppearanceTab />, { wrapper: Wrapper });++ expect(screen.getByText("This device only")).toBeInTheDocument();+ expect(within(group("Mode")).getByRole("button", { name: "Light" })).toHaveAttribute(+ "aria-pressed",+ "true",+ );+ await user.click(within(group("Mode")).getByRole("button", { name: "Dark" }));++ expect(themeState.setTheme).toHaveBeenCalledWith("dark");+ });++ it("lists every theme in a dropdown, drawn in the applied mode, and saves the pick", async () => {+ themeState.theme = "system";+ themeState.resolvedTheme = "dark";+ const user = userEvent.setup();+ render(<AppearanceTab />, { wrapper: Wrapper });++ await user.click(themeSelect());+ const options = await screen.findAllByRole("option");+ expect(options.map((o) => o.textContent)).toEqual(["Default", "Pop", "GitHub", "Blueprint", "Notion"]);+ expect(options[2]!.querySelector("[data-theme-swatch]")).toHaveAttribute("data-swatch-mode", "dark");+ await user.click(options[2]!);++ expect(state().theme).toBe("github");+ expect(themeSelect()).toHaveTextContent("GitHub");+ expect(screen.queryByRole("button", { name: /import/i })).not.toBeInTheDocument();+ });++ it("renders the options the active theme declares and saves them per theme", async () => {+ const user = userEvent.setup();+ render(<AppearanceTab />, { wrapper: Wrapper });+ expect(screen.queryByText("Theme options")).not.toBeInTheDocument();++ await user.click(themeSelect());+ await user.click(await screen.findByRole("option", { name: "Pop" }));+ expect(screen.getByText("Theme options")).toBeInTheDocument();+ expect(screen.getByRole("radio", { name: "Yellow" })).toHaveAttribute("aria-checked", "true");+ await user.click(screen.getByRole("radio", { name: "Mint" }));+ await user.click(screen.getByRole("switch", { name: "Status blocks" }));++ expect(state().themeOptions).toEqual({ pop: { signal: "mint", "status-blocks": false } });+ await user.click(screen.getByRole("button", { name: "Reset options" }));+ expect(state().themeOptions).toEqual({});+ });++ it("sets interface and content type separately", async () => {+ const user = userEvent.setup();+ render(<AppearanceTab />, { wrapper: Wrapper });++ const [uiLatin, contentLatin] = screen.getAllByRole("combobox", { name: "Latin font" });+ const [, contentCjk] = screen.getAllByRole("combobox", { name: "CJK font" });+ await user.click(uiLatin!);+ await user.click(await screen.findByRole("option", { name: /^Source Serif 4/ }));+ await user.click(contentLatin!);+ await user.click(await screen.findByRole("option", { name: /^Geist Mono/ }));+ await user.click(contentCjk!);+ await user.click(await screen.findByRole("option", { name: /^Kai/ }));+ await user.click(within(group("Line height")).getByRole("button", { name: "Relaxed" }));++ expect(state()).toMatchObject({+ uiFont: "serif",+ uiCjkFont: "sans",+ contentFont: "mono",+ contentCjkFont: "kai",+ contentLeading: "relaxed",+ });+ expect(contentLatin).toHaveTextContent("Geist Mono");+ });++ it("names the theme's fonts when the default choice keeps them", () => {+ useAppearanceStore.setState({ theme: "github" });+ const { unmount } = render(<AppearanceTab />, { wrapper: Wrapper });+ const [uiLatin] = screen.getAllByRole("combobox", { name: "Latin font" });+ expect(uiLatin).toHaveTextContent("Theme font");+ expect(screen.getByRole("combobox", { name: "Code font" })).toHaveTextContent("Theme font");+ unmount();++ useAppearanceStore.setState({ theme: "default" });+ render(<AppearanceTab />, { wrapper: Wrapper });+ expect(screen.getAllByRole("combobox", { name: "Latin font" })[0]).toHaveTextContent("Inter");+ expect(screen.getByRole("combobox", { name: "Code font" })).toHaveTextContent("Geist Mono");+ });++ it("picks the density and contrast, and has no accent colour of its own", async () => {+ const user = userEvent.setup();+ render(<AppearanceTab />, { wrapper: Wrapper });+ expect(screen.queryByRole("radiogroup", { name: "Accent color" })).not.toBeInTheDocument();++ await user.click(within(group("Density")).getByRole("button", { name: "Compact" }));+ await user.click(screen.getByRole("switch", { name: "Increase contrast" }));++ expect(state()).toMatchObject({ density: "compact", highContrast: true });+ });++ it("renders every option type a theme declares, grouped under its headings", async () => {+ const user = userEvent.setup();+ testTheme.current = {+ apiVersion: 1,+ id: "paper",+ name: "Paper",+ css: "",+ options: [+ { id: "page", type: "heading", label: "Page", description: "The paper itself." },+ { id: "paper-color", type: "color", label: "Paper", default: { light: "#f6efdf", dark: "#1d1b16" } },+ { id: "page-width", type: "slider", label: "Width", default: 46, min: 30, max: 60, unit: "rem" },+ { id: "type", type: "heading", label: "Type" },+ { id: "h1-font", type: "font", label: "Heading font", default: "Georgia, serif" },+ { id: "leading", type: "number", label: "Leading", default: 1.6, step: 0.1 },+ { id: "rule", type: "variable-select", label: "Rule", default: "1px", choices: [+ { value: "1px", label: "Thin" },+ { value: "2px", label: "Thick" },+ ] },+ ],+ };+ useAppearanceStore.setState({ theme: "paper" });+ render(<AppearanceTab />, { wrapper: Wrapper });++ expect(screen.getByRole("heading", { name: "Page" })).toBeInTheDocument();+ expect(screen.getByText("The paper itself.")).toBeInTheDocument();+ expect(screen.getByRole("heading", { name: "Type" })).toBeInTheDocument();+ expect(screen.getByLabelText("Paper (Dark)")).toHaveValue("#1d1b16");+ expect(screen.getByText("46rem")).toBeInTheDocument();++ const font = () => screen.getByRole("textbox", { name: "Heading font" });+ await user.clear(font());+ await user.type(font(), '"Paper Serif", serif{Enter}');+ expect(state().themeOptions.paper?.["h1-font"]).toBe('"Paper Serif", serif');++ await user.clear(font());+ await user.type(font(), "x; color: red{Enter}");+ expect(state().themeOptions.paper?.["h1-font"]).toBe('"Paper Serif", serif');+ expect(font()).toHaveValue('"Paper Serif", serif');++ const leading = screen.getByRole("spinbutton", { name: "Leading" });+ await user.clear(leading);+ await user.type(leading, "1.8");+ await user.tab();+ expect(state().themeOptions.paper?.leading).toBe(1.8);+ });++ it("resets to the defaults, and only once something changed", async () => {+ const user = userEvent.setup();+ render(<AppearanceTab />, { wrapper: Wrapper });+ const reset = screen.getByRole("button", { name: "Reset to defaults" });+ expect(reset).toBeDisabled();++ await user.click(within(group("Density")).getByRole("button", { name: "Comfortable" }));+ expect(reset).toBeEnabled();+ await user.click(reset);++ expect(state().density).toBe("default");+ expect(reset).toBeDisabled();+ });+});diff --git a/packages/views/settings/components/appearance-tab.tsx b/packages/views/settings/components/appearance-tab.tsxnew file mode 100644index 0000000000..aa0ae1e553--- /dev/null+++ b/packages/views/settings/components/appearance-tab.tsx@@ -0,0 +1,979 @@+"use client";++import { useMemo } from "react";+import { useShallow } from "zustand/react/shallow";+import {+ Monitor,+ Moon,+ RotateCcw,+ Sun,+} from "@multica/ui/icons";+import { cn } from "@multica/ui/lib/utils";+import { Button } from "@multica/ui/components/ui/button";+import {+ Select,+ SelectContent,+ SelectGroup,+ SelectItem,+ SelectLabel,+ SelectSeparator,+ SelectTrigger,+ SelectValue,+} from "@multica/ui/components/ui/select";+import { Input } from "@multica/ui/components/ui/input";+import { Slider } from "@multica/ui/components/ui/slider";+import { Switch } from "@multica/ui/components/ui/switch";+import { useTheme } from "@multica/ui/components/common/theme-provider";+import {+ BUILT_IN_THEMES,+ CJK_FONTS,+ CODE_FONTS,+ CONTENT_LEADINGS,+ CONTENT_SIZES,+ DEFAULT_APPEARANCE,+ DEFAULT_FONT_SIZE,+ DENSITIES,+ FOLLOW_UI,+ FONT_SIZES,+ UI_FONTS,+ activeTheme,+ cjkFontStack,+ isDefaultAppearance,+ isLocalFont,+ isSafeFontValue,+ isSafeThemeValue,+ localFontFamily,+ localizedText,+ selectAppearance,+ themeModeVariables,+ themeOptionValue,+ uiFontStack,+ useAppearanceStore,+ useLocalCjkFonts,+ type CjkFontChoice,+ type CodeFont,+ type ContentSize,+ type FontSize,+ type Theme,+ type ThemeOption,+ type ThemeOptionValue,+ type ThemedColor,+ type UiFont,+} from "@multica/core/appearance";+import { useLocale, useT } from "../../i18n";+import { SegmentedToggle } from "../../common/segmented-toggle";+import {+ SettingsCard,+ SettingsRow,+ SettingsSection,+ SettingsTab,+} from "./settings-layout";++type PreviewMode = "light" | "dark";+type ModeChoice = PreviewMode | "system";++const UI_FONT_NAME: Record<UiFont, string> = {+ inter: "Inter",+ system: "SF Pro / Segoe UI",+ serif: "Source Serif 4",+ mono: "Geist Mono",+};+const CODE_FONT_SAMPLE: Record<CodeFont, string> = {+ geist: "var(--font-ui-mono), monospace",+ jetbrains: "var(--font-code-jetbrains), monospace",+ system: 'ui-monospace, "SF Mono", Menlo, Consolas, monospace',+};+const CODE_FONT_NAME: Record<CodeFont, string> = {+ geist: "Geist Mono",+ jetbrains: "JetBrains Mono",+ system: "SF Mono / Consolas",+};+/**+ * Whether the active theme sets a font variable. The default font choice+ * writes nothing, so on such a theme it shows the theme's font, not its own.+ */+function useThemeSetsFont(variable: "font-ui" | "font-mono"): boolean {+ const appliedMode = useAppliedMode();+ const theme = useAppearanceStore((s) => s.theme);+ const css = activeTheme({ theme }).css;+ return useMemo(() => variable in themeModeVariables(css)[appliedMode], [css, appliedMode, variable]);+}++/** Select value that asks for the device's fonts instead of choosing one. */+const LOAD_LOCAL_FONTS = "__load_local_fonts";++/**+ * Appearance: colour (mode and theme), the active theme's options,+ * interface text, content text, and layout and accessibility. Every change+ * applies at once, so the page itself is the preview.+ */+export function AppearanceTab() {+ const { t } = useT("settings");+ const prefs = useAppearanceStore(useShallow(selectAppearance));+ const reset = useAppearanceStore((s) => s.reset);+ return (+ <SettingsTab+ title={t(($) => $.page.tabs.appearance)}+ scope="device"+ actions={+ <Button+ variant="ghost"+ size="sm"+ disabled={isDefaultAppearance(prefs)}+ onClick={reset}+ >+ <RotateCcw />+ {t(($) => $.appearance.reset)}+ </Button>+ }+ >+ <div className="space-y-8">+ <ColorSection />+ <ThemeOptionsSection />+ <InterfaceTextSection />+ <ContentTextSection />+ <LayoutSection />+ </div>+ </SettingsTab>+ );+}++function useAppliedMode(): PreviewMode {+ const { resolvedTheme } = useTheme();+ return resolvedTheme === "dark" ? "dark" : "light";+}++function useThemeLabel() {+ const { t } = useT("settings");+ return (theme: Theme) =>+ theme.id === "default"+ ? t(($) => $.appearance.theme.default)+ : theme.id === "pop"+ ? t(($) => $.appearance.theme.pop)+ : theme.name;+}++function ColorSection() {+ const { t } = useT("settings");+ const { theme: mode, setTheme: setMode } = useTheme();+ const appliedMode = useAppliedMode();+ const theme = useAppearanceStore((s) => s.theme);+ const set = useAppearanceStore((s) => s.set);+ const themeLabelFor = useThemeLabel();+ const modeValue: ModeChoice = mode === "light" || mode === "dark" ? mode : "system";+ const modeLabel = t(($) => $.appearance.mode.title);+ const themeLabel = t(($) => $.appearance.theme.title);+ const selected = BUILT_IN_THEMES.find((manifest) => manifest.id === theme);+ const items = BUILT_IN_THEMES.map((manifest) => ({+ value: manifest.id,+ label: themeLabelFor(manifest),+ }));++ return (+ <SettingsSection title={t(($) => $.appearance.color.title)} anchor="color">+ <SettingsCard>+ <SettingsRow label={modeLabel} anchor="mode">+ <div role="group" aria-label={modeLabel}>+ <SegmentedToggle<ModeChoice>+ value={modeValue}+ onChange={setMode}+ buttonClassName="flex items-center gap-1.5 px-2.5 py-1 text-label"+ options={[+ ["light", <><Sun aria-hidden="true" className="size-3.5" />{t(($) => $.appearance.mode.light)}</>],+ ["dark", <><Moon aria-hidden="true" className="size-3.5" />{t(($) => $.appearance.mode.dark)}</>],+ ["system", <><Monitor aria-hidden="true" className="size-3.5" />{t(($) => $.appearance.mode.system)}</>],+ ]}+ />+ </div>+ </SettingsRow>+ <SettingsRow label={themeLabel} description={t(($) => $.appearance.theme.description)} anchor="theme">+ <Select+ items={items}+ value={selected ? theme : "default"}+ onValueChange={(next) => {+ if (next) set({ theme: next });+ }}+ >+ <SelectTrigger size="sm" className="w-48" aria-label={themeLabel}>+ <SelectValue>+ {selected ? (+ <span className="flex min-w-0 items-center gap-2">+ <ThemeSwatch theme={selected} mode={appliedMode} />+ <span className="truncate">{themeLabelFor(selected)}</span>+ </span>+ ) : null}+ </SelectValue>+ </SelectTrigger>+ <SelectContent align="end" className="min-w-48">+ {BUILT_IN_THEMES.map((manifest) => (+ <SelectItem key={manifest.id} value={manifest.id}>+ <span className="flex min-w-0 flex-1 items-center gap-2.5">+ <ThemeSwatch theme={manifest} mode={appliedMode} />+ <span className="truncate">{themeLabelFor(manifest)}</span>+ </span>+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ </SettingsRow>+ </SettingsCard>+ </SettingsSection>+ );+}++/** The options the active theme declares, rendered from its manifest. */+function ThemeOptionsSection() {+ const { t } = useT("settings");+ const locale = useLocale();+ const prefs = useAppearanceStore(useShallow(selectAppearance));+ const setThemeOption = useAppearanceStore((s) => s.setThemeOption);+ const set = useAppearanceStore((s) => s.set);+ const themeLabelFor = useThemeLabel();+ const theme = activeTheme(prefs);+ const options = theme.options ?? [];+ if (options.length === 0) return null;+ const chosen = prefs.themeOptions[theme.id];++ return (+ <SettingsSection+ title={t(($) => $.appearance.theme_options.title)}+ description={t(($) => $.appearance.theme_options.description, { name: themeLabelFor(theme) })}+ anchor="theme-options"+ action={+ <Button+ variant="ghost"+ size="xs"+ disabled={!chosen}+ onClick={() => {+ const { [theme.id]: _removed, ...rest } = prefs.themeOptions;+ set({ themeOptions: rest });+ }}+ >+ {t(($) => $.appearance.theme_options.reset)}+ </Button>+ }+ >+ <div className="space-y-5">+ {optionGroups(options).map((group, index) => (+ <div key={group.heading?.id ?? index} className="space-y-2">+ {group.heading ? (+ <div className="px-1">+ <h3 className="text-label font-medium">{localizedText(group.heading.label, locale)}</h3>+ {group.heading.description ? (+ <p className="text-caption text-muted-foreground">+ {localizedText(group.heading.description, locale)}+ </p>+ ) : null}+ </div>+ ) : null}+ {group.options.length > 0 ? (+ <SettingsCard>+ {group.options.map((option) => (+ <ThemeOptionRow+ key={option.id}+ option={option}+ locale={locale}+ value={themeOptionValue(option, chosen?.[option.id])}+ onChange={(value) => setThemeOption(theme.id, option.id, value)}+ />+ ))}+ </SettingsCard>+ ) : null}+ </div>+ ))}+ </div>+ </SettingsSection>+ );+}++type HeadingOption = Extract<ThemeOption, { type: "heading" }>;++/** Splits options at each heading. */+function optionGroups(options: readonly ThemeOption[]) {+ const groups: { heading?: HeadingOption; options: Exclude<ThemeOption, HeadingOption>[] }[] = [];+ for (const option of options) {+ if (option.type === "heading") groups.push({ heading: option, options: [] });+ else if (groups.length === 0) groups.push({ options: [option] });+ else groups[groups.length - 1]!.options.push(option);+ }+ return groups;+}++function ThemeOptionRow({+ option,+ locale,+ value,+ onChange,+}: {+ option: Exclude<ThemeOption, HeadingOption>;+ locale: string;+ value: ThemeOptionValue;+ onChange: (value: ThemeOptionValue) => void;+}) {+ const { t } = useT("settings");+ const label = localizedText(option.label, locale);+ const description = localizedText(option.description, locale) || undefined;+ switch (option.type) {+ case "toggle":+ return (+ <SettingsRow label={label} description={description}>+ <Switch checked={value === true} onCheckedChange={onChange} aria-label={label} />+ </SettingsRow>+ );+ case "select": {+ const swatches = option.choices.every((choice) => choice.swatch);+ return (+ <SettingsRow label={label} description={description}>+ {swatches ? (+ <div role="radiogroup" aria-label={label} className="flex items-center gap-2.5">+ {option.choices.map((choice) => (+ <ColorSwatch+ key={choice.value}+ label={localizedText(choice.label, locale)}+ color={choice.swatch!}+ selected={value === choice.value}+ onSelect={() => onChange(choice.value)}+ />+ ))}+ </div>+ ) : (+ <div role="group" aria-label={label}>+ <SegmentedToggle+ value={String(value)}+ onChange={onChange}+ buttonClassName="px-3 py-1 text-label"+ options={option.choices.map((choice) => [choice.value, localizedText(choice.label, locale)] as const)}+ />+ </div>+ )}+ </SettingsRow>+ );+ }+ case "variable-select": {+ const items = option.choices.map((choice) => ({ value: choice.value, label: localizedText(choice.label, locale) }));+ return (+ <SettingsRow label={label} description={description}>+ <Select items={items} value={String(value)} onValueChange={(next) => next && onChange(next)}>+ <SelectTrigger size="sm" className="w-40" aria-label={label}>+ <SelectValue />+ </SelectTrigger>+ <SelectContent align="end">+ {items.map((item) => (+ <SelectItem key={item.value} value={item.value}>+ {item.label}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ </SettingsRow>+ );+ }+ case "color": {+ const color = value as ThemedColor;+ return (+ <SettingsRow label={label} description={description}>+ <div role="group" aria-label={label} className="flex items-center gap-3">+ {(["light", "dark"] as const).map((mode) => {+ const modeLabel = t(($) => $.appearance.mode[mode]);+ return (+ <label key={mode} className="flex items-center gap-1.5 text-caption text-muted-foreground">+ <input+ type="color"+ aria-label={`${label} (${modeLabel})`}+ value={color[mode].length === 4 ? expandHex(color[mode]) : color[mode].slice(0, 7)}+ onChange={(event) => onChange({ ...color, [mode]: event.target.value })}+ className="size-6 cursor-pointer rounded-md border border-input bg-transparent p-0.5 [&::-webkit-color-swatch]:rounded-xs [&::-webkit-color-swatch]:border-0 [&::-webkit-color-swatch-wrapper]:p-0"+ />+ {modeLabel}+ </label>+ );+ })}+ </div>+ </SettingsRow>+ );+ }+ case "slider":+ return (+ <SettingsRow label={label} description={description} size="text">+ <div className="flex w-full items-center gap-3">+ <Slider+ aria-label={label}+ min={option.min}+ max={option.max}+ step={option.step ?? 1}+ value={value as number}+ onValueChange={(next) => {+ const n = Array.isArray(next) ? next[0] : next;+ if (typeof n === "number") onChange(n);+ }}+ className="flex-1"+ />+ <span className="w-14 shrink-0 text-right text-label tabular-nums text-muted-foreground">+ {String(value)}+ {option.unit}+ </span>+ </div>+ </SettingsRow>+ );+ case "number":+ return (+ <SettingsRow label={label} description={description}>+ <div className="flex items-center gap-1.5">+ <Input+ type="number"+ aria-label={label}+ className="h-8 w-24 text-right tabular-nums"+ min={option.min}+ max={option.max}+ step={option.step ?? "any"}+ defaultValue={String(value)}+ key={String(value)}+ onBlur={(event) => {+ const n = event.target.valueAsNumber;+ if (Number.isFinite(n)) onChange(n);+ else event.target.value = String(value);+ }}+ />+ {option.unit ? <span className="text-label text-muted-foreground">{option.unit}</span> : null}+ </div>+ </SettingsRow>+ );+ case "text":+ case "font": {+ const valid = option.type === "font" ? isSafeFontValue : isSafeThemeValue;+ return (+ <SettingsRow label={label} description={description} size="text">+ <Input+ aria-label={label}+ className="h-8"+ defaultValue={String(value)}+ key={String(value)}+ spellCheck={false}+ onKeyDown={(event) => {+ if (event.key === "Enter") event.currentTarget.blur();+ }}+ onBlur={(event) => {+ const next = event.target.value.trim();+ if (next !== value && valid(next)) onChange(next);+ else event.target.value = String(value);+ }}+ />+ </SettingsRow>+ );+ }+ }+}++/** `#abc` to `#aabbcc`, which is all a colour input accepts. */+function expandHex(hex: string): string {+ return `#${[...hex.slice(1)].map((c) => c + c).join("")}`;+}++function ColorSwatch({+ label,+ color,+ selected,+ onSelect,+}: {+ label: string;+ color: string;+ selected: boolean;+ onSelect: () => void;+}) {+ return (+ <button+ type="button"+ role="radio"+ aria-checked={selected}+ aria-label={label}+ title={label}+ onClick={onSelect}+ style={{ backgroundColor: color }}+ className={cn(+ // eslint-disable-next-line no-restricted-syntax -- color swatch+ "flex size-5 items-center justify-center rounded-full text-white outline-none ring-offset-2 ring-offset-surface transition-shadow focus-visible:ring-2 focus-visible:ring-ring",+ selected && "ring-2 ring-foreground",+ )}+ >+ <span className="sr-only">{label}</span>+ </button>+ );+}++function InterfaceTextSection() {+ const { t } = useT("settings");+ const { uiFont, uiCjkFont, fontSize, set } = useAppearanceStore(+ useShallow((s) => ({ uiFont: s.uiFont, uiCjkFont: s.uiCjkFont, fontSize: s.fontSize, set: s.set })),+ );+ const themeUiFont = useThemeSetsFont("font-ui");+ const sizeLabel = t(($) => $.appearance.font_size.title);++ return (+ <SettingsSection+ title={t(($) => $.appearance.ui_text.title)}+ description={t(($) => $.appearance.ui_text.description)}+ anchor="ui-text"+ >+ <SettingsCard>+ <SettingsRow label={t(($) => $.appearance.latin_font.title)} anchor="ui-latin-font" size="select">+ <LatinFontSelect value={uiFont} themeFont={themeUiFont} onChange={(next) => set({ uiFont: next as UiFont })} />+ </SettingsRow>+ <SettingsRow+ label={t(($) => $.appearance.cjk_font.title)}+ description={t(($) => $.appearance.cjk_font.description)}+ anchor="ui-cjk-font"+ size="select"+ >+ <CjkFontSelect value={uiCjkFont} onChange={(next) => set({ uiCjkFont: next as CjkFontChoice })} />+ </SettingsRow>+ <SettingsRow+ label={sizeLabel}+ description={t(($) => $.appearance.font_size.description)}+ anchor="font-size"+ >+ <div className="flex w-56 items-center gap-3">+ <span aria-hidden="true" className="text-caption text-muted-foreground">+ A+ </span>+ <Slider+ aria-label={sizeLabel}+ min={FONT_SIZES[0]}+ max={FONT_SIZES[FONT_SIZES.length - 1]}+ step={1}+ value={fontSize}+ onValueChange={(next) => {+ const size = Array.isArray(next) ? next[0] : next;+ if ((FONT_SIZES as readonly number[]).includes(size as number)) {+ set({ fontSize: size as FontSize });+ }+ }}+ className="flex-1"+ />+ <span aria-hidden="true" className="text-title-sm text-muted-foreground">+ A+ </span>+ <span className="w-24 shrink-0 text-right text-caption tabular-nums text-muted-foreground">+ {fontSize === DEFAULT_FONT_SIZE+ ? t(($) => $.appearance.font_size.default, { size: fontSize })+ : t(($) => $.appearance.font_size.value, { size: fontSize })}+ </span>+ </div>+ </SettingsRow>+ </SettingsCard>+ </SettingsSection>+ );+}++function ContentTextSection() {+ const { t } = useT("settings");+ const { contentFont, contentCjkFont, contentSize, contentLeading, codeFont, fontSize, set } =+ useAppearanceStore(+ useShallow((s) => ({+ contentFont: s.contentFont,+ contentCjkFont: s.contentCjkFont,+ contentSize: s.contentSize,+ contentLeading: s.contentLeading,+ codeFont: s.codeFont,+ fontSize: s.fontSize,+ set: s.set,+ })),+ );+ const codeLabel = t(($) => $.appearance.code_font.title);+ const sizeLabel = t(($) => $.appearance.content_size.title);+ const leadingLabel = t(($) => $.appearance.content_leading.title);+ const themeCodeFont = useThemeSetsFont("font-mono");+ const themeFontLabel = t(($) => $.appearance.theme_font);+ const fromTheme = (id: CodeFont) => themeCodeFont && id === DEFAULT_APPEARANCE.codeFont;+ const codeName = (id: CodeFont) => (fromTheme(id) ? themeFontLabel : CODE_FONT_NAME[id]);+ const codeSample = (id: CodeFont) => (fromTheme(id) ? "var(--font-mono)" : CODE_FONT_SAMPLE[id]);+ const codeOptions = CODE_FONTS.map((id) => ({ value: id, label: codeName(id) }));+ const sizeName = (size: ContentSize) =>+ size === FOLLOW_UI+ ? t(($) => $.appearance.content_size.follow, { size: fontSize })+ : t(($) => $.appearance.font_size.value, { size });+ const sizeOptions = ([FOLLOW_UI, ...CONTENT_SIZES] as ContentSize[]).map((size) => ({+ value: String(size),+ label: sizeName(size),+ }));++ return (+ <SettingsSection+ title={t(($) => $.appearance.content_text.title)}+ description={t(($) => $.appearance.content_text.description)}+ anchor="content-text"+ >+ <SettingsCard>+ <div className="rich-text-editor bg-page-canvas px-4 py-3.5 text-body" data-appearance-content-sample="">+ <p>{t(($) => $.appearance.content_text.sample)}</p>+ </div>+ <SettingsRow label={t(($) => $.appearance.latin_font.title)} anchor="content-latin-font" size="select">+ <LatinFontSelect value={contentFont} follow onChange={(next) => set({ contentFont: next as UiFont })} />+ </SettingsRow>+ <SettingsRow+ label={t(($) => $.appearance.cjk_font.title)}+ description={t(($) => $.appearance.cjk_font.description)}+ anchor="content-cjk-font"+ size="select"+ >+ <CjkFontSelect+ value={contentCjkFont}+ follow+ onChange={(next) => set({ contentCjkFont: next as CjkFontChoice })}+ />+ </SettingsRow>+ <SettingsRow+ label={codeLabel}+ description={t(($) => $.appearance.code_font.description)}+ anchor="code-font"+ size="select"+ >+ <Select+ items={codeOptions}+ value={codeFont}+ onValueChange={(next) => {+ if (next) set({ codeFont: next as CodeFont });+ }}+ >+ <SelectTrigger size="sm" className="w-full" aria-label={codeLabel}>+ <SelectValue>+ <span style={{ fontFamily: codeSample(codeFont) }}>{codeName(codeFont)}</span>+ </SelectValue>+ </SelectTrigger>+ <SelectContent align="end">+ {CODE_FONTS.map((id) => (+ <SelectItem key={id} value={id}>+ <span className="flex min-w-0 flex-1 items-baseline justify-between gap-3">+ <span style={{ fontFamily: codeSample(id) }}>{codeName(id)}</span>+ <span className="text-caption text-muted-foreground">+ {t(($) => $.appearance.code_font[id])}+ </span>+ </span>+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ </SettingsRow>+ <SettingsRow+ label={sizeLabel}+ description={t(($) => $.appearance.content_size.description)}+ anchor="content-size"+ size="select"+ >+ <Select+ items={sizeOptions}+ value={String(contentSize)}+ onValueChange={(next) => {+ if (!next) return;+ const size = next === FOLLOW_UI ? FOLLOW_UI : Number(next);+ if (size === FOLLOW_UI || (CONTENT_SIZES as readonly number[]).includes(size)) {+ set({ contentSize: size as ContentSize });+ }+ }}+ >+ <SelectTrigger size="sm" className="w-full" aria-label={sizeLabel}>+ <SelectValue>{sizeName(contentSize)}</SelectValue>+ </SelectTrigger>+ <SelectContent align="end">+ {sizeOptions.map((option) => (+ <SelectItem key={option.value} value={option.value}>+ {option.label}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ </SettingsRow>+ <SettingsRow label={leadingLabel} anchor="content-leading">+ <div role="group" aria-label={leadingLabel}>+ <SegmentedToggle+ value={contentLeading}+ onChange={(next) => set({ contentLeading: next })}+ buttonClassName="px-3 py-1 text-label"+ options={CONTENT_LEADINGS.map((id) => [id, t(($) => $.appearance.content_leading[id])] as const)}+ />+ </div>+ </SettingsRow>+ </SettingsCard>+ </SettingsSection>+ );+}++/** Latin faces, each drawn in itself; `follow` adds "same as interface" for content. */+function LatinFontSelect({+ value,+ follow = false,+ themeFont = false,+ onChange,+}: {+ value: string;+ follow?: boolean;+ /** The active theme sets the interface font, which the default choice keeps. */+ themeFont?: boolean;+ onChange: (value: string) => void;+}) {+ const { t } = useT("settings");+ const label = t(($) => $.appearance.latin_font.title);+ const followLabel = t(($) => $.appearance.follow_ui);+ const themeFontLabel = t(($) => $.appearance.theme_font);+ const fromTheme = (id: string) => themeFont && id === DEFAULT_APPEARANCE.uiFont;+ const name = (id: string) =>+ id === FOLLOW_UI ? followLabel : fromTheme(id) ? themeFontLabel : UI_FONT_NAME[id as UiFont];+ const family = (id: string) =>+ id === FOLLOW_UI ? undefined : fromTheme(id) ? "var(--font-ui)" : uiFontStack(id as UiFont);+ const ids: string[] = [...(follow ? [FOLLOW_UI] : []), ...UI_FONTS];+ return (+ <Select+ items={ids.map((id) => ({ value: id, label: name(id) }))}+ value={value}+ onValueChange={(next) => {+ if (next) onChange(next);+ }}+ >+ <SelectTrigger size="sm" className="w-full" aria-label={label}>+ <SelectValue>+ <span style={{ fontFamily: family(value) }}>{name(value)}</span>+ </SelectValue>+ </SelectTrigger>+ <SelectContent align="end">+ {ids.map((id) => (+ <SelectItem key={id} value={id}>+ <span className="flex min-w-0 flex-1 items-baseline justify-between gap-3">+ <span style={{ fontFamily: family(id) }}>{name(id)}</span>+ {id === FOLLOW_UI ? null : (+ <span className="text-caption text-muted-foreground">+ {t(($) => $.appearance.ui_font[id as UiFont])}+ </span>+ )}+ </span>+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ );+}++/**+ * Built-in CJK faces, then families installed on this device (listed on+ * request, since reading them can ask for permission). Every option shows a+ * sample in its own face.+ */+function CjkFontSelect({+ value,+ follow = false,+ onChange,+}: {+ value: string;+ follow?: boolean;+ onChange: (value: string) => void;+}) {+ const { t } = useT("settings");+ const local = useLocalCjkFonts();+ const label = t(($) => $.appearance.cjk_font.title);+ const sample = t(($) => $.appearance.cjk_font.sample);+ const followLabel = t(($) => $.appearance.follow_ui);+ const localValues = local.families.map((family) => `local:${family}`);+ if (isLocalFont(value) && !localValues.includes(value)) localValues.unshift(value);++ const name = (id: string) =>+ id === FOLLOW_UI+ ? followLabel+ : isLocalFont(id)+ ? localFontFamily(id)+ : t(($) => $.appearance.cjk_font[id as (typeof CJK_FONTS)[number]]);+ const family = (id: string) => (id === FOLLOW_UI ? undefined : cjkFontStack(id as CjkFontChoice));+ const builtIn: string[] = [...(follow ? [FOLLOW_UI] : []), ...CJK_FONTS];+ const items = [...builtIn, ...localValues].map((id) => ({ value: id, label: name(id) }));++ const row = (id: string) => (+ <SelectItem key={id} value={id}>+ <span className="flex min-w-0 flex-1 items-baseline justify-between gap-4">+ <span className="truncate" style={{ fontFamily: family(id) }}>+ {name(id)}+ </span>+ {id === FOLLOW_UI ? null : (+ <span className="shrink-0 text-caption text-muted-foreground" style={{ fontFamily: family(id) }}>+ {sample}+ </span>+ )}+ </span>+ </SelectItem>+ );++ const localStatus =+ local.status === "loading"+ ? t(($) => $.appearance.cjk_font.loading)+ : local.status === "ready" && local.families.length === 0+ ? t(($) => $.appearance.cjk_font.none)+ : local.status === "error"+ ? t(($) => $.appearance.cjk_font.load_failed)+ : null;++ return (+ <Select+ items={items}+ value={value}+ onValueChange={(next) => {+ if (!next) return;+ if (next === LOAD_LOCAL_FONTS) void local.load();+ else onChange(next);+ }}+ >+ <SelectTrigger size="sm" className="w-full" aria-label={label}>+ <SelectValue>+ <span style={{ fontFamily: family(value) }}>{name(value)}</span>+ </SelectValue>+ </SelectTrigger>+ <SelectContent align="end" className="min-w-80">+ <SelectGroup>+ <SelectLabel>{t(($) => $.appearance.cjk_font.built_in)}</SelectLabel>+ {builtIn.map(row)}+ </SelectGroup>+ {local.status !== "unavailable" || localValues.length > 0 ? (+ <>+ <SelectSeparator />+ <SelectGroup>+ <SelectLabel>{t(($) => $.appearance.cjk_font.local)}</SelectLabel>+ {localValues.map(row)}+ {local.status === "idle" || local.status === "error" ? (+ <SelectItem value={LOAD_LOCAL_FONTS}>+ <span className="text-muted-foreground">{t(($) => $.appearance.cjk_font.load_local)}</span>+ </SelectItem>+ ) : null}+ {localStatus ? (+ <div className="px-2 py-1.5 text-caption text-muted-foreground">{localStatus}</div>+ ) : null}+ </SelectGroup>+ </>+ ) : null}+ </SelectContent>+ </Select>+ );+}++function LayoutSection() {+ const { t } = useT("settings");+ const { density, reduceMotion, highContrast, set } = useAppearanceStore(+ useShallow((s) => ({+ density: s.density,+ reduceMotion: s.reduceMotion,+ highContrast: s.highContrast,+ set: s.set,+ })),+ );+ const densityLabel = t(($) => $.appearance.density.title);+ return (+ <SettingsSection title={t(($) => $.appearance.layout.title)} anchor="layout">+ <SettingsCard>+ <SettingsRow+ label={densityLabel}+ description={t(($) => $.appearance.density.description)}+ anchor="density"+ >+ <div role="group" aria-label={densityLabel}>+ <SegmentedToggle+ value={density}+ onChange={(next) => set({ density: next })}+ buttonClassName="px-3 py-1 text-label"+ options={DENSITIES.map((id) => [id, t(($) => $.appearance.density[id])] as const)}+ />+ </div>+ </SettingsRow>+ <SettingsRow+ label={t(($) => $.appearance.reduce_motion.title)}+ description={t(($) => $.appearance.reduce_motion.description)}+ anchor="reduce-motion"+ >+ <Switch+ checked={reduceMotion}+ onCheckedChange={(checked) => set({ reduceMotion: checked })}+ aria-label={t(($) => $.appearance.reduce_motion.title)}+ />+ </SettingsRow>+ <SettingsRow+ label={t(($) => $.appearance.high_contrast.title)}+ description={t(($) => $.appearance.high_contrast.description)}+ anchor="high-contrast"+ >+ <Switch+ checked={highContrast}+ onCheckedChange={(checked) => set({ highContrast: checked })}+ aria-label={t(($) => $.appearance.high_contrast.title)}+ />+ </SettingsRow>+ </SettingsCard>+ </SettingsSection>+ );+}++type SwatchTokens = Record<"app-shell" | "page-canvas" | "surface-border" | "foreground" | "brand", string>;++/**+ * The tokens a theme swatch needs, as tokens.css sets them for the default+ * theme. A theme only overrides some of them, so swatches start from these.+ */+const THEME_SWATCH_BASE: Record<PreviewMode, SwatchTokens> = {+ light: {+ "app-shell": "oklch(0.964 0.001 286)",+ "page-canvas": "oklch(0.988 0 0)",+ "surface-border": "oklch(0.92 0.004 286)",+ foreground: "oklch(0.141 0.005 286)",+ brand: "oklch(0.561 0.194 256.4)",+ },+ dark: {+ "app-shell": "oklch(0.155 0.005 286)",+ "page-canvas": "oklch(0.18 0.005 286)",+ "surface-border": "oklch(0.3 0.006 286)",+ foreground: "oklch(0.985 0 0)",+ brand: "oklch(0.65 0.16 255)",+ },+};++const swatchCache = new WeakMap<Theme, ReturnType<typeof themeModeVariables>>();++/**+ * Resolves `var()` references a swatch can know without the theme applied:+ * the theme's own variables for the mode and its colour options' defaults.+ */+function resolveSwatchValue(value: string, theme: Theme, variables: Record<string, string>, mode: PreviewMode, depth = 0): string {+ return value.replace(/var\(--([a-z0-9-]+)\)/g, (reference, name: string) => {+ const option = theme.options?.find((o) => o.id === name);+ if (option?.type === "color") return option.default[mode];+ const own = variables[name];+ return own && depth < 4 ? resolveSwatchValue(own, theme, variables, mode, depth + 1) : reference;+ });+}++function swatchTokens(theme: Theme, mode: PreviewMode): SwatchTokens {+ let variables = swatchCache.get(theme);+ if (!variables) {+ variables = themeModeVariables(theme.css);+ swatchCache.set(theme, variables);+ }+ const tokens = { ...THEME_SWATCH_BASE[mode] };+ for (const name of Object.keys(tokens) as (keyof SwatchTokens)[]) {+ const own = variables[mode][name];+ if (own) tokens[name] = resolveSwatchValue(own, theme, variables[mode], mode);+ }+ return tokens;+}++/** A theme in miniature: its frame, page, ink and brand colour. */+function ThemeSwatch({ theme, mode }: { theme: Theme; mode: PreviewMode }) {+ const tokens = swatchTokens(theme, mode);+ return (+ <span+ aria-hidden="true"+ data-theme-swatch={theme.id}+ data-swatch-mode={mode}+ className="flex h-4 w-6 shrink-0 items-end overflow-hidden rounded-xs p-[2px] ring-1 ring-foreground/10"+ style={{ background: tokens["app-shell"] }}+ >+ <span+ className="flex size-full flex-col justify-center gap-[2px] rounded-[calc(var(--radius-xs)/2)] px-[2px]"+ style={{ background: tokens["page-canvas"], boxShadow: `inset 0 0 0 0.5px ${tokens["surface-border"]}` }}+ >+ <span className="h-[2px] w-3/5 rounded-full" style={{ background: tokens.foreground }} />+ <span className="h-[2px] w-2/5 rounded-full" style={{ background: tokens.brand }} />+ </span>+ </span>+ );+}diff --git a/packages/views/settings/components/preferences-tab.test.tsx b/packages/views/settings/components/preferences-tab.test.tsxindex 0ae9b407ad..1215575493 100644--- a/packages/views/settings/components/preferences-tab.test.tsx+++ b/packages/views/settings/components/preferences-tab.test.tsx@@ -30,16 +30,11 @@ const mockReload = vi.hoisted(() => vi.fn());const mockToastWarning = vi.hoisted(() => vi.fn());const mockToastError = vi.hoisted(() => vi.fn());const mockToastSuccess = vi.hoisted(() => vi.fn());-const mockSetTheme = vi.hoisted(() => vi.fn());const mockSetUser = vi.hoisted(() => vi.fn());const userRef = vi.hoisted(() => ({current: null as { id: string; timezone?: string | null } | null,}));-vi.mock("@multica/ui/components/common/theme-provider", () => ({- useTheme: () => ({ theme: "light", setTheme: mockSetTheme }),-}));-vi.mock("@multica/core/i18n/react", async () => {const actual = await vi.importActual<typeof import("@multica/core/i18n/react")@@ -160,21 +155,6 @@ describe("PreferencesTab — Language switcher", () => {expect(mockReload).not.toHaveBeenCalled();});- it("applies the theme on this device without announcing success", async () => {- const user = userEvent.setup({ advanceTimers: vi.advanceTimersByTime });- render(<PreferencesTab />, { wrapper: I18nWrapper });-- const group = screen.getByRole("group", { name: "Theme" });- expect(within(group).getByRole("button", { name: "Light" })).toHaveAttribute(- "aria-pressed",- "true",- );- await user.click(within(group).getByRole("button", { name: "Dark" }));-- expect(mockSetTheme).toHaveBeenCalledWith("dark");- expect(mockToastSuccess).not.toHaveBeenCalled();- });-it.each([{ name: "한국어", locale: "ko" },{ name: "日本語", locale: "ja" },@@ -432,8 +412,8 @@ describe("PreferencesTab — Scope", () => {it("labels where each group of settings is stored", () => {render(<PreferencesTab />, { wrapper: I18nWrapper });expect(screen.getByText("Account · synced")).toBeInTheDocument();- // Appearance, opening issues, comments & chat.- expect(screen.getAllByText("This device only")).toHaveLength(3);+ // Opening issues, comments & chat.+ expect(screen.getAllByText("This device only")).toHaveLength(2);});it("switches what clicking a card or row opens, and says what Shift does", async () => {diff --git a/packages/views/settings/components/preferences-tab.tsx b/packages/views/settings/components/preferences-tab.tsxindex d40b0705de..281e3546bb 100644--- a/packages/views/settings/components/preferences-tab.tsx+++ b/packages/views/settings/components/preferences-tab.tsx@@ -24,7 +24,6 @@ import {CommandItem,CommandList,} from "@multica/ui/components/ui/command";-import { useTheme } from "@multica/ui/components/common/theme-provider";import type { SupportedLocale } from "@multica/core/i18n";import { useAuthStore } from "@multica/core/auth";import { useChatStore } from "@multica/core/chat";@@ -57,9 +56,10 @@ import {/*** Preferences on one page. The settings here are stored in three different- * places — the account (language, timezone), this device (theme, composer,- * chat) and this device for the current workspace (create-dialog fields) —- * so each section carries a scope badge instead of splitting them into tabs.+ * places — the account (language, timezone), this device (composer, chat,+ * opening issues) and this device for the current workspace (create-dialog+ * fields) — so each section carries a scope badge instead of splitting them+ * into tabs. Theme, style and frame colour live on the Appearance page.* Changes apply immediately; only failures are announced.*/export function PreferencesTab() {@@ -77,16 +77,6 @@ export function PreferencesTab() {</SettingsCard></SettingsSection>- <SettingsSection- title={t(($) => $.preferences.appearance_title)}- scope="device"- anchor="appearance"- >- <SettingsCard>- <ThemeRow />- </SettingsCard>- </SettingsSection>-<SettingsSectiontitle={t(($) => $.preferences.comments_title)}scope="device"@@ -121,28 +111,6 @@ export function PreferencesTab() {);}-function ThemeRow() {- const { t } = useT("settings");- const { theme, setTheme } = useTheme();- const value = theme === "light" || theme === "dark" ? theme : "system";- return (- <SettingsRow anchor="theme" label={t(($) => $.preferences.theme.title)}>- <div role="group" aria-label={t(($) => $.preferences.theme.title)}>- <SegmentedToggle- value={value}- onChange={setTheme}- buttonClassName="px-3 py-1 text-label"- options={[- ["light", t(($) => $.preferences.theme.light)],- ["dark", t(($) => $.preferences.theme.dark)],- ["system", t(($) => $.preferences.theme.system)],- ]}- />- </div>- </SettingsRow>- );-}-function LanguageRow() {const { t } = useT("settings");const {diff --git a/packages/views/settings/components/settings-navigation.test.ts b/packages/views/settings/components/settings-navigation.test.tsindex d9d0e96825..f3d96d020b 100644--- a/packages/views/settings/components/settings-navigation.test.ts+++ b/packages/views/settings/components/settings-navigation.test.ts@@ -11,6 +11,18 @@ describe("settings location", () => {["tab=issue", { tab: "preferences", section: "issue", integration: null }],["tab=chat", { tab: "preferences", section: "chat", integration: null }],["tab=labs", { tab: "workspace", section: null, integration: null }],+ [+ "tab=preferences§ion=appearance",+ { tab: "appearance", section: null, integration: null },+ ],+ [+ "tab=preferences§ion=theme",+ { tab: "appearance", section: "mode", integration: null },+ ],+ [+ "tab=preferences§ion=style",+ { tab: "appearance", section: "theme", integration: null },+ ],["tab=lark", { tab: "channels", section: null, integration: "lark" }],["tab=integrations&integration=slack",diff --git a/packages/views/settings/components/settings-navigation.ts b/packages/views/settings/components/settings-navigation.tsindex 3eb15b4062..a6a007ab8e 100644--- a/packages/views/settings/components/settings-navigation.ts+++ b/packages/views/settings/components/settings-navigation.ts@@ -15,6 +15,17 @@ export function isChannelIntegration(return (CHANNEL_INTEGRATIONS as readonly string[]).includes(value ?? "");}+/**+ * Preferences anchors that moved to the Appearance page, and where they land+ * there. The light/dark picker was `theme` under Preferences; on the+ * Appearance page that row is `mode` and `theme` is the theme gallery.+ */+const APPEARANCE_SECTIONS: Record<string, string | null> = {+ appearance: null,+ theme: "mode",+ style: "theme",+};+export interface SettingsLocation {tab: string;/** In-page anchor to scroll to (see `SettingsSection`/`SettingsRow`). */@@ -42,6 +53,11 @@ export function resolveSettingsLocation(case "issue":case "chat":return { tab: "preferences", section: tab, integration: null };+ case "preferences":+ if (section && Object.hasOwn(APPEARANCE_SECTIONS, section)) {+ return { tab: "appearance", section: APPEARANCE_SECTIONS[section] ?? null, integration: null };+ }+ return { tab, section, integration };case "labs":return { tab: "workspace", section: null, integration: null };case "github":diff --git a/packages/views/settings/components/settings-page.tsx b/packages/views/settings/components/settings-page.tsxindex dde093fcc4..100ea3ae40 100644--- a/packages/views/settings/components/settings-page.tsx+++ b/packages/views/settings/components/settings-page.tsx@@ -12,6 +12,7 @@ import {ListPlus,Lock,MessagesSquare,+ Palette,Plug,Search,Server,@@ -37,6 +38,7 @@ import { resolveSettingsLocation, settingsHref } from "./settings-navigation";import { AppLink, useNavigation } from "../../navigation";import { AccountTab } from "./account-tab";import { PreferencesTab } from "./preferences-tab";+import { AppearanceTab } from "./appearance-tab";import { TokensTab } from "./tokens-tab";import { WorkspaceTab } from "./workspace-tab";import { MembersTab } from "./members-tab";@@ -157,6 +159,12 @@ export function SettingsPage({ extraDeviceTabs = [] }: SettingsPageProps = {}) {SlidersHorizontal,<PreferencesTab />,),+ entry(+ "appearance",+ t(($) => $.page.tabs.appearance),+ Palette,+ <AppearanceTab />,+ ),entry("notifications",t(($) => $.page.tabs.notifications),@@ -439,7 +447,7 @@ export function SettingsPage({ extraDeviceTabs = [] }: SettingsPageProps = {}) {);return (- <div className="flex min-h-0 flex-1 flex-col overflow-hidden bg-background md:flex-row">+ <div data-mc="settings-page" className="flex min-h-0 flex-1 flex-col overflow-hidden bg-background md:flex-row"><ListColumncollapsed={listCollapsed}// Below md the navigation stacks above the content as a select.diff --git a/packages/views/settings/components/use-settings-search-index.ts b/packages/views/settings/components/use-settings-search-index.tsindex b9b7537dde..a2ae76a3b6 100644--- a/packages/views/settings/components/use-settings-search-index.ts+++ b/packages/views/settings/components/use-settings-search-index.ts@@ -52,7 +52,78 @@ export function useSettingsSearchIndex(title: t(($) => $.preferences.timezone.title),description: t(($) => $.preferences.timezone.hint),},- { tab: "preferences", anchor: "theme", title: t(($) => $.preferences.theme.title) },+ { tab: "appearance", anchor: "mode", title: t(($) => $.appearance.mode.title) },+ {+ tab: "appearance",+ anchor: "theme",+ title: t(($) => $.appearance.theme.title),+ description: t(($) => $.appearance.theme.description),+ },+ {+ tab: "appearance",+ anchor: "ui-text",+ title: t(($) => $.appearance.ui_text.title),+ description: t(($) => $.appearance.ui_text.description),+ },+ {+ tab: "appearance",+ anchor: "ui-cjk-font",+ title: `${t(($) => $.appearance.ui_text.title)} · ${t(($) => $.appearance.cjk_font.title)}`,+ description: t(($) => $.appearance.cjk_font.description),+ },+ {+ tab: "appearance",+ anchor: "font-size",+ title: t(($) => $.appearance.font_size.title),+ description: t(($) => $.appearance.font_size.description),+ },+ {+ tab: "appearance",+ anchor: "content-text",+ title: t(($) => $.appearance.content_text.title),+ description: t(($) => $.appearance.content_text.description),+ },+ {+ tab: "appearance",+ anchor: "content-cjk-font",+ title: `${t(($) => $.appearance.content_text.title)} · ${t(($) => $.appearance.cjk_font.title)}`,+ description: t(($) => $.appearance.cjk_font.description),+ },+ {+ tab: "appearance",+ anchor: "code-font",+ title: t(($) => $.appearance.code_font.title),+ description: t(($) => $.appearance.code_font.description),+ },+ {+ tab: "appearance",+ anchor: "content-size",+ title: `${t(($) => $.appearance.content_text.title)} · ${t(($) => $.appearance.content_size.title)}`,+ description: t(($) => $.appearance.content_size.description),+ },+ {+ tab: "appearance",+ anchor: "content-leading",+ title: t(($) => $.appearance.content_leading.title),+ },+ {+ tab: "appearance",+ anchor: "density",+ title: t(($) => $.appearance.density.title),+ description: t(($) => $.appearance.density.description),+ },+ {+ tab: "appearance",+ anchor: "reduce-motion",+ title: t(($) => $.appearance.reduce_motion.title),+ description: t(($) => $.appearance.reduce_motion.description),+ },+ {+ tab: "appearance",+ anchor: "high-contrast",+ title: t(($) => $.appearance.high_contrast.title),+ description: t(($) => $.appearance.high_contrast.description),+ },{tab: "preferences",anchor: "sticky-comment-bar",diff --git a/packages/views/skills/components/runtime-local-skill-import-panel.test.tsx b/packages/views/skills/components/runtime-local-skill-import-panel.test.tsxindex 94ad2c33a5..03acf87015 100644--- a/packages/views/skills/components/runtime-local-skill-import-panel.test.tsx+++ b/packages/views/skills/components/runtime-local-skill-import-panel.test.tsx@@ -79,7 +79,6 @@ vi.mock("motion/react", () => ({className?: string;}) => <div className={className}>{children}</div>,},- useReducedMotion: () => true,}));import { RuntimeLocalSkillImportPanel } from "./runtime-local-skill-import-panel";diff --git a/packages/views/skills/components/runtime-local-skill-import-panel.tsx b/packages/views/skills/components/runtime-local-skill-import-panel.tsxindex c18eda705a..bd64d0cd2f 100644--- a/packages/views/skills/components/runtime-local-skill-import-panel.tsx+++ b/packages/views/skills/components/runtime-local-skill-import-panel.tsx@@ -1,7 +1,8 @@"use client";import { useEffect, useMemo, useRef, useState } from "react";-import { AnimatePresence, motion, useReducedMotion } from "motion/react";+import { AnimatePresence, motion } from "motion/react";+import { useReducedMotion } from "@multica/core/appearance";import { useQuery, useQueryClient } from "@tanstack/react-query";import {AlertCircle,@@ -504,7 +505,7 @@ export function RuntimeLocalSkillImportPanel({const wsId = useWorkspaceId();const qc = useQueryClient();const userId = useAuthStore((s) => s.user?.id ?? null);- const shouldReduceMotion = useReducedMotion() ?? false;+ const shouldReduceMotion = useReducedMotion();const { data: runtimes = [] } = useQuery(runtimeListOptions(wsId));const localRuntimes = useMemo(diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 8101902234..1880f989b9 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -254,6 +254,9 @@ importers:'@fontsource-variable/inter':specifier: ^5.2.5version: 5.2.8+ '@fontsource-variable/jetbrains-mono':+ specifier: ^5.3.0+ version: 5.3.0'@fontsource-variable/source-serif-4':specifier: ^5.2.9version: 5.2.9@@ -2435,6 +2438,9 @@ packages:'@fontsource-variable/[email protected]':resolution: {integrity: sha512-kOfP2D+ykbcX/P3IFnokOhVRNoTozo5/JxhAIVYLpea/UBmCQ/YWPBfWIDuBImXX/15KH+eKh4xpEUyS2sQQGQ==}+ '@fontsource-variable/[email protected]':+ resolution: {integrity: sha512-F32xpS2NsGYoQi2ADSkKTgpJj7ozajsGgDJ8woTnqjmIB+dxDIqImjl4pXZVEExu8UFZ2ndhmX18EBS/hdz3Lw==}+'@fontsource-variable/[email protected]':resolution: {integrity: sha512-PPcxjLFk/fS0WHg79pDM2YNvz61kC+oYZ5cWZZyCS0DHpJncmuYOuiZAsvj4tDxlWPBEvxxcRLQQNmSaRbPkqw==}@@ -13117,6 +13123,8 @@ snapshots:'@fontsource-variable/[email protected]': {}+ '@fontsource-variable/[email protected]': {}+'@fontsource-variable/[email protected]': {}'@formatjs/[email protected]': {}