Skip to content

Conversation

@weareoutman
Copy link
Member

@weareoutman weareoutman commented Jul 9, 2025

依赖检查

组件之间的依赖声明,是微服务组件架构下的重要信息,请确保其正确性。

请勾选以下两组选项其中之一:

  • 本次 MR 没有使用上游组件(例如框架、后台组件等)的较新版本提供的特性。

或者:

  • 本次 MR 使用了上游组件(例如框架、后台组件等)的较新版本提供的特性。
  • 在对应的文件中更新了该上游组件的依赖版本(或确认了当前声明的依赖版本已包含本次 MR 使用的新特性)。

提交信息检查

Git 提交信息将决定包的版本发布及自动生成的 CHANGELOG,请检查工作内容与提交信息是否相符,并在以下每组选项中都依次确认。

破坏性变更是针对于下游使用者而言,可以通过本次改动对下游使用者的影响来识别变更类型:

  • 下游使用者不做任何改动,仍可以正常工作时,那么它属于普通变更。
  • 反之,下游使用者不做改动就无法正常工作时,那么它属于破坏性变更。

例如,构件修改了一个属性名,小产品 Storyboard 中需要使用新属性名才能工作,那么它就是破坏性变更。
又例如,构件还没有任何下游使用者,那么它的任何变更都是普通变更。

破坏性变更:

  • ⚠️ 本次 MR 包含破坏性变更的提交,请继续确认以下所有选项:
  • 没有更好的兼容方案,必须做破坏性变更。
  • 使用了 feat 作为提交类型。
  • 标注了 BREAKING CHANGE: 你的变更说明
  • 同时更新了本仓库中所有下游使用者的调用。
  • 同时更新了本仓库中所有下游使用者对该子包的依赖为即将发布的 major 版本。
  • 同时为其它仓库的 Migrating 做好了准备,例如文档或批量改动的方法。
  • 手动验证过破坏性变更在 Migrate 后可以正常工作。
  • 破坏性变更所在的提交没有意外携带其它子包的改动。

新特性:

  • 本次 MR 包含新特性的提交,且该提交不带有破坏性变更,并使用了 feat 作为提交类型。
  • 给新特性添加了单元测试。
  • 手动验证过新特性可以正常工作。

问题修复:

  • 本次 MR 包含问题修复的提交,且该提交不带有新特性或破坏性变更,并使用了 fix 作为提交类型。
  • 给问题修复添加了单元测试。
  • 手动验证过问题修复得到解决。

杂项工作:

即所有对下游使用者无任何影响、且没有必要显示在 CHANGELOG 中的改动,例如修改注释、测试用例、开发文档等:

  • 本次 MR 包含杂项工作的提交,且该提交不带有问题修复、新特性或破坏性变更,并使用了 chore, docs, test 等作为提交类型。

Summary by CodeRabbit

  • 新功能

    • 引入了“主题变体”功能,支持在“default”和“elevo”两种站点主题变体之间切换。
    • 新增了相关方法用于获取和设置当前主题变体,变体切换会同步更新页面属性并触发事件。
    • 新增了“elevo”主题相关的 CSS 变量,定义了品牌色、边框、背景等样式属性。
  • 测试

    • 增加了针对主题变体功能的测试用例,确保变体切换和属性更新的正确性。

@coderabbitai
Copy link

coderabbitai bot commented Jul 9, 2025

Walkthrough

本次更改引入了“主题变体(theme variant)”的概念,包括类型声明、主题变体的设置与获取函数、相关测试用例及全新 CSS 变量文件。还将“elevo”主题样式通过 CSS 文件集成到主题体系中,并在运行时逻辑和类型声明中增加对变体的支持。

Changes

