Skip to content

feat: 完善深色模式——组件 token 化、移除 cssVar 死接口、主题文档 - #19

Merged
vaebe merged 5 commits into
mainfrom
style-dark
Jun 4, 2026
Merged

feat: 完善深色模式——组件 token 化、移除 cssVar 死接口、主题文档#19
vaebe merged 5 commits into
mainfrom
style-dark

Conversation

@vaebe

@vaebe vaebe commented Jun 4, 2026

Copy link
Copy Markdown
Owner

正文
深色基础设施(ConfigProvider algorithm:'dark'、token 体系、.dark 级联)此前已就绪,本次补齐组件、API、文档三层。

改动

  • 组件:auto-complete / button / button-3d / color-picker / mentions / popover / tooltip / transfer / upload 的硬编码灰阶与白色表面改为 $ccui-* token,深色下随主题级联;保留恒为白的元素(彩色按钮白字、滑块手柄描边、渐变停靠色、alpha 棋盘格、switch 旋钮)
  • tokenthemes/light.ts + dark.ts 新增 button-info*color-picker-alpha-checker(均带 light/dark 双值)
  • API:移除 ThemeConfig.cssVar 死接口(ccui 全程 CSS 变量驱动,该标志为 no-op)
  • 文档:新增「主题定制 / 深色模式」指南页(主推根元素 .dark 类切换)
  • 修复:divider 米色背景 demo 在深色下白字不可读——底色与文字一并钉死并补配对说明
  • 工程.ls-lint.yml 忽略 docs-notes 目录(内部笔记不受 kebab-case 约束)

验证

  • cd packages/ccui && pnpm test → 对基线零增减
  • pnpm docs:build → exit 0,无 Undefined variable

Summary by CodeRabbit

  • Documentation

    • Added comprehensive theme customization guide covering dark mode, token system, and dynamic switching.
    • Enhanced divider component documentation with styling recommendations.
  • Style

    • Updated UI components to use unified design tokens instead of hardcoded colors for consistent theming across auto-complete, buttons, color-picker, mentions, popover, tooltip, transfer, and upload components.
  • Refactor

    • Simplified ConfigProvider ThemeConfig API by removing the cssVar option; now supports only token and algorithm.

vaebe and others added 5 commits June 4, 2026 10:33
深色基础设施(ConfigProvider algorithm:'dark'、token 体系、.dark 级联)此前已就绪,
本次补齐使其在组件、API、文档三层完整:

- 组件:auto-complete / button / button-3d / color-picker / mentions / popover /
  tooltip / transfer / upload 的硬编码灰阶与白色表面填充改为 $ccui-* token,
  深色下随主题级联;保留恒为白的元素(彩色按钮白字、滑块手柄描边、
  SV/hue 渐变停靠色、alpha 棋盘格、switch 旋钮)
- token:themes/light.ts + dark.ts 新增 button-info* 与 color-picker-alpha-checker
  (均带 light/dark 双值)
- API:移除 ThemeConfig.cssVar 死接口(ccui 全程 CSS 变量驱动,该标志为 no-op)
- 文档:新增「主题定制 / 深色模式」指南页(主推根元素 .dark 类切换),登记侧边栏入口
- 文档站:每个 demo 注入浅/深就地预览开关,仅切容器自身 .dark,不影响全站 appearance
- 修复:tooltip / popover 原本纯硬编码、缺 style-var 引入,换 token 后真实构建报
  Undefined variable,补 @use '../../style-var/index.scss' as *;

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
docs-notes 是面向贡献者的内部维护笔记(含 README.md 等非 kebab 命名),
与 docs-notes 已是 Ant 提及 / 格式 debt 的豁免区一致,显式加入 .ls-lint.yml
ignore,使命名检查跳过该目录。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
content-background-color="#fff7e6" 钉死了浅米色底,但未设 content-color,
文字跟随主题 → 深色模式下变白,白字落在米色底上糊成一片。补一个深暖色
content-color="#874d00",浅/深两模式均可读;说明里同步补上「钉死浅底时
须一并钉死文字色」的配对原则。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
旧实现只 toggle demo 容器自身的 .dark,但 .dark 会从任意祖先级联。全站深色
(html.dark)时容器即便不带 .dark 也继承深色,单纯增删容器的 .dark 切不回浅色,
按钮状态也读错(恒显示 ☾)。

- generate-theme.js:darkTheme.css 在 .dark{} 外再产出对称的 .light{}(light 全集)。
  CSS 自定义属性按元素就近解析,子树容器上挂 .light 即可覆盖外层 html.dark 下传值。
- demoDarkToggle.ts:改为给容器挂【显式】互斥的 .dark / .light,并以容器当前实际
  渲染态(含全站继承)为基准取反,首次点击在浅/深任一全站模式下都正确翻转;
  另监听 html.class 变化,跟随全站的未显式选择容器同步按钮图标。

darkTheme.css 是 gitignored 生成产物,随 postinstall/bootstrap 重生成。
pnpm docs:build 通过(exit 0,无 Undefined variable)。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
实际意义不大,整体撤掉 Track D:
- 删 demoDarkToggle.ts 及 theme/index.ts 中的注入调用
- 删 styles/index.css 中 .ccui-demo-dark-toggle 按钮样式
- 撤 generate-theme.js 中专为该功能加的 .light{} 生成(darkTheme.css 复原为仅 .dark{})
- 删主题文档末尾「文档站内试试开关」提示段

全站深色仍由 html.dark / ConfigProvider algorithm:'dark' 提供,组件 token 化与
主题指南页保留。pnpm docs:build 通过(exit 0)。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

