pair-dark-mode-tokens-by-role
Use when adding a dark theme. Maps semantic tokens to two palettes by role and re-derives surfaces and shadows instead of inverting colours.
- License 许可
- MIT
- 最近更新
- 2026-11-13
- Stars
- ★ 81
- Forks
- 17
01 前言 Front Matter
- name
- pair-dark-mode-tokens-by-role
- description
- Use when adding a dark theme. Maps semantic tokens to two palettes by role and re-derives surfaces and shadows instead of inverting colours.
02 资源文件 3
- 许可证LICENSE1.0 KB
- 参考文档SOURCE.md355 B
- 参考文档TRUST.auto.yaml2.2 KB
03 SKILL.md 正文
Pair dark mode tokens by role
Inverting a light palette produces muddy mid-greys and glowing whites because dark mode is a different material, not a negative. The durable approach is semantic tokens with two values per role.
Procedure
- Name tokens by role, never by hue:
--surface,--surface-raised,--text-primary,--text-muted,--border,--accent.--grey-200cannot carry a different meaning in two themes. - Define both palettes on the same token names, scoped to a theme attribute: :root[data-theme="light"] { --surface:#ffffff; --surface-raised:#f7f7f8; --text-primary:#111318; } :root[data-theme="dark"] { --surface:#0e1117; --surface-raised:#1a1f27; --text-primary:#e8eaed; }
- In dark mode make raised surfaces lighter, not darker. Elevation reads as "closer to the light source" in both themes; a dark card must be lighter than the page behind it.
- Lower pure whites: use
#e8eaed-range text on dark, not#ffffff. Full white on near-black vibrates and is the single most common dark-mode mistake. - Re-pick accent colours. A saturated blue tuned for white has too little contrast on
#0e1117; lighten it and re-check at 4.5:1 rather than reusing the hex. - Replace drop shadows with a lighter border or a subtle top highlight in dark mode — shadows are invisible on dark and the element loses separation.
- Handle images and logos: a black wordmark disappears on dark. Serve a swapped asset via
<picture>withprefers-color-scheme, or place it on a light chip. - Set
color-scheme: darkon the root so form controls, scrollbars and the default canvas follow the theme.
Pitfalls
- Inverting with a CSS filter (
filter: invert(1)), which mangles images, brand colours and photos. - Only theming the page background and leaving modals, tooltips and menus on the light palette because they render in a portal outside the themed root.
- Reusing semantic names bound to one theme, so
--backgroundmeans white in light and someone hard-codes it as the card colour. - Assuming the OS preference equals the app preference; store an explicit user override and apply it before first paint.
Verification
# Confirm both themes define the same token set (no gaps):
for t in light dark; do
grep -oE "\-\-[a-z-]+:" src/styles/tokens.css | sort -u > /tmp/$t.txt
done
diff <(grep -A20 'data-theme="light"' src/styles/tokens.css | grep -oE '\-\-[a-z-]+') \
<(grep -A20 'data-theme="dark"' src/styles/tokens.css | grep -oE '\-\-[a-z-]+')
An empty diff means both palettes cover the same roles. Then screenshot both themes and confirm no element is a light surface on the dark page. Report the token strategy and any role defined in one theme only.
04 同仓库更多 Skills
recipe-performance
Diagnose a specific MetaMask user flow's real-app performance and Sentry critical-user-flow telemetry with deterministic mm-harness recipes. Use for CUF boundaries, cold/warm/background-resume behavior, latency regressions, lifecycle tags, duplicate or blocking network requests, long tasks, layout/paint cost, screen redraws, React rerenders, or browser trace analysis where tests alone cannot prove the real app.
mexc-spot-websocket
MEXC Spot WebSocket workflows for public streams, protobuf handling, depth maintenance, listen keys, and private streams without exposing API keys.
mexc-spot-rest
MEXC Spot REST workflows for public data, signed account requests, orders, wallet/admin actions, and secure signing without exposing API keys.
mexc-futures-websocket
MEXC Futures WebSocket workflows for public streams, private account/order/position streams, ping/pong, subscriptions, and depth maintenance.
0xklen-version-and-refresh-sanctions-lists
暂无简介
verify-tests-cover-changed-lines
Use when a PR adds code that the existing suite may not exercise. Measures patch coverage — the share of newly changed lines hit by tests — before approving.