文件路径/组 变更摘要
etc/runtime.api.md 新增 getThemeVariant(): SiteVariant 的导出声明及类型导入。
packages/runtime/src/index.ts themeAndMode.js 新增导出 getThemeVariant
packages/runtime/src/internal/Router.ts 在渲染流程中增加 setThemeVariant 调用,设置全局主题变体。
packages/runtime/src/themeAndMode.spec.ts 新增“variant”测试块,测试 setThemeVariantgetThemeVariant
packages/runtime/src/themeAndMode.ts 新增 SiteVariant 类型导入,新增 setThemeVariantgetThemeVariant 两个导出函数,实现主题变体的设置与获取,并同步更新 DOM 属性及派发事件。
packages/theme/src/elevo.css 新增 elevo.css,定义一组以 --elevo- 为前缀的 CSS 变量。
packages/theme/src/index.css 新增对 elevo.css 的导入。
packages/types/src/manifest.ts 新增类型别名 `SiteVariant = "default"

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/runtime/src/index.ts

Oops! Something went wrong! :(

ESLint: 9.29.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@next-core/eslint-config-next' imported from /eslint.config.mjs
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:801:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38)
at #link (node:internal/modules/esm/module_job:202:49)

packages/runtime/src/internal/Router.ts

Oops! Something went wrong! :(

ESLint: 9.29.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@next-core/eslint-config-next' imported from /eslint.config.mjs
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:801:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38)
at #link (node:internal/modules/esm/module_job:202:49)

packages/runtime/src/themeAndMode.spec.ts

Oops! Something went wrong! :(

ESLint: 9.29.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@next-core/eslint-config-next' imported from /eslint.config.mjs
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:801:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38)
at #link (node:internal/modules/esm/module_job:202:49)

  • 4 others
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (1)
packages/theme/src/elevo.css (1)

8-8: 分隔符颜色透明度值需要验证

分隔符颜色使用了 rgba(222, 222, 223, 0.6) 的透明度值。建议验证这个透明度在不同背景下的视觉效果是否合适。

建议考虑将分隔符颜色也定义为基于主色调的变体:

-  --elevo-divider-color: rgba(222, 222, 223, 0.6);
+  --elevo-divider-color: rgba(0, 10, 26, 0.1);

这样可以与 --elevo-placeholder-color 保持色调一致性。

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 94ef9e4 and 04d4b49.

📒 Files selected for processing (8)
  • etc/runtime.api.md (2 hunks)
  • packages/runtime/src/index.ts (1 hunks)
  • packages/runtime/src/internal/Router.ts (2 hunks)
  • packages/runtime/src/themeAndMode.spec.ts (2 hunks)
  • packages/runtime/src/themeAndMode.ts (2 hunks)
  • packages/theme/src/elevo.css (1 hunks)
  • packages/theme/src/index.css (1 hunks)
  • packages/types/src/manifest.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
packages/runtime/src/internal/Router.ts (2)
packages/runtime/src/themeAndMode.ts (1)
  • setThemeVariant (107-120)
packages/runtime/src/internal/Runtime.ts (1)
  • getRuntime (191-191)
packages/runtime/src/themeAndMode.ts (2)
packages/types/src/manifest.ts (1)
  • SiteVariant (1624-1624)
packages/runtime/src/index.ts (1)
  • getThemeVariant (28-28)
packages/runtime/src/themeAndMode.spec.ts (2)
packages/runtime/src/themeAndMode.ts (2)
  • setThemeVariant (107-120)
  • getThemeVariant (122-124)
packages/runtime/src/index.ts (1)
  • getThemeVariant (28-28)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build (20.x)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (16)
packages/types/src/manifest.ts (1)

1621-1624: 类型定义看起来很好!

新增的 SiteVariant 类型定义符合现有代码模式,与 SiteThemeSiteMode 的定义结构一致。类型限制为两个字符串字面量值是合理的设计选择。

packages/theme/src/index.css (1)

8-8: CSS 导入添加正确!

新增的 elevo.css 导入语句位置合适,与现有的主题相关导入保持一致的结构。

etc/runtime.api.md (2)

41-41: 类型导入正确!

正确导入了 SiteVariant 类型,为新的主题变体功能提供类型支持。


236-237: 函数声明符合规范!

getThemeVariant() 函数声明正确,返回类型与实现一致。注意该函数当前标记为未文档化,后续可能需要补充文档。

packages/runtime/src/index.ts (1)

28-28: 导出添加正确!

新增的 getThemeVariant 导出与其他主题相关函数归组合理,遵循现有的导出模式。

packages/runtime/src/internal/Router.ts (2)

33-33: 导入添加正确!

setThemeVariant 函数导入与其他主题相关函数归组合理,遵循现有的导入模式。


408-408: 主题变体设置调用位置合适!

setThemeVariant 调用位置恰当,紧跟在 setThemesetMode 之后,作为主题配置流程的一部分。根据相关代码片段,该函数内部已处理无效值的情况,会默认设置为 "default",因此即使 globalThemeVariant 未定义或无效也能安全处理。

packages/runtime/src/themeAndMode.spec.ts (2)

10-11: 函数导入命名一致性良好

导入的函数使用下划线前缀以避免与测试中的局部变量冲突,命名约定与现有的 theme 和 mode 测试保持一致。


151-162: 测试设置遵循现有模式

测试设置正确地重置模块并初始化 DOM 状态,与现有的 theme 和 mode 测试保持一致的模式。

packages/runtime/src/themeAndMode.ts (3)

1-1: 类型导入正确

正确导入了 SiteVariant 类型,与现有的 SiteModeSiteTheme 类型保持一致。


105-105: 变量初始化遵循现有模式

变量初始化为 "default" 值,与现有的 thememode 变量的初始化模式保持一致。


122-124: getter 函数实现正确

getThemeVariant 函数实现简洁正确,返回类型明确,与现有的 getTheme()getMode() 函数保持一致。

packages/theme/src/elevo.css (4)

1-17: CSS 变量命名规范良好

CSS 变量使用 --elevo- 前缀保持命名空间隔离,变量名描述性强且结构清晰。颜色变量同时提供了 RGB 通道和十六进制值,便于不同场景使用。


10-11: 组件背景样式设计合理

组件背景使用半透明白色配合模糊效果,这是现代 UI 设计中常见的毛玻璃效果实现方式。backdrop-filter 属性提供了良好的视觉层次。


14-15: 输入框阴影使用 RGB 通道变量

输入框阴影巧妙地使用了 RGB 通道变量 var(--elevo-color-brand-rgb-channel) 配合透明度,这样可以保持与品牌色的一致性,同时允许透明度调整。


2-5: 确认品牌色对比度符合 WCAG AA 要求

  • #2540ff 在白色背景(#ffffff)下的对比度为 5.64:1(≥4.5:1,符合 AA 普通文本要求)。
  • #2540ff 在黑色背景(#000000)下的对比度为 8.76:1(符合所有文本和 UI 组件要求)。

如果在其他背景色上使用,请使用 WebAIM Contrast Checker、AccessibleWeb 等工具验证是否满足 4.5:1(文字/UI 元素)或 3:1(图形/非文字元素)的最低对比度标准。

无需对 packages/theme/src/elevo.css 中定义的品牌色进行修改。

@cypress
Copy link

cypress bot commented Jul 9, 2025

next-core    Run #11482

Run Properties:  status check passed Passed #11482  •  git commit 97efd74fd1 ℹ️: Merge 04d4b49099df43afa98fd638a3144c8133f49477 into 94ef9e433ff9e6d69e446d240c2a...
Project next-core
Branch Review steve/v3-theme-variant
Run status status check passed Passed #11482
Run duration 00m 27s
Commit git commit 97efd74fd1 ℹ️: Merge 04d4b49099df43afa98fd638a3144c8133f49477 into 94ef9e433ff9e6d69e446d240c2a...
Committer Shenwei Wang
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 17
View all changes introduced in this branch ↗︎

@codecov
Copy link

codecov bot commented Jul 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.23%. Comparing base (94ef9e4) to head (04d4b49).
Report is 2 commits behind head on v3.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##               v3    #4747   +/-   ##
=======================================
  Coverage   95.23%   95.23%           
=======================================
  Files         209      209           
  Lines        9120     9131   +11     
  Branches     1756     1758    +2     
=======================================
+ Hits         8685     8696   +11     
  Misses        322      322           
  Partials      113      113           
Files with missing lines Coverage Δ
packages/runtime/src/internal/Router.ts 95.37% <100.00%> (+0.01%) ⬆️
packages/runtime/src/themeAndMode.ts 96.29% <100.00%> (+0.84%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@weareoutman weareoutman requested a review from Copilot July 9, 2025 11:33
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds support for a “theme variant” concept, introducing a new SiteVariant type, CSS variables for an “elevo” variant, and runtime APIs to get/set the current variant.

  • Defined SiteVariant in type manifests.
  • Imported and defined CSS vars for the “elevo” variant.
  • Implemented setThemeVariant/getThemeVariant, added tests, integrated in router, and exposed API for reading the variant.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/types/src/manifest.ts Introduced SiteVariant type
packages/theme/src/index.css Imported elevo.css for new variant
packages/theme/src/elevo.css Defined CSS variables for “elevo” theme variant
packages/runtime/src/themeAndMode.ts Implemented setThemeVariant/getThemeVariant
packages/runtime/src/themeAndMode.spec.ts Added unit tests for variant behavior
packages/runtime/src/internal/Router.ts Integrated variant init into router setup
packages/runtime/src/index.ts Exposed getThemeVariant in public API exports
etc/runtime.api.md Documented getThemeVariant in API reference
Comments suppressed due to low confidence (5)

packages/runtime/src/index.ts:28

  • Consider also exporting setThemeVariant in the public API so consumers can programmatically switch theme variants.
  getThemeVariant,

etc/runtime.api.md:237

  • Add documentation for setThemeVariant to the API reference to reflect its availability and behavior.
export function getThemeVariant(): SiteVariant;

packages/runtime/src/themeAndMode.spec.ts:151

  • Add a test case to cover the branch where setThemeVariant receives an invalid value and falls back to "default".
describe("variant", () => {

packages/runtime/src/themeAndMode.ts:107

  • Add JSDoc comments to describe the behavior of setThemeVariant, including its fallback logic and dispatched "variant.change" event.
export function setThemeVariant(value: unknown) {

packages/runtime/src/themeAndMode.ts:115

  • [nitpick] Consider namespacing the custom event (e.g., "theme.variant.change") to avoid potential conflicts with other global events.
  window.dispatchEvent(

Comment on lines +164 to +185
test("should set theme variant", () => {
expect(getThemeVariant()).toEqual("default");
expect(document.documentElement.dataset.variant).toBe("default");
setThemeVariant("elevo");
expect(getThemeVariant()).toEqual("elevo");
expect(document.documentElement.dataset.variant).toBe("elevo");
});

test("should apply the current theme variant", () => {
expect(getThemeVariant()).toEqual("default");
expect(document.documentElement.dataset.variant).toBe("default");
setThemeVariant("elevo");
expect(document.documentElement.dataset.variant).toBe("elevo");
});

test("should apply the specified theme variant", () => {
expect(getThemeVariant()).toEqual("default");
expect(document.documentElement.dataset.variant).toBe("default");
setThemeVariant("elevo");
expect(getThemeVariant()).toEqual("elevo");
expect(document.documentElement.dataset.variant).toBe("elevo");
});
Copy link

Copilot AI Jul 9, 2025

Choose a reason for hiding this comment

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

[nitpick] This test overlaps significantly with other variant tests; consider consolidating or removing redundant cases to streamline maintenance.

Suggested change
test("should set theme variant", () => {
expect(getThemeVariant()).toEqual("default");
expect(document.documentElement.dataset.variant).toBe("default");
setThemeVariant("elevo");
expect(getThemeVariant()).toEqual("elevo");
expect(document.documentElement.dataset.variant).toBe("elevo");
});
test("should apply the current theme variant", () => {
expect(getThemeVariant()).toEqual("default");
expect(document.documentElement.dataset.variant).toBe("default");
setThemeVariant("elevo");
expect(document.documentElement.dataset.variant).toBe("elevo");
});
test("should apply the specified theme variant", () => {
expect(getThemeVariant()).toEqual("default");
expect(document.documentElement.dataset.variant).toBe("default");
setThemeVariant("elevo");
expect(getThemeVariant()).toEqual("elevo");
expect(document.documentElement.dataset.variant).toBe("elevo");
});
test("should handle theme variant correctly", () => {
// Verify initial state
expect(getThemeVariant()).toEqual("default");
expect(document.documentElement.dataset.variant).toBe("default");
// Set a new theme variant and verify changes
setThemeVariant("elevo");
expect(getThemeVariant()).toEqual("elevo");
expect(document.documentElement.dataset.variant).toBe("elevo");
// Verify that the current theme variant is applied correctly
expect(document.documentElement.dataset.variant).toBe("elevo");
});

Copilot uses AI. Check for mistakes.
@weareoutman weareoutman merged commit 032a21e into v3 Jul 9, 2025
9 checks passed
@weareoutman weareoutman deleted the steve/v3-theme-variant branch July 9, 2025 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants