Skip to content

Conversation

irisSong
Copy link
Collaborator

@irisSong irisSong commented Mar 24, 2025

🤔 这个变动的性质是?

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

🔗 相关 Issue

💡 需求背景和解决方案

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

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

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

Summary by CodeRabbit

  • 新功能

    • 为徽章组件新增了“禁用”状态,可通过设置相应属性展示禁用外观。
  • 文档更新

    • 更新了组件文档和演示示例,新增禁用状态的使用说明及示例演示。
    • 调整了迁移指南,反映了徽章组件属性的变更。

Copy link

coderabbitai bot commented Mar 24, 2025

Walkthrough

该PR在Badge组件中引入了全新的disabled状态支持。主要改动包括:向SCSS中添加禁用样式类,并在React组件中新增disabled属性(默认值为false),以便根据状态条件渲染不同的CSS样式。同时,文档和示例也做了相应更新,新增演示禁用状态的示例和相关属性说明。此外,还在变量文件和类型声明中同步添加了对禁用状态的支持。

Changes

文件 更改说明
src/packages/badge/badge.scss 新增 &-disabled 修饰类,应用 $badge-background-disabled-color 背景色。
src/packages/badge/badge.taro.tsx, src/packages/badge/badge.tsx, src/types/spec/badge/base.ts 在Badge组件中添加 disabled 属性(默认false)及其在类型定义中的声明,并基于该属性条件渲染禁用样式。
src/packages/badge/doc.en-US.md, src/packages/badge/doc.md, src/packages/badge/doc.taro.md, src/packages/badge/doc.zh-TW.md 更新文档:新增“Disabled/禁用”章节,添加 disabled 属性说明和CSS变量 --nutui-badge-background-disabled-color
src/sites/.../migrate-from-v2.md (react和taro) 更新迁移文档:新增 disabled 属性,同时移除 color 属性,改为依赖CSS变量配置背景色。
src/styles/variables-jmapp.scss, src/styles/variables-jrkf.scss, src/styles/variables.scss 新增变量 $badge-background-disabled-color,使用CSS变量 --nutui-badge-background-disabled-color 和默认值 $color-text-disabled 定义。
src/packages/badge/demo.taro.tsx, src/packages/badge/demo.tsx, src/packages/badge/demos/h5/demo9.tsx, src/packages/badge/demos/taro/demo9.tsx 新增Demo组件Demo9及相应的翻译条目,展示Badge在禁用状态下的表现。

Sequence Diagram(s)

sequenceDiagram
    participant User as 用户
    participant Badge as Badge组件
    participant SCSS as 样式文件

    User->>Badge: 提供props(可能包含disabled属性)
    Badge->>Badge: 解构并检查disabled属性
    alt disabled为true
        Badge->>SCSS: 添加 "-disabled" CSS类
        SCSS-->>Badge: 返回禁用样式
    else
        Badge->>Badge: 使用常规样式
    end
    Badge-->>User: 渲染最终Badge组件
Loading

Possibly related PRs

Suggested reviewers

  • xiaoyatong
  • oasis-cloud

Poem

小兔子跳跃在代码的林间,
disabled属性闪耀微光点点。
样式与逻辑齐舞翩翩,
文档和示例铺满温暖边。
愿代码世界永远轻松欢畅 🐰🎉!

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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 Mar 24, 2025
Copy link

codecov bot commented Mar 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.96%. Comparing base (9a903a0) to head (bfc118d).
Report is 6 commits behind head on feat_v3.x.

Additional details and impacted files
@@            Coverage Diff             @@
##           feat_v3.x    #3118   +/-   ##
==========================================
  Coverage      86.95%   86.96%           
==========================================
  Files            280      280           
  Lines          18456    18459    +3     
  Branches        2786     2786           
==========================================
+ Hits           16049    16052    +3     
  Misses          2402     2402           
  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.

Copy link
Collaborator

@xiaoyatong xiaoyatong left a comment

Choose a reason for hiding this comment

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

1、建议保留自定义的demo
2、新增一个 disabled 的 demo,可直接放在 默认用法 中。

@pull-request-size pull-request-size bot added size/L and removed size/M labels Mar 25, 2025
@irisSong
Copy link
Collaborator Author

1、建议保留自定义的demo 2、新增一个 disabled 的 demo,可直接放在 默认用法 中。

已修改

@irisSong irisSong requested a review from xiaoyatong March 25, 2025 04:56
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 (3)
src/packages/badge/demos/taro/demo9.tsx (1)

1-20: 禁用模式示例实现完整

示例代码展示了三种不同类型Badge的禁用状态(点状、数字和文本内容),覆盖了常见使用场景,便于用户理解禁用效果。代码结构简洁清晰,与其他demo文件风格保持一致。

建议为示例代码添加注释,帮助用户更好地理解不同类型的禁用状态。例如:

 <Cell style={{ justifyContent: 'space-around' }}>
+  {/* 点状徽标禁用状态 */}
   <Badge dot disabled>
     <Avatar icon={<User />} shape="square" />
   </Badge>
+  {/* 数字徽标禁用状态 */}
   <Badge value={8} disabled>
     <Avatar icon={<User />} shape="square" />
   </Badge>
+  {/* 文本徽标禁用状态 */}
   <Badge value="内容" disabled>
     <Avatar icon={<User />} shape="square" />
   </Badge>
 </Cell>
src/packages/badge/doc.en-US.md (1)

111-111: 英文CSS变量说明存在语法错误

英文描述"badge disables background color"存在语法问题,应修改为"badge disabled background color",以保持语法正确性。

-| \--nutui-badge-background-disabled-color | badge disables background color | `$color-text-disabled` |
+| \--nutui-badge-background-disabled-color | badge disabled background color | `$color-text-disabled` |
src/packages/badge/demo.taro.tsx (1)

60-61: 禁用模式演示部分添加合理

您已成功添加禁用模式的演示部分,并使用了翻译后的标题。不过,考虑一下禁用模式在演示顺序中的位置是否合适。通常,基本功能(如默认用法、最大值)应该排在前面,而禁用状态等变体可能更适合放在自定义功能之后。

建议考虑将禁用模式的演示放在更靠后的位置,比如在所有自定义功能之后,这样可能更符合用户对功能展示的直觉期望。

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between cbb388c and bfc118d.

📒 Files selected for processing (8)
  • src/packages/badge/demo.taro.tsx (5 hunks)
  • src/packages/badge/demo.tsx (5 hunks)
  • src/packages/badge/demos/h5/demo9.tsx (1 hunks)
  • src/packages/badge/demos/taro/demo9.tsx (1 hunks)
  • src/packages/badge/doc.en-US.md (3 hunks)
  • src/packages/badge/doc.md (3 hunks)
  • src/packages/badge/doc.taro.md (3 hunks)
  • src/packages/badge/doc.zh-TW.md (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/packages/badge/demos/h5/demo9.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/packages/badge/doc.zh-TW.md
  • src/packages/badge/doc.md
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test
🔇 Additional comments (10)
src/packages/badge/demo.tsx (3)

11-11: 新增Demo9引入符合代码风格

新增的导入语句与现有的导入结构保持一致,遵循了项目的导入模式。


24-24: 国际化文本添加合理

在三种语言环境(简体中文、繁体中文和英文)中都添加了"禁用"/"Disabled"的翻译,确保了多语言支持的完整性。

Also applies to: 35-35, 46-46


55-56: 禁用模式演示位置放置得当

将禁用模式的演示放在基础用法之后、最大值之前,符合功能展示的逻辑顺序,使用户能够循序渐进地了解组件功能。

src/packages/badge/doc.taro.md (3)

21-28: 文档中添加禁用章节合理

在文档中添加禁用章节,并提供相应的演示代码示例,使开发者能够清晰了解如何使用禁用功能。章节放置在基础用法之后,符合文档的组织结构。


98-98: Props表格新增disabled属性定义清晰

在Props表格中添加了disabled属性的说明,包括类型和默认值,使API文档更加完整。


110-110: 新增CSS变量说明完整

添加了禁用状态的背景色CSS变量(--nutui-badge-background-disabled-color)及其默认值,便于开发者进行主题定制,文档内容全面。

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

21-28: 英文文档禁用章节添加合理

英文文档中新增的Disabled章节与中文文档保持一致,保证了不同语言文档的同步性。


99-99: 英文Props表格新增disabled属性描述准确

英文文档中对disabled属性的描述简洁明了,与中文文档内容对应,方便非中文用户理解使用。

src/packages/badge/demo.taro.tsx (2)

14-14: 正确引入了新的演示组件

您成功地引入了演示禁用状态的Demo9组件,这符合现有的导入模式。


27-27: 多语言支持完善

您已为"禁用"功能添加了所有必要的语言翻译(简体中文、繁体中文和英文),确保了国际化支持的完整性。

Also applies to: 38-38, 49-49

@xiaoyatong xiaoyatong merged commit 2e3c490 into jdf2e:feat_v3.x Mar 26, 2025
8 checks passed
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.

3 participants