Skip to content

Conversation

zombieJ
Copy link
Member

@zombieJ zombieJ commented Sep 19, 2025

把结构按照 Semantic 规范调整一下

Summary by CodeRabbit

  • 新功能
    • 无用户可见的新功能变更。
  • 重构
    • 将浮层背景组件及导出类型由“FloatBg”重命名为“UniqueBody”,统一命名不改变行为或公开接口。
  • 样式
    • 更新样式选择器从 -float-bg 到 -unique-body,视觉与交互保持不变;自定义类名与样式能力延续。
  • 测试
    • 调整单元测试与选择器以匹配新命名,继续验证自定义样式/类名及仅保留单一可见浮层等行为稳定。

Copy link

coderabbitai bot commented Sep 19, 2025

Caution

Review failed

The pull request is closed.

Note

Other AI code review bot(s) detected

CodeRabbit 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

Cohort / File(s) Summary
样式重命名
assets/index.less
选择器从 &-float-bg 改为 &-unique-body,注释从 "Float BG" 改为 "Unique Body";内部样式与 &-hidden/&-visible 状态不变。
组件重命名与导出
src/UniqueProvider/UniqueBody.tsx
新增/重命名组件 UniqueBody(原 FloatBg):接口 FloatBgPropsUniqueBodyProps,组件名与默认导出更新;基类名由 -float-bg 改为 -unique-body,内部变量名(如 floatBgClsbodyCls)更新,其余逻辑保持一致。
Provider 集成更新
src/UniqueProvider/index.tsx
将 UniqueProvider 内部背景子组件由 FloatBg 替换为 UniqueBody,并向其传入扩展 props(如 open, align, offsetR/offsetB/offsetX/offsetY, popupSize, motion, uniqueBgClassName, uniqueBgStyle);外部 API 未改动。
测试同步
tests/unique.test.tsx
测试与模拟从 FloatBgUniqueBody;模拟路径与 DOM 选择器更新为 .rc-trigger-popup-unique-body;断言和测试名相应改为 UniqueBody,验证 className/style 与可见性逻辑保持一致。

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` 的可见性与状态
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

我是小兔敲代码,换了新名开新局,
float 变 unique,舞台依旧不孤独。
样式改了名,行为仍旧默契足,
测试点点头,组件安然无惊扰。
嘻嘻,跳跳,提交里藏着小兔的祝福 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed 标题 "refactor: use semantic name" 简洁且与变更集的主要内容相符:该 PR 将 FloatBg / -float-bg 重命名为 UniqueBody / -unique-body,并在样式、组件与测试中做了对应更新,因此标题准确反映了最重要的改动。标题为单句、明确且不含多余信息,便于同事扫历史时快速理解主要意图。
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2f7fc2b and b542467.

📒 Files selected for processing (1)
  • src/UniqueProvider/UniqueBody.tsx (5 hunks)

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

Summary of Changes

Hello @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 FloatBg component, its associated interface, and styling classes have been systematically renamed to UniqueBody to better convey its purpose and align with semantic naming principles. This change propagates through the codebase, including imports, component instantiation, and unit tests, ensuring consistency and clarity.

Highlights

  • Component and File Renaming: The FloatBg component and its corresponding file src/UniqueProvider/FloatBg.tsx have been renamed to UniqueBody and src/UniqueProvider/UniqueBody.tsx respectively, to improve semantic clarity.
  • Interface and Class Name Updates: The FloatBgProps interface was updated to UniqueBodyProps, and the associated Less CSS class &-float-bg was renamed to &-unique-body.
  • Codebase-Wide References Adjusted: All imports, component usages, and test assertions across the codebase have been updated to reflect the new UniqueBody and unique-body naming conventions.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 文件中的一个局部变量名没有随之更改,建议一并修改以保持代码的一致性和可读性。

Copy link

codecov bot commented Sep 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.72%. Comparing base (9021a70) to head (b542467).
⚠️ Report is 2 commits behind head on master.

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

@zombieJ
Copy link
Member Author

zombieJ commented Sep 19, 2025

@gemini-code-assist done

Copy link
Contributor

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.

@zombieJ zombieJ merged commit c029464 into master Sep 19, 2025
9 checks passed
@zombieJ zombieJ deleted the rename branch September 19, 2025 08:01
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 (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-hiddenrole="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

📥 Commits

Reviewing files that changed from the base of the PR and between 9021a70 and 2f7fc2b.

📒 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:用例到位

覆盖负路径,能防止回归。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant