-
-
Notifications
You must be signed in to change notification settings - Fork 237
refactor: use semantic name #575
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
Conversation
Caution Review failedThe pull request is closed. Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. Walkthrough将内部背景组件及样式从 FloatBg/-float-bg 重命名为 UniqueBody/-unique-body,更新 UniqueProvider 的导入与传参,及相关测试与样式选择器;功能与行为逻辑保持不变。 Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant User as 用户
participant Trigger as Trigger
participant Provider as UniqueProvider
participant Popup as Popup
participant UBody as UniqueBody
User->>Trigger: 交互(打开/移动/关闭)
Trigger->>Provider: 传递状态与定位 (open, align, offsets, popupSize)
Provider->>Popup: 渲染 Popup(包含 motion 等)
Popup->>UBody: 渲染背景层 (open, align, offsets, uniqueBgClassName/uniqueBgStyle)
UBody-->>Popup: 切换 `*-unique-body` 的可见性与状态
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
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. Comment |
Summary of ChangesHello @zombieJ, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on enhancing code readability and maintainability by refactoring a key component's naming. The Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
这次的代码重构主要是为了让命名更符合语义,将 FloatBg
相关命名都改为了 UniqueBody
。整体改动很彻底,包括组件、接口、样式类名和测试都做了相应的调整。我只发现了一个小细节可以优化,即 UniqueBody.tsx
文件中的一个局部变量名没有随之更改,建议一并修改以保持代码的一致性和可读性。
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #575 +/- ##
=======================================
Coverage 95.72% 95.72%
=======================================
Files 17 17
Lines 936 936
Branches 270 274 +4
=======================================
Hits 896 896
Misses 40 40 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@gemini-code-assist done |
Thanks for the update, @zombieJ! I'm glad to hear the changes are complete. Please let me know if you have any further questions or need additional assistance with this pull request. |
There was a problem hiding this 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 (9)
assets/index.less (3)
79-84
: 可选:避免遮挡事件,建议禁用指针事件Unique Body 仅作视觉背景时,建议加上
pointer-events: none
,以杜绝潜在的命中/遮挡问题。&-unique-body { position: absolute; z-index: 0; box-sizing: border-box; border: 1px solid red; background: green; + pointer-events: none;
89-91
: 可选:限定过渡属性提高渲染性能
transition: all
会放大重排/重绘范围。限定到需要的属性更稳。- &-visible { - transition: all 0.1s; - } + &-visible { + transition: opacity 0.1s, transform 0.1s; + }
77-92
: 命名重构一致 — 更新残留FloatBg
引用样式迁移风险低;仓库中发现 3 处残留引用,需更新或确认:
- src/index.tsx:101 — 注释包含
FloatBg
,将其替换为新命名(例如UniqueProvider
/unique-body
)。- src/index.tsx:103 — 注释包含
FloatBg
,同上。- tests/unique.test.tsx:132 — 注释包含
FloatBg
,同上或在测试中说明保留理由。src/UniqueProvider/UniqueBody.tsx (3)
8-22
: Props 扩展合理;注意 prefixCls 必须为已定义的字符串类型上
prefixCls: string
要求调用方保证存在。结合 UniqueProvider 当前实现,若上游未提供prefixCls
可能传入undefined
。建议在调用处兜底(见对 index.tsx 的评论)。请确认 Trigger/Context 层总会注入
prefixCls
,或在调用处提供默认值。
41-41
: 命名遗留:floatBgCls 应同步重命名为 uniqueBodyCls避免语义混淆,便于后续维护。
- const floatBgCls = `${prefixCls}-unique-body`; + const uniqueBodyCls = `${prefixCls}-unique-body`; @@ - leavedClassName={`${floatBgCls}-hidden`} + leavedClassName={`${uniqueBodyCls}-hidden`} @@ - const cls = classNames(floatBgCls, motionClassName, uniqueBgClassName, { - [`${floatBgCls}-visible`]: motionVisible, + const cls = classNames(uniqueBodyCls, motionClassName, uniqueBgClassName, { + [`${uniqueBodyCls}-visible`]: motionVisible,Also applies to: 71-81
84-92
: 可选:无障碍改进,隐藏纯装饰元素Unique Body 为装饰层,建议加上
aria-hidden
与role="presentation"
,避免读屏聚焦。<div className={cls} style={{ ...offsetStyle, ...sizeStyle, ...motionStyle, ...uniqueBgStyle, }} + aria-hidden={true} + role="presentation" />src/UniqueProvider/index.tsx (1)
207-221
: 在传递 prefixCls 时做兜底,防止出现undefined-unique-controlled
类名当上游未显式提供
prefixCls
时,这里会向下游与样式拼接undefined-*
。建议本处兜底为包默认前缀。<UniqueBody - prefixCls={prefixCls} + prefixCls={prefixCls || 'rc-trigger-popup'} isMobile={false} ready={ready} open={open} align={alignInfo}额外建议(非本段变更,供参考):上方 Popup 的
className
中也使用相同兜底,以保持一致性:// 建议在渲染前定义 const safePrefixCls = prefixCls || 'rc-trigger-popup'; // 并用于 className: className={classNames( options.popupClassName, alignedClassName, `${safePrefixCls}-unique-controlled`, )}tests/unique.test.tsx (2)
7-9
: 为自定义全局变量补充类型声明,避免 TS 报错或隐式 any当前直接写入
global.openChangeLog
,在严格 TS 配置下会报错。建议添加声明。// 文件顶部添加 declare global { // 初次比较时 from 可能为 undefined // eslint-disable-next-line no-var var openChangeLog: Array<{ from: boolean | undefined; to: boolean }>; } export {};
101-107
: 更新注释以反映命名变更注释仍提及 “float bg”,建议改为 “unique body” 以避免混淆。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
assets/index.less
(1 hunks)src/UniqueProvider/UniqueBody.tsx
(4 hunks)src/UniqueProvider/index.tsx
(2 hunks)tests/unique.test.tsx
(5 hunks)
🔇 Additional comments (5)
src/UniqueProvider/index.tsx (1)
15-15
: 导入重命名正确与样式与测试中的
UniqueBody
命名一致。tests/unique.test.tsx (4)
10-13
: Mock 方式合理;保持对真实实现的包装包装
OriginalUniqueBody
记录 open 变更,行为与生产一致,便于断言。Also applies to: 27-27
185-192
: 验证 uniqueBgClassName 透传覆盖:用例到位此用例能有效防回归。
194-204
: 验证 uniqueBgStyle 透传覆盖:用例到位断言样式生效,匹配新 API 预期。
206-213
: 无提供 className 时不应产生undefined
:用例到位覆盖负路径,能防止回归。
把结构按照 Semantic 规范调整一下
Summary by CodeRabbit