Skip to content

Conversation

zombieJ
Copy link
Member

@zombieJ zombieJ commented Sep 18, 2025

上游语义化结构支持 arrow 样式配置,底层支持一下

Summary by CodeRabbit

  • 新功能
    • 支持为弹出层箭头设置内联样式;与对齐样式自动合并,用户样式优先生效;未配置时行为不变。
  • 测试
    • 新增用例验证箭头样式应用及与对齐样式的合并逻辑。

Copy link

coderabbitai bot commented Sep 18, 2025

Walkthrough

为 Popup 的 Arrow 增加可选的内联样式支持:在 ArrowTypeOuter 接口中新增 style 属性,并在 Arrow 组件中将该 style 与计算得到的 alignStyle 合并应用到根 div。新增测试覆盖无/有 autoArrow 时样式合并与覆盖行为。

Changes

Cohort / File(s) Change Summary
Arrow 渲染与样式合并
src/Popup/Arrow.tsx
解构并接收 arrow.style,渲染时使用 { ...alignStyle, ...style } 合并样式,允许外部样式覆盖对齐样式。
类型与公共接口
src/interface.ts
ArrowTypeOuter 上新增可选属性 style?: React.CSSProperties
测试用例
tests/arrow.test.jsx
新增两条用例:验证在 autoArrow=falseautoArrow=true 下,箭头样式的应用与与对齐样式的合并。

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant T as Trigger
  participant A as Arrow(组件)
  participant S as Style(alignStyle + style)
  participant D as DOM(.rc-trigger-popup-arrow)

  T->>A: 渲染 Arrow,传入 arrow 对象(含 style?)
  A->>A: 计算 alignStyle(基于对齐/autoArrow)
  A->>S: 合并 { ...alignStyle, ...style }
  A->>D: 以合并后的样式渲染根 div
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

小兔拎箭头,轻点一抹彩,
对齐有规矩,样式随心来。
左边贴一贴,颜色再覆盖,
测试把关严,跳跃不出界。
咔哒一声响,弹窗更可爱。 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed 标题 "feat: arrow config support style" 与变更集中最重要的改动直接相关:为 Arrow/ArrowTypeOuter 添加可选 style 属性并在组件中合并使用,且包含相应测试覆盖,因此标题准确反映了主要功能变更。标题简短且能让审阅者快速理解此次 PR 的目的。虽然英文语法略显笨拙,但不影响其表达的清晰性和相关性。
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-arrow

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

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

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!

此拉取请求旨在增强组件的灵活性,通过引入对箭头样式的直接配置支持,允许开发者更精细地控制箭头的外观。这一改动使得箭头可以根据需求应用自定义的 CSS 样式,并且这些样式会与组件内部的对齐样式无缝融合,从而提升了组件的可定制性和视觉表现力。

Highlights

  • 箭头样式配置: 为 Arrow 组件引入了 style 属性,允许通过 arrow prop 直接配置箭头的 CSS 样式。
  • 样式合并逻辑: 确保自定义的 style 属性能够与现有的 alignStyle 正确合并,从而在保持对齐逻辑的同时,提供灵活的样式定制能力。
  • 类型定义更新: 在 ArrowTypeOuter 接口中添加了 style?: React.CSSProperties; 类型定义,以支持新的样式属性。
  • 新增测试用例: 增加了两个测试用例,分别验证了箭头样式能够独立应用以及与对齐样式正确合并的功能。
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
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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

codecov bot commented Sep 18, 2025

Codecov Report

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

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #573   +/-   ##
=======================================
  Coverage   95.72%   95.72%           
=======================================
  Files          17       17           
  Lines         936      936           
  Branches      274      274           
=======================================
  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.

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

你好,感谢你的贡献。这次的 Pull Request 为 arrow 组件增加了 style 配置,允许用户自定义箭头样式,这是一个很棒的功能增强。代码实现清晰,通过扩展 ArrowTypeOuter 接口,在 Arrow 组件中合并样式,并且添加了相应的单元测试来验证功能的正确性,包括了样式覆盖和合并的场景。整体来看,代码质量很高,没有发现明显问题。

@zombieJ zombieJ merged commit 2751565 into master Sep 18, 2025
9 of 10 checks passed
@zombieJ zombieJ deleted the fix-arrow branch September 18, 2025 07:12
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/interface.ts (1)

91-95: style 补充 JSDoc,并在文档/变更记录中声明该 API

建议明确说明合并与优先级,避免误用覆盖定位属性;同时这是对外 API 增补,建议在 CHANGELOG/README 标注为 minor 版本变更。

 export interface ArrowTypeOuter {
-  style?: React.CSSProperties;
+  /** Inline 样式,最终会与对齐样式合并(用户样式后置覆盖)。
+   *  建议仅设置展示类属性(如 color/background),避免覆盖定位相关属性(position/left/top/right/bottom)。 */
+  style?: React.CSSProperties;
   className?: string;
   content?: React.ReactNode;
 }
src/Popup/Arrow.tsx (1)

61-62: 防止外部样式覆盖 position,保证箭头绝对定位

当前合并顺序允许 style.position 改写 alignStyle.position,可能导致错位。建议在合并末尾强制 position: 'absolute'

-      style={{ ...alignStyle, ...style }}
+      // 防止外部 style 覆盖定位方式,保持箭头正确对齐
+      style={{ ...alignStyle, ...style, position: 'absolute' }}
tests/arrow.test.jsx (1)

221-250: 补充断言:确保定位不被外部样式改写

为防回归,建议额外断言 position: absolute 存在(与实现侧的“强制 absolute”建议一致)。

       const arrowDom = document.querySelector('.rc-trigger-popup-arrow');
       // Should have both align style (left: 0) and custom style
       expect(arrowDom).toHaveStyle({
         left: 0,
         color: 'red',
         backgroundColor: 'blue',
       });
+      expect(arrowDom).toHaveStyle({ position: 'absolute' });
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bac9320 and 8d319fb.

📒 Files selected for processing (3)
  • src/Popup/Arrow.tsx (2 hunks)
  • src/interface.ts (1 hunks)
  • tests/arrow.test.jsx (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tests/arrow.test.jsx (1)
tests/util.tsx (1)
  • awaitFakeTimer (97-104)
🔇 Additional comments (2)
src/Popup/Arrow.tsx (1)

15-16: 解构新增 style 字段,合并思路清晰,LGTM

tests/arrow.test.jsx (1)

192-219: 覆盖“非 autoArrow”场景的样式注入,LGTM

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