Skip to content

Conversation

Arktomson
Copy link

@Arktomson Arktomson commented Sep 25, 2025

Summary by CodeRabbit

  • 新功能

    • 引导浮层的关闭按钮现支持自定义类名与内联样式,便于品牌化与主题定制,兼容现有前缀类。
    • 扩展可用样式语义名,新增 “close”(保留 “mask”),可精细化定制关闭元素外观,向后兼容运行逻辑。
  • 测试

    • 增加关闭按钮相关测试,验证类名、样式、可见性与无障碍属性在多步场景下的行为。

Copy link

vercel bot commented Sep 25, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
tour Ready Ready Preview Comment Oct 1, 2025 2:00am

Copy link

coderabbitai bot commented Sep 25, 2025

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

在 DefaultPanel 的关闭按钮上新增对 tourClassNames?.closestyles?.close 的应用;在接口中为 SemanticName 类型新增成员 'close';测试扩展以覆盖关闭按钮的类名、内联样式与可见性断言。无运行时控制流变更。

Changes

Cohort / File(s) Summary of Changes
关闭按钮样式钩子扩展
src/TourStep/DefaultPanel.tsx
关闭按钮由仅使用静态类名 ${prefixCls}-close 改为合成 className(包含可选的 tourClassNames?.close)并支持内联样式 styles?.close
类型:语义名扩展
src/interface.ts
扩展公共类型 SemanticName,新增成员 'close'(保留 'mask'),以允许为关闭按钮提供语义化 className/style。无运行时逻辑变更。
测试:关闭 UI 覆盖
tests/index.test.tsx
增加测试以验证关闭元素的存在、类名与样式传播(包含全局与 per-step 的 closeIcon 行为),并添加对应的查询与断言。仅测试扩展,无业务逻辑更改。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • zombieJ

Poem

小兔蹦来看面板,
关钮添衣心欢然,
class 与 style 轻相伴,
语义 'close' 写短笺,
咔嚓一按路更宽。 🐇🎉

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 这条标题明确指出本次 PR 的主要变更:为 “close” 元素适配语义化命名和样式处理,符合添加新功能(feat)的意图,且与实际代码改动高度契合。
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Summary of Changes

Hello @Arktomson, 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 enhances the customization options for the close button within tour steps. It introduces the ability to apply custom CSS classes and inline styles directly to the close button, and formally recognizes 'close' as a semantic element. This change provides developers with more control over the appearance and behavior of the tour step's close functionality.

Highlights

  • Close Button Customization: The close button in the DefaultPanel component now supports custom class names and inline styles, allowing for greater visual flexibility.
  • Semantic Recognition: The SemanticName type has been extended to include 'close', enabling semantic identification and potential targeting of the close button within the tour step.
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

@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

This pull request correctly adds support for semantic styling of the close button, allowing className and style customization. The implementation is consistent with existing patterns in the codebase. My main feedback is to add test coverage for this new feature to ensure its correctness and prevent future regressions.

Comment on lines +44 to +45
className={classNames(`${prefixCls}-close`, tourClassNames?.close)}
style={styles?.close}

Choose a reason for hiding this comment

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

medium

While the implementation for applying custom className and style to the close button is correct, this pull request is missing corresponding tests to verify the new functionality. Please add a test case to ensure that tourClassNames.close and styles.close are applied as expected. You could extend the existing 'support custom styles' test in tests/index.test.tsx for this.

Copy link

codecov bot commented Sep 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.07%. Comparing base (ecd28bc) to head (57c5573).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #83   +/-   ##
=======================================
  Coverage   99.07%   99.07%           
=======================================
  Files          10       10           
  Lines         217      217           
  Branches       96       98    +2     
=======================================
  Hits          215      215           
  Misses          2        2           

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

aria-label="Close"
{...ariaProps}
className={`${prefixCls}-close`}
className={classNames(`${prefixCls}-close`, tourClassNames?.close)}

Choose a reason for hiding this comment

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

测试用例需要补一下

@Arktomson
Copy link
Author

Arktomson commented Sep 27, 2025 via email

@li-jia-nan
Copy link
Member

同步一下上游分支

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 57c5573 and 5ab8cb8.

📒 Files selected for processing (1)
  • src/TourStep/DefaultPanel.tsx (1 hunks)

Comment on lines +43 to +44
className={classNames(`${prefixCls}-close`, tourClassNames?.close)}
style={styles?.close}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

验证测试覆盖是否已补充。

过往评审中 coding-ice 和 gemini-code-assist[bot] 都提到需要补充测试用例来验证 tourClassNames.closestyles.close 的应用。虽然 AI 摘要提到测试已扩展,但建议确认 tests/index.test.tsx 中是否包含了针对关闭按钮的类名和样式的断言。

运行以下脚本验证测试覆盖:


🏁 Script executed:

#!/bin/bash
# 描述:验证 tests/index.test.tsx 中是否包含对 close 按钮样式的测试

# 搜索测试文件中与 close 相关的断言
rg -n -A 5 -B 5 "tourClassNames.*close|styles.*close|\.close" tests/index.test.tsx

Length of output: 361


补充关闭按钮类名和样式测试
在 tests/index.test.tsx 中缺少对 DefaultPanel 关闭按钮 className={classNames(..., tourClassNames?.close)}style={styles?.close} 的断言,请添加测试以验证 tourClassNames.closestyles.close 的正确应用。

🤖 Prompt for AI Agents
In src/TourStep/DefaultPanel.tsx around lines 43-44, the close button receives
className={classNames(`${prefixCls}-close`, tourClassNames?.close)} and
style={styles?.close} but tests don't assert these; update tests/index.test.tsx
to render DefaultPanel with explicit tourClassNames={{ close: 'my-close' }} and
styles={{ close: { color: 'red' } }} (or similar), locate the close button (by
role/button, aria-label, or the generated class), and add assertions that the
element's classList contains the provided tourClassNames.close and that its
style matches the provided styles.close (use toContain/toHaveClass for class and
toHaveStyle or equivalent for inline styles).

aria-label="Close"
{...ariaProps}
className={`${prefixCls}-close`}
className={classNames(`${prefixCls}-close`, tourClassNames?.close)}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

关键错误:使用了未定义的 classNames 函数。

第 43 行使用了 classNames 函数,但文件顶部导入的是 clsx(第 3 行)。这会导致运行时错误 ReferenceError: classNames is not defined。文件中其他所有地方都正确使用了 clsx(第 32、34、50、54、61、70、86 行)。

应用此 diff 修复:

-            className={classNames(`${prefixCls}-close`, tourClassNames?.close)}
+            className={clsx(`${prefixCls}-close`, tourClassNames?.close)}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
className={classNames(`${prefixCls}-close`, tourClassNames?.close)}
className={clsx(`${prefixCls}-close`, tourClassNames?.close)}
🤖 Prompt for AI Agents
In src/TourStep/DefaultPanel.tsx around line 43, the code calls an undefined
classNames function (causing ReferenceError) while the module imports clsx;
replace the usage of classNames with clsx at line 43 so it matches the rest of
the file (or alternatively add an import that exposes classNames), ensuring the
close button className uses clsx(`${prefixCls}-close`, tourClassNames?.close).

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.

3 participants