This PR systematizes the ccui design token architecture by introducing shared theme tokens and migrating component stylesheets to use them, while simplifying the ConfigProvider API and documenting the complete theming system for end users.

Changes

Design System Token Adoption

Layer / File(s) Summary
Theme token expansion
packages/theme/themes/light.ts, packages/theme/themes/dark.ts
Light and dark theme maps are extended with button-info* variants (button-info, button-info-hover, button-info-active, button-info-plain-bg, button-info-plain-border) and a new color-picker-alpha-checker token.
Configuration type system and linting
packages/ccui/ui/config-provider/src/config-provider-types.ts, .ls-lint.yml
ThemeConfig interface removes the cssVar flag, retaining only token and algorithm options. Linting configuration excludes the docs-notes directory from naming constraints.
Component stylesheet token adoption
packages/ccui/ui/button/src/button.scss, packages/ccui/ui/button-3d/src/button-3d.scss, packages/ccui/ui/auto-complete/src/auto-complete.scss, packages/ccui/ui/color-picker/src/color-picker.scss, packages/ccui/ui/upload/src/upload.scss, packages/ccui/ui/transfer/src/transfer.scss, packages/ccui/ui/mentions/src/mentions.scss, packages/ccui/ui/popover/src/popover.scss, packages/ccui/ui/tooltip/src/tooltip.scss
Nine component stylesheets replace hardcoded hex colors with shared $ccui-* design tokens for borders, backgrounds, disabled states, and theme-variant colors. Each component adopts the token pattern consistently across button styles, form control borders, dropdown panels, drag zones, and overlay backgrounds.
Theme documentation, guides, and sidebar generation
packages/docs/components/theme/index.md, packages/docs/components/config-provider/index.md, packages/docs/components/divider/index.md, packages/cli/templates/vitepress-sidebar.js
Comprehensive new theme guide documents CSS variable overrides, .dark class-based dark mode, application-level and subtree-scoped switching via ConfigProvider, token mechanics, and token-based customization examples. ConfigProvider and divider documentation are updated to reflect API changes and best practices. VitePress sidebar generation now includes the theme guide in both zh and en menus.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • vaebe/ccui#7: Popover component implementation and styling; this PR refactors popover.scss to use shared design tokens aligned with that component's introduction.
  • vaebe/ccui#6: Both PRs modify tooltip.scss to migrate theme/color styling from hardcoded values to shared token variables.

Poem

🐰 Hopping through colors with tokens so bright,
From hardcoded hues to variables of light,
Buttons and pickers now dance in theme's sway,
Dark mode and light mode—no changes to pay! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main objectives: dark mode refinement, component tokenization, removal of the cssVar API, and theme documentation.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch style-dark

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/ccui/ui/upload/src/upload.scss (1)

195-195: ⚡ Quick win

Align primary token usage in upload.scss ($ccui-primary vs $ccui-color-primary)

packages/ccui/ui/upload/src/upload.scss uses $ccui-primary only here: border-color: $ccui-primary; (line 195), while the rest of the file consistently uses $ccui-color-primary*. $ccui-primary is also used across other components, and neither token is defined within this repo (tokens likely come from @vaebe/ccui-theme). If $ccui-primary is intended to match $ccui-color-primary, replace line 195 to keep token naming consistent within upload.scss.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/ccui/ui/upload/src/upload.scss` at line 195, The border-color
declaration in upload.scss uses the inconsistent token $ccui-primary; update it
to the consistent token family used elsewhere in this file by replacing that
occurrence with $ccui-color-primary so the border-color property aligns with the
other $ccui-color-primary* tokens (locate the border-color: $ccui-primary; line
in packages/ccui/ui/upload/src/upload.scss and change the token).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/ccui/ui/upload/src/upload.scss`:
- Line 195: The border-color declaration in upload.scss uses the inconsistent
token $ccui-primary; update it to the consistent token family used elsewhere in
this file by replacing that occurrence with $ccui-color-primary so the
border-color property aligns with the other $ccui-color-primary* tokens (locate
the border-color: $ccui-primary; line in packages/ccui/ui/upload/src/upload.scss
and change the token).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: de546481-fcbf-426b-a86f-b2b7bb1c8e0f

📥 Commits

Reviewing files that changed from the base of the PR and between 8c5bbb3 and d1f8f0e.

📒 Files selected for processing (17)
  • .ls-lint.yml
  • packages/ccui/ui/auto-complete/src/auto-complete.scss
  • packages/ccui/ui/button-3d/src/button-3d.scss
  • packages/ccui/ui/button/src/button.scss
  • packages/ccui/ui/color-picker/src/color-picker.scss
  • packages/ccui/ui/config-provider/src/config-provider-types.ts
  • packages/ccui/ui/mentions/src/mentions.scss
  • packages/ccui/ui/popover/src/popover.scss
  • packages/ccui/ui/tooltip/src/tooltip.scss
  • packages/ccui/ui/transfer/src/transfer.scss
  • packages/ccui/ui/upload/src/upload.scss
  • packages/cli/templates/vitepress-sidebar.js
  • packages/docs/components/config-provider/index.md
  • packages/docs/components/divider/index.md
  • packages/docs/components/theme/index.md
  • packages/theme/themes/dark.ts
  • packages/theme/themes/light.ts
💤 Files with no reviewable changes (1)
  • packages/ccui/ui/config-provider/src/config-provider-types.ts

@vaebe
vaebe merged commit 368c4d6 into main Jun 4, 2026
4 checks passed
@vaebe
vaebe deleted the style-dark branch June 4, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant