Skip to content
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

feat(v14): button adaptation #2737

Open
wants to merge 1 commit into
base: V3.0
Choose a base branch
from

Conversation

oasis-cloud
Copy link
Collaborator

@oasis-cloud oasis-cloud commented Nov 12, 2024

🤔 这个变动的性质是?

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

🔗 相关 Issue

💡 需求背景和解决方案

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

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

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

Summary by CodeRabbit

  • 新功能

    • 添加了按钮的新样式修饰符 &-round,提供不同尺寸的圆角选项。
    • 主按钮背景颜色更新为线性渐变,增强视觉效果。
  • 样式调整

    • 修改了按钮的字体大小和样式,确保各尺寸按钮的一致性。
    • 引入了新的变量以改善文本和图标的对齐。

Copy link

coderabbitai bot commented Nov 12, 2024

Walkthrough

此次更改主要涉及button.scssvariables.scss文件的样式和变量定义。button.scss文件对.nut-button类的样式进行了修改,增加了&-round修饰符及其相关的圆角设置。variables.scss文件则更新了多个按钮字体大小的变量,并将主按钮的背景颜色从单色更改为线性渐变,同时引入了新的变量以设置文本和图标的对齐边距。

Changes

文件路径 更改摘要
src/packages/button/button.scss 修改了.nut-button类的样式,增加了&-round修饰符及其大小相关的圆角设置。调整了display属性为flex,并激活了-webkit-appearance属性。
src/styles/variables.scss 更新了多个按钮字体大小变量,修改了主按钮背景颜色为线性渐变,新增了按钮文本与图标的边距变量。

Possibly related PRs

Suggested labels

size/XL, 3.x

Suggested reviewers

  • xiaoyatong
  • irisSong

🐰 兔子欢跃新样式,
按钮圆角更灵巧。
渐变色彩添魅力,
设计灵活如梦绕。
让我们一起欢庆,
兔子舞动乐无穷! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • 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 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 the 3.x label Nov 12, 2024
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: 2

🧹 Outside diff range and nitpick comments (3)
src/packages/button/button.scss (1)

101-116: 建议为圆角按钮添加使用文档

圆角按钮的样式实现规范合理,建议在组件文档中补充以下内容:

  • 各尺寸对应的圆角大小说明
  • 使用示例代码
  • 与普通按钮的对比展示

需要我帮助生成文档内容吗?

src/styles/variables.scss (2)

291-295: 主按钮背景色优化为渐变效果

将主按钮的背景色从纯色更改为线性渐变:

  • 起始颜色:#ff475d
  • 结束颜色:#ff0f23
  • 渐变角度:90度(水平)

这种渐变效果能让按钮看起来更现代化,提升视觉层次感。建议添加相应的 hover 和 active 状态的渐变效果。


370-373: 新增特大按钮文本图标间距变量

新增了 $button-xlarge-text-icon-margin 变量:

  • 标准化了特大按钮中文本和图标之间的间距
  • 默认值 6px 提供了适当的分隔
  • 使用 CSS 自定义属性便于主题定制

建议考虑为其他尺寸的按钮也添加类似的间距变量,保持一致性。

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 304fd2f and e74ac16.

📒 Files selected for processing (2)
  • src/packages/button/button.scss (6 hunks)
  • src/styles/variables.scss (5 hunks)
🔇 Additional comments (2)
src/packages/button/button.scss (1)

25-25: 样式重置属性设置正确!

添加 -webkit-appearance: none 可以有效消除浏览器默认按钮样式,这是一个标准的跨浏览器兼容性处理方案。

src/styles/variables.scss (1)

232-232: 按钮字体大小调整更加合理

字体大小的调整形成了更合理的层级关系:

  • 默认按钮:12px(小号)
  • 大按钮:14px(基础)
  • 特大按钮:18px(特大)
  • 迷你按钮:11px(特小)

这种层级更符合按钮的视觉层次,提高了用户界面的可读性。

Also applies to: 243-243, 250-250, 276-276

Comment on lines +155 to +156
border-radius: $radius-base;

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

建议统一边框圆角变量的使用

当前代码中边框圆角的变量使用不统一:

  • xlarge 和 large 使用 $radius-base
  • small 和 mini 使用 $radius-s

建议:

  1. 统一使用同一个变量,或
  2. 为不同尺寸定义专门的按钮圆角变量(如 $button-large-radius
  &-xlarge {
    height: $button-xlarge-height;
    padding: $button-xlarge-padding;
    font-size: $button-xlarge-font-size;
    font-weight: $button-large-font-weight;
-   border-radius: $radius-base;
+   border-radius: $button-xlarge-radius;

    // ... other styles
  }

  &-large {
    height: $button-large-height;
    padding: $button-large-padding;
    font-size: $button-large-font-size;
    font-weight: $button-large-font-weight;
-   border-radius: $radius-base;
+   border-radius: $button-large-radius;

    // ... other styles
  }

  &-small {
    height: $button-small-height;
    padding: $button-small-padding;
    font-size: $button-small-font-size;
-   border-radius: $radius-s;
+   border-radius: $button-small-radius;

    // ... other styles
  }

  &-mini {
    height: $button-mini-height;
    padding: $button-mini-padding;
    font-size: $button-mini-font-size;
-   border-radius: $radius-s;
+   border-radius: $button-mini-radius;

    // ... other styles
  }

Also applies to: 180-181, 205-205, 222-222

Comment on lines +157 to +162
.nut-button-text {
margin-left: $button-xlarge-text-icon-margin;
&-right {
margin-right: $button-xlarge-text-icon-margin;
}
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

修复大号按钮图标间距变量使用错误

在 large 尺寸按钮中错误使用了 xlarge 的间距变量:

.nut-button-text {
  margin-left: $button-xlarge-text-icon-margin;  // 错误使用
  &-right {
    margin-right: $button-xlarge-text-icon-margin;  // 错误使用
  }
}

建议修复为:

  &-large {
    // ... other styles
    .nut-button-text {
-     margin-left: $button-xlarge-text-icon-margin;
+     margin-left: $button-large-text-icon-margin;
      &-right {
-       margin-right: $button-xlarge-text-icon-margin;
+       margin-right: $button-large-text-icon-margin;
      }
    }
  }

Also applies to: 182-187

Copy link

codecov bot commented Nov 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.99%. Comparing base (f085b67) to head (e74ac16).
Report is 1 commits behind head on V3.0.

Additional details and impacted files
@@           Coverage Diff           @@
##             V3.0    #2737   +/-   ##
=======================================
  Coverage   83.99%   83.99%           
=======================================
  Files         221      221           
  Lines       17878    17878           
  Branches     2676     2676           
=======================================
  Hits        15016    15016           
  Misses       2857     2857           
  Partials        5        5           

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

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.

1 participant