Skip to content

fix(configprovider): 调整demo展示 #3232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 22, 2025

Conversation

xiaoyatong
Copy link
Collaborator

@xiaoyatong xiaoyatong commented May 22, 2025

🤔 这个变动的性质是?

  • 新特性提交
  • 日常 bug 修复
  • 站点、文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • TypeScript 定义更新
  • 包体积优化
  • 性能优化
  • 功能增强
  • 国际化改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他改动(是关于什么的改动?)

🔗 相关 Issue

💡 需求背景和解决方案

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • fork仓库代码是否为最新避免文件冲突
  • Files changed 没有 package.json lock 等无关文件

Summary by CodeRabbit

  • 新功能
    • 简化并合并了 ConfigProvider 组件的演示示例,优化了主题和国际化展示方式。
  • 文档
    • 精简并合并了文档中的演示代码块,减少重复内容,提升文档可读性。
  • 重构
    • 统一和重命名了演示组件名称,移除冗余示例文件,结构更加清晰。
  • 移除
    • 删除了部分不再展示的演示组件及相关文档引用。

Copy link

coderabbitai bot commented May 22, 2025

Walkthrough

本次变更主要对 ConfigProvider 组件的演示示例和文档进行了简化和合并。具体包括:移除 Demo4 和 Demo5,重命名和合并 demo 组件,精简国际化和主题相关的文案与渲染结构,统一 demo 命名方式,并同步更新了中英文及 Taro 相关文档的 demo 展示部分。

Changes

文件/路径分组 变更摘要
src/packages/configprovider/demo.tsx
src/packages/configprovider/demo.taro.tsx
移除 Demo4、Demo5 的导入与渲染,合并/简化国际化文案与 demo 渲染顺序。
src/packages/configprovider/demos/h5/demo1.tsx
src/packages/configprovider/demos/taro/demo1.tsx
组件重命名为 Demo,增加 darkTheme,分别演示默认和自定义主题。
src/packages/configprovider/demos/h5/demo2.tsx
src/packages/configprovider/demos/taro/demo2.tsx
组件重命名为 Demo,移除主题演示,改为演示国际化(locale)功能。
src/packages/configprovider/demos/h5/demo3.tsx
src/packages/configprovider/demos/taro/demo3.tsx
组件重命名为 Demo,内容改为 Cell 组件,明确 direction="rtl"。
src/packages/configprovider/demos/h5/demo4.tsx
src/packages/configprovider/demos/h5/demo5.tsx
src/packages/configprovider/demos/taro/demo4.tsx
src/packages/configprovider/demos/taro/demo5.tsx
删除 Demo4、Demo5 相关文件。
src/packages/configprovider/doc.md
src/packages/configprovider/doc.en-US.md
src/packages/configprovider/doc.taro.md
src/packages/configprovider/doc.zh-TW.md
精简和合并 demo 展示区块,统一 demo 引用,移除部分 Taro/H5 demo 展示。

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ConfigProviderDemo
    participant Demo
    User->>ConfigProviderDemo: 打开演示页面
    ConfigProviderDemo->>Demo: 渲染主题演示
    ConfigProviderDemo->>Demo: 渲染国际化演示
    ConfigProviderDemo->>Demo: 渲染 RTL 演示
Loading

Possibly related PRs

  • jdf2e/nutui-react#2401: 也删除了 configprovider 的 Demo4 和 Demo5,处理 demo 依赖问题,涉及相同文件和组件。
  • jdf2e/nutui-react#2904: 修改了 demo2 的 darkTheme 属性,和本 PR 都有涉及 demo2,但关注点不同。

Poem

🐇
代码精简又合并,
演示组件少繁冗。
主题国际化,RTL,
皆在一页中。
小兔挥挥爪,
文档焕新容!

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 30th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.

✨ 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.

@github-actions github-actions bot added action:review This PR needs more reviews (less than 2 approvals) 3.x Target branch 3.x labels May 22, 2025
@xiaoyatong xiaoyatong requested a review from irisSong May 22, 2025 09:50
Copy link

codecov bot commented May 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.17%. Comparing base (77cf449) to head (2dfd07f).
Report is 1 commits behind head on feat_v3.x.

Additional details and impacted files
@@            Coverage Diff             @@
##           feat_v3.x    #3232   +/-   ##
==========================================
  Coverage      87.17%   87.17%           
==========================================
  Files            291      291           
  Lines          19210    19210           
  Branches        2930     2930           
==========================================
  Hits           16747    16747           
  Misses          2458     2458           
  Partials           5        5           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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.

@irisSong irisSong merged commit 4d47408 into jdf2e:feat_v3.x May 22, 2025
8 checks passed
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: 0

🧹 Nitpick comments (5)
src/packages/configprovider/demo.tsx (1)

25-30: Demo结构优化

将Demo结构简化为三个部分(主题、国际化和RTL)使演示更加清晰。但建议考虑添加更多注释来说明每个Demo的具体功能,以便开发者更容易理解每个示例的用途。

src/packages/configprovider/demos/h5/demo2.tsx (2)

5-5: 组件重命名

将组件从Demo2重命名为Demo,但文件名仍保持为demo2.tsx。为保持一致性,建议考虑将文件名也更新为demo.tsx,或者保持组件名为Demo2。

Also applies to: 22-22


8-17: 功能演示更简洁

通过两个ConfigProvider分别展示默认语言和英文语言环境下的TextArea组件,使国际化功能演示更加直观。但是,这里的TextArea都设置为disabled状态,可能不太容易看出语言切换的效果。考虑添加一些可见的文本内容来更明显地展示语言差异。

 <ConfigProvider>
   <Cell>
-    <TextArea disabled showCount maxLength={20} />
+    <TextArea disabled showCount maxLength={20} placeholder="请输入文本" />
   </Cell>
 </ConfigProvider>
 <ConfigProvider locale={enUS}>
   <Cell>
-    <TextArea disabled showCount maxLength={20} />
+    <TextArea disabled showCount maxLength={20} placeholder="Please enter text" />
   </Cell>
src/packages/configprovider/demos/h5/demo3.tsx (1)

2-2: 组件更新与重命名

将组件从Demo3重命名为Demo,并更新了导入的组件。建议保持组件名与文件名的一致性,可以考虑将文件名更新为demo.tsx或保持组件名为Demo3。

Also applies to: 4-4, 22-22

src/packages/configprovider/demos/taro/demo3.tsx (1)

2-3: Taro组件更新与重命名

将组件从Demo3重命名为Demo,并更新了Taro相关的组件导入。同样建议保持组件名与文件名的一致性,可以考虑将文件名更新为demo.tsx或保持组件名为Demo3。

Also applies to: 5-5, 27-27

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 77cf449 and 2dfd07f.

📒 Files selected for processing (16)
  • src/packages/configprovider/demo.taro.tsx (1 hunks)
  • src/packages/configprovider/demo.tsx (1 hunks)
  • src/packages/configprovider/demos/h5/demo1.tsx (2 hunks)
  • src/packages/configprovider/demos/h5/demo2.tsx (1 hunks)
  • src/packages/configprovider/demos/h5/demo3.tsx (1 hunks)
  • src/packages/configprovider/demos/h5/demo4.tsx (0 hunks)
  • src/packages/configprovider/demos/h5/demo5.tsx (0 hunks)
  • src/packages/configprovider/demos/taro/demo1.tsx (2 hunks)
  • src/packages/configprovider/demos/taro/demo2.tsx (1 hunks)
  • src/packages/configprovider/demos/taro/demo3.tsx (1 hunks)
  • src/packages/configprovider/demos/taro/demo4.tsx (0 hunks)
  • src/packages/configprovider/demos/taro/demo5.tsx (0 hunks)
  • src/packages/configprovider/doc.en-US.md (1 hunks)
  • src/packages/configprovider/doc.md (1 hunks)
  • src/packages/configprovider/doc.taro.md (1 hunks)
  • src/packages/configprovider/doc.zh-TW.md (1 hunks)
💤 Files with no reviewable changes (4)
  • src/packages/configprovider/demos/h5/demo4.tsx
  • src/packages/configprovider/demos/taro/demo5.tsx
  • src/packages/configprovider/demos/h5/demo5.tsx
  • src/packages/configprovider/demos/taro/demo4.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: test
🔇 Additional comments (25)
src/packages/configprovider/doc.zh-TW.md (2)

90-90: 文档中的演示引用已更新

将国际化部分的代码块引用从原先的demo更改为h5/demo2.tsx,确保与实际文件结构一致。这符合PR中简化和合并演示组件的目标。


98-98: RTL部分演示引用已更新

将RTL部分的代码块引用更改为h5/demo3.tsx,与重命名后的演示组件保持一致。

src/packages/configprovider/doc.en-US.md (2)

90-90: 文档中的演示引用已更新

国际化部分的代码块引用已更改为h5/demo2.tsx,这与PR中简化演示组件的目标一致。


98-98: RTL部分演示引用已更新

RTL部分的代码块引用已更改为h5/demo3.tsx,符合新的文件结构和命名规范。

src/packages/configprovider/doc.md (2)

90-90: 文档中的演示引用已更新

国际化部分的代码块引用已更改为h5/demo2.tsx,这与PR中简化和合并演示组件的目标一致。


98-98: RTL部分演示引用已更新

RTL部分的代码块引用已更改为h5/demo3.tsx,确保与重命名后的演示组件保持一致。

src/packages/configprovider/demos/h5/demo1.tsx (4)

4-9: 组件命名规范化并添加主题配置

组件从Demo1重命名为Demo,并添加了暗色主题配置,这有助于统一命名并更好地展示主题配置功能。


24-35: 新增第二个ConfigProvider展示主题效果

添加了使用自定义主题的第二个ConfigProvider实例,这样可以直观对比默认主题和自定义主题的效果,使演示更加完整。


40-40: 导出名称已更新

导出的组件名称已从Demo1更新为Demo,与组件声明保持一致。


6-6:

❌ Incorrect review comment

确认主题变量名称是否正确

nutuiColorPrimaryIcon与文档中列出的CSS变量不完全匹配。文档中提到的是--nutui-color-primary而非--nutui-color-primary-icon

请验证此变量名称是否正确,以确保用户在自定义主题时不会感到困惑。


🌐 Web query:

NutUI React 主题变量 nutuiColorPrimaryIcon

💡 Result:

在 NutUI React 中,nutuiColorPrimaryIcon 是用于设置主色调图标颜色的主题变量。要自定义该变量,建议使用 ConfigProvider 组件进行全局配置。通过 ConfigProvider,您可以方便地覆盖默认主题变量,实现主题定制。

以下是使用 ConfigProvider 自定义 nutuiColorPrimaryIcon 的示例:

import React from 'react';
import { ConfigProvider, Button } from '@nutui/nutui-react';

const App = () => {
  const customTheme = {
    nutuiColorPrimaryIcon: '#FF5733', // 设置主色调图标颜色为红色
  };

  return (
    <ConfigProvider theme={customTheme}>
      <Button type="primary">主按钮</Button>
    </ConfigProvider>
  );
};

export default App;

在上述代码中,ConfigProvidertheme 属性被设置为包含 nutuiColorPrimaryIcon 的对象,从而将主色调图标颜色修改为红色。这种方式可以确保主题变量的修改在整个应用中生效。

请注意,直接通过 CSS 变量覆盖主色调可能会导致某些组件的样式未能正确更新。因此,使用 ConfigProvider 进行主题定制是更为推荐的做法。

更多关于 NutUI React 主题定制的信息,请参考官方文档。


确认主题变量 nutuiColorPrimaryIcon 正确无误

nutuiColorPrimaryIcon 是 NutUI React 官方支持的主题变量,用于设置主色调图标颜色,可通过 ConfigProvidertheme 属性进行全局定制,无需改名或替换。

Likely an incorrect or invalid review comment.

src/packages/configprovider/demos/taro/demo1.tsx (3)

4-9: 组件重命名和主题对象添加得当

组件从 Demo1 重命名为 Demo,并添加了 darkTheme 对象定义三个绿色相关属性,使示例更加清晰。这种改进有助于用户理解如何自定义主题。


24-35: 主题对比展示清晰

新增的带有自定义主题的 ConfigProvider 部分与默认主题形成对比,让用户能够直观地看到主题定制的效果。这种并排展示的方式使示例更具教育意义。


40-40: 导出语句与组件名称保持一致

导出语句已更新为导出重命名后的 Demo 组件,保持了代码的一致性。

src/packages/configprovider/doc.taro.md (2)

90-90: 国际化演示引用更新

文档中的国际化部分现在引用了单个 demo 文件 'taro/demo2.tsx',这与简化后的 demo 结构一致。这个更改使文档与代码保持同步,避免了引用不存在的 demo 文件。


98-98: RTL 演示引用更新

RTL 部分现在引用了 'taro/demo3.tsx',而不是原来的 'taro/demo5.tsx',这与简化后的 demo 结构一致。这个更改确保了文档的准确性。

src/packages/configprovider/demo.taro.tsx (4)

14-15: 翻译键简化合理

翻译键由四个简化为两个('text' 和 'theme'),使翻译结构更加清晰。这种简化与整体的 demo 结构调整保持一致。


19-20: 多语言翻译内容更新

繁体中文和英文的翻译内容已更新,与简体中文保持一致,确保了国际化支持的完整性。

Also applies to: 24-25


33-36: 标题与演示组件顺序调整

标题顺序调整为先展示主题相关内容,再展示国际化内容,使演示逻辑更加清晰。标题使用了更新后的翻译键,保持了一致性。


38-38: RTL 演示更新

RTL 部分现在使用 Demo3 组件,取代了被移除的 Demo5,这与简化后的 demo 结构一致。

src/packages/configprovider/demos/taro/demo2.tsx (2)

2-3: 引入更新符合演示目的

移除了 Button 和 Rate 组件的引入,添加了 TextArea 和英文语言包的引入,使导入内容更加聚焦于国际化演示的目的。


5-22: 国际化演示简化得当

组件从 Demo2 重命名为 Demo,UI 从复杂的 Cell.Group 布局简化为两个 ConfigProvider 包装的 TextArea 组件,一个使用默认语言,一个使用英文。这种简化使演示更加专注于国际化功能,易于理解。

TextArea 设置为 disabled 状态是合理的,因为这样可以防止用户输入干扰演示效果。

src/packages/configprovider/demo.tsx (1)

10-11: 翻译键简化效果很好

将原来的四个翻译键(title1, title2, defaultTheme, customTheme)合并为两个(text, theme)使代码更加简洁和易于维护。

Also applies to: 14-15, 18-19

src/packages/configprovider/demos/h5/demo2.tsx (1)

2-3: 导入组件更新

适当更新了导入的组件,从Rate和Button更改为TextArea,并添加了英文语言包,使演示更加聚焦于国际化功能。

src/packages/configprovider/demos/h5/demo3.tsx (1)

7-16: RTL展示优化

将TextArea组件更换为Cell组件,并添加了更丰富的内容结构(标题、描述和额外文字),使RTL布局效果更加明显。这是一个很好的改进,因为Cell组件有更复杂的布局结构,能更好地展示RTL的效果。

src/packages/configprovider/demos/taro/demo3.tsx (1)

8-21: Taro RTL实现优化

使用Taro特有的组件和样式方法(如pxTransform),实现了与H5版本类似的RTL展示效果。Cell组件的结构使用View和Text进行了适当嵌套,并添加了适合移动端的字体大小和颜色样式,这对于Taro环境下的RTL展示是一个很好的实现。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Target branch 3.x action:review This PR needs more reviews (less than 2 approvals) size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants