Theme tokens

From 2017YANR02/cuberoot.me · View interactive version

Theme tokens is an AI agent skill from the GitHub repository 2017YANR02/cuberoot.me. Use whenever editing 颜色、background、border、text color、dark/light mode, theme tokens, color-mix, hex, rgba, or hard-coded grays such as #888. Reuse the site's token system and dark-locked page rules.

How to use this skill

Skill file

Theme tokens — Codex 风 hex + color-mix

Web 与安装端共用的 token 定义在 core/packages/app-ui/src/appearance.css :root,公开入口为 @cuberoot/app-ui/appearance.css;Web 的 globals.css 只保留页面暗锁等站点策略。完整色值表 + 决策树见下方表格 + 决策树小节(原 client-vite/DESIGN.md / client-vite/src/pages/THEMING.md 未随 Vite 退役迁过来)。

写新 CSS 必查 token 表

| 用途 | Token |

|---|---|

| 页面主背景 | var(--background) |

| 卡片 / panel 背景 | 先查下方全站材质契约;无场景背景时使用 var(--card) / var(--popover) / var(--muted) |

| 主文字 | var(--foreground) |

| 副信息文字 | var(--muted-foreground) |

| 弱化 / disabled / 占位文字 | var(--faint-foreground) |

| 默认边框 | var(--border-default) |

| 强边框 | var(--border-strong) |

| 输入框边框 | var(--input) |

| focus ring | var(--ring) |

| 品牌强调 (terracotta) | var(--accent) |

| accent 上文字 | var(--accent-foreground) |

| accent tag/badge 弱化背景 | var(--accent-soft) |

| 主按钮背景 | var(--primary) |

| 主按钮文字 | var(--primary-foreground) |

| 危险/删除 | var(--destructive) / var(--destructive-foreground) |

| 成功 | var(--signal-success) |

| 警告 | var(--signal-warning) |

| 信息 | var(--signal-info) |

| 开关「开启态」(iOS 绿,PillToggle/switch) | var(--toggle-on) |

衍生色:一律 color-mix

/* 半透明叠加 */
background: color-mix(in srgb, var(--foreground) 8%, transparent);
border: 1px solid color-mix(in srgb, var(--foreground) 20%, transparent);

/* hover / 提亮 */
background: color-mix(in srgb, var(--accent) 88%, black);    /* 压一档 */
background: color-mix(in srgb, var(--accent) 12%, transparent); /* tag 弱化 */

禁 手算 rgba(255, 235, 220, 0.08) 这种。Anthropic CDS 也是 color-mix(in srgb, ...) 644 处实战。

决策树

  1. 品牌强调? → --accent
  2. 状态色? (success/warning/danger/info) → --signal-success/-warning/-info / --destructive
  3. 文字层级? → --foreground (主) / --muted-foreground (副) / --faint-foreground (弱)
  4. 面板背景? → 复用全站材质角色;默认主题色用 --card / --popover / --muted / --secondary
  5. 边框? → --border-default / --border-strong / --input / --ring
  6. 都不是? → 多半想多了,选 --muted-foreground 或 --border-default

页面主题策略 (写 CSS 前先确认是哪类)

| 页 | 模式 | 处理 |

|---|---|---|

| /wca/calendar /wb /memo/colpi /alg /trainer (含 /trainer/3bld/*) /battle /recon /mosaic /site | 双主题 | 走 :root token,自动 light/dark 翻 |

| /wca/* 统计页面 (含 records/wse/t10h/fun-stats/result-watch/comp/stats) | 双主题 | 继承全站 token,跟随系统明暗、用户选择与配色预览;禁止重新加页面级暗色锁 |

| /calc | palette-inert light | html:root:has(.calc-page)(0,2,1 outrank 配色块)钉 light + --background/--foreground,所有配色都不渗入(art-directed 奶油纸) |

配色主题 × 锁页(2026-06-16)

全站透明材质

Light/dark 反盖 (写新 :root token 才用)

:root { --background: #FAF9F5; --foreground: #181716; }

/* 跟系统 dark + 显式 data-theme=dark */
@media (prefers-color-scheme: dark) {
  html:not([data-theme=light]) {  /* 禁 :where() 包裹,会让 specificity 变 0 */
    --background: #1c1917;
    --foreground: #f0ebe3;
  }
}
html[data-theme=dark] {
  --background: #1c1917;
  --foreground: #f0ebe3;
}

禁区

测试矩阵 (改主题相关 CSS 必跑 4 cell)

DevTools → F12 → Ctrl+Shift+P → "Emulate CSS prefers-color-scheme"

| ThemeToggle | OS pref | 期望 |

|---|---|---|

| system | light | light 视觉 |

| system | dark | dark 视觉 (最容易漏的格子) |

| light | dark | light 视觉 (用户强切 light) |

| dark | light | dark 视觉 (用户强切 dark) |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.