Skip to content

Conversation

@Adamlyu-hub
Copy link

@Adamlyu-hub Adamlyu-hub commented Jul 18, 2025

1.button组件:
(1)优化鸿蒙环境button组件样式问题,达到官网效果。
处理前:
image
处理后:
image

2.dialog组件:
(1)优化鸿蒙环境dialog组件样式问题,达到官网效果。
处理前:
image
处理后:
image
(2)处理closeIcon不显示问题。
处理后:
image

🤔 这个变动的性质是?

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

🔗 相关 Issue

💡 需求背景和解决方案

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

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

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

Summary by CodeRabbit

  • 样式
    • 按钮组件和弹窗组件新增“harmony dynamic”模式下的样式,区分不同模式下的尺寸、颜色、边框、圆角等视觉表现。
    • 按钮组件在“harmony dynamic”模式下采用固定高度、字体大小、颜色等,非动态模式则继续使用变量。
    • 弹窗组件在“harmony dynamic”模式下调整了最大高度、宽度、边框圆角、背景色和内边距等,弹窗外层和关闭按钮样式也根据模式区分。
  • 功能优化
    • 弹窗关闭按钮位置调整,现位于内容底部区域,提升用户体验。

@coderabbitai
Copy link

coderabbitai bot commented Jul 18, 2025

Walkthrough

本次更新为 Button 和 Dialog 组件的 SCSS 样式引入了基于 harmony dynamic 标志的条件样式分支。Button 和 Dialog 的尺寸、排版、颜色、背景、边框、过渡等样式属性在动态与非动态模式下分别应用不同的样式。同时,Dialog 组件的关闭按钮在 JSX 结构中的位置发生了调整。

Changes

文件/分组 变更摘要
src/packages/button/button.scss .nut-button 按钮样式引入 harmony dynamic 条件分支,分别设置宽高、字体、颜色、背景等属性。.nut-button-wrap 的宽度也根据条件分支调整。
src/packages/dialog/dialog.scss .nut-dialog 及其子元素引入 harmony dynamic 条件样式,调整布局、尺寸、圆角、背景等属性。
src/packages/dialog/content.tsx close 关闭按钮 JSX 渲染位置由外层容器移至内层容器 footer 后。

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Button
    participant Dialog

    User->>Button: 触发渲染
    Button-->>Button: 根据 harmony dynamic 标志应用不同样式

    User->>Dialog: 打开对话框
    Dialog-->>Dialog: 根据 harmony dynamic 标志应用不同样式
    Dialog-->>Dialog: 渲染 close 按钮于新位置
Loading

Possibly related PRs

  • #2790:同样针对 Dialog 组件的 harmony dynamic 条件样式适配,涉及相同 SCSS 文件和样式规则。
  • #2900:聚焦于 Dialog v15 样式和交互适配,涉及 CSS 变量和样式细化,与本 PR 的样式调整方向一致。
  • #2737:涉及 .nut-button 样式调整,与本 PR 针对 Button 组件的条件样式变更相关。

Suggested reviewers

  • oasis-cloud

Poem

🐰
Harmony 风起样式新,
按钮对话皆分身。
动态静态各有道,
变量切换巧分明。
兔子挥笔庆更新,
代码世界更缤纷!

✨ 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 3.x Target branch 3.x action:review This PR needs more reviews (less than 2 approvals) labels Jul 18, 2025
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: 1

🧹 Nitpick comments (3)
src/packages/button/button.scss (1)

19-37: 条件编译块产生大量重复属性,后期维护成本高
/* #ifndef harmony dynamic *//* #ifdef harmony dynamic */ 两块中,height / font-size / font-weight / transition / color / background / border-width 等属性被硬编码复制。后续若需调整按钮规格,必须在两个分支里同时修改,容易遗漏。建议抽取公共属性或通过 SCSS 变量映射,减少重复。

src/packages/dialog/dialog.scss (2)

9-18: box-sizing 在文件顶部与动态分支内重复声明
第 9 行和 26 行均写了 box-sizing: border-box;,编译后虽无功能性冲突,但冗余会混淆阅读。


86-97: 关闭按钮 bottom: -150px 魔法数字风险
固定 -150 px 在不同弹窗高度或缩放场景下可能脱离可视区域,无法点击。考虑使用 Flex / 绝对定位相对于父高度的百分比或 CSS 变量。

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 77de439 and 27dfce5.

📒 Files selected for processing (3)
  • src/packages/button/button.scss (2 hunks)
  • src/packages/dialog/content.tsx (1 hunks)
  • src/packages/dialog/dialog.scss (3 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: oasis-cloud
PR: jdf2e/nutui-react#2540
File: src/packages/trendarrow/trendarrow.taro.tsx:29-30
Timestamp: 2024-11-06T02:16:07.069Z
Learning: 在`TrendArrow`组件(`src/packages/trendarrow/trendarrow.taro.tsx`)中,CSS变量在鸿蒙系统(Harmony OS)中可能未被完全支持,导致兼容性问题。因此,使用硬编码的十六进制颜色值可以确保在鸿蒙系统上的正确显示。
Learnt from: oasis-cloud
PR: jdf2e/nutui-react#2700
File: src/packages/animatingnumbers/animatingnumbers.harmony.css:25-32
Timestamp: 2024-11-06T05:56:06.800Z
Learning: 在优化 NutUI React 动画性能时,添加 `will-change` 属性可能会对布局产生影响,需要谨慎使用。
src/packages/button/button.scss (2)
Learnt from: oasis-cloud
PR: jdf2e/nutui-react#2700
File: src/packages/animatingnumbers/animatingnumbers.harmony.css:25-32
Timestamp: 2024-11-06T05:56:06.800Z
Learning: 在优化 NutUI React 动画性能时,添加 `will-change` 属性可能会对布局产生影响,需要谨慎使用。
Learnt from: oasis-cloud
PR: jdf2e/nutui-react#2540
File: src/packages/trendarrow/trendarrow.taro.tsx:29-30
Timestamp: 2024-11-06T02:16:07.069Z
Learning: 在`TrendArrow`组件(`src/packages/trendarrow/trendarrow.taro.tsx`)中,CSS变量在鸿蒙系统(Harmony OS)中可能未被完全支持,导致兼容性问题。因此,使用硬编码的十六进制颜色值可以确保在鸿蒙系统上的正确显示。
🧬 Code Graph Analysis (1)
src/packages/dialog/content.tsx (1)
src/packages/dialog/dialog.taro.tsx (1)
  • close (267-271)
🔇 Additional comments (3)
src/packages/button/button.scss (1)

80-83: 动态模式缺少 width: 100% 可能导致文字被裁剪
width: 100% 仅在非 dynamic 分支里声明。Harmony dynamic 下若父元素宽度不足,.nut-button-wrap 可能无法撑满导致内容折行或截断,请确认 UI 需求。

src/packages/dialog/dialog.scss (1)

40-53: 外层 .nut-dialog-outer 动态分支覆盖了原有 Overlay 语义
将宽高设为 100% 并加深背景 rgba(0,0,0,0.8),可能与 Overlay 组件的遮罩叠加,造成双层遮罩 & 不可滚动。请确认 Overlay 已被移除或相应透明度调整。

src/packages/dialog/content.tsx (1)

62-71: 关闭图标移入内部后事件冒泡需要确认
onClick 绑定在 .nut-dialog-outerclose 现在位于内部 .nut-dialog。若关闭图标点击事件依赖阻止冒泡以避免触发外层 onClick,请确认 close 组件内部是否正确 stopPropagation,否则可能导致点击关闭按钮时同时触发外层回调。

Comment on lines +19 to +28
/* #ifdef harmony dynamic*/
background-color: #ffffff;
width: 80%;
border-radius: 24px;
min-width: 240px;
min-height: 248px;
padding: 48px;
box-sizing: border-box;
position: relative;
/* #endif */
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

动态分支尺寸硬编码,缺乏响应式适配
width: 80%min-width: 240pxmin-height: 248pxpadding: 48px 等均为固定像素。不同 DP 值设备或折叠屏上可能出现 UI 失真,建议改用设计系统里的尺寸变量或 vw / rem

🤖 Prompt for AI Agents
In src/packages/dialog/dialog.scss between lines 19 and 28, the fixed pixel
values for width, min-width, min-height, and padding cause poor responsiveness
on different devices. Replace these hardcoded pixel sizes with relative units
like vw or rem, or use size variables from the design system to ensure the
dialog scales properly across various screen densities and foldable devices.

@codecov
Copy link

codecov bot commented Jul 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.14%. Comparing base (77de439) to head (27dfce5).
⚠️ Report is 22 commits behind head on feat_v3.x.

Additional details and impacted files
@@            Coverage Diff             @@
##           feat_v3.x    #3309   +/-   ##
==========================================
  Coverage      88.13%   88.14%           
==========================================
  Files            290      290           
  Lines          19110    19110           
  Branches        2959     2960    +1     
==========================================
+ Hits           16843    16844    +1     
+ Misses          2262     2261    -1     
  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.

background: $button-default-background-color;
border-width: $button-border-width;
/* #endif */
/* #ifdef harmony dynamic*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个不能写死,可以通过编译实现。

Copy link
Collaborator

Choose a reason for hiding this comment

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

参考鸿蒙

@xiaoyatong
Copy link
Collaborator

cpp 版本中,dialog已适配,本pr关闭。

@xiaoyatong xiaoyatong closed this Sep 22, 2025
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/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants