Skip to content

Conversation

@json-q
Copy link

@json-q json-q commented Feb 1, 2026

Summary by CodeRabbit

发布说明

  • 新功能

    • Tab 组件支持为图标单独配置样式:使用结构化的 classNames 和 styles(分别含 root 与 icon 子项)来更灵活地定制根元素与图标外观。
    • 类型扩展:语义名称新增 'icon',便于对图标进行语义化标识。
  • 测试

    • 新增对标签页图标样式与类名的测试覆盖。

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Feb 1, 2026

@json-q is attempting to deploy a commit to the React Component Team on Vercel.

A member of the Team first needs to authorize it.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @json-q, 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 introduces a significant enhancement to the Tabs component's customization capabilities. By refactoring how styling and class names are applied, it now provides developers with fine-grained control over the appearance of tab icons. This change improves the component's flexibility, allowing for more precise design adjustments and better integration into various UI themes without affecting other elements.

Highlights

  • Refactored Styling Props: The TabNodeProps interface has been refactored to replace direct style and className props with nested styles and classNames objects. These new objects allow for more granular control, specifically targeting root and icon elements within a tab.
  • Icon Element Customization: The icon element within tabs can now receive custom classNames and styles directly, enabling more flexible styling and thematic integration.
  • Semantic Name Extension: The SemanticName type has been extended to include 'icon', providing a semantic identifier for icon elements in the Tabs component.
  • Updated Prop Propagation: The TabNavList component has been updated to correctly pass the new styles and classNames objects down to the TabNode component, ensuring the custom icon styling is applied.
  • Comprehensive Test Coverage: New test cases have been added to verify that custom class names and styles are correctly applied to the tab icon element, ensuring the new functionality works as expected.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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.

@coderabbitai
Copy link

coderabbitai bot commented Feb 1, 2026

Walkthrough

将 TabNode 的样式 API 从平铺的 style/className 改为结构化的 styles/classNames(包含 rooticon),TabNavList 相应改为传递嵌套样式,Tabs 的语义类型新增 'icon',并增加测试以验证图标样式应用。

Changes

Cohort / File(s) Summary
TabNode 组件重构
src/TabNavList/TabNode.tsx
移除 style/className props,新增 styles?: {root?, icon?}classNames?: {root?, icon?}。渲染时将根节点与图标节点分别使用 styles.root/classNames.rootstyles.icon/classNames.icon
TabNavList 适配层
src/TabNavList/index.tsx
调用处从传递单一 style/className 切换为传递 { styles: { root, icon }, classNames: { root, icon } },并将首项的条件 margin 放入 styles.root
类型扩展
src/Tabs.tsx
将导出类型 SemanticName 扩展,新增 'icon' 成员以支持图标语义命名。
测试更新
tests/index.test.tsx
新增/更新测试项以包含 tab 的 icon 属性与相应的 className 与 内联样式 断言,确保图标元素应用了新的 classNames/styles。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 分钟

Possibly related PRs

🐰 我在代码菜地里跳跃,轻敲键盘声响闪耀,
root 与 icon 分道扬镳,样式整齐像胡萝卜排,
小小改动换新颜,标签图标欢喜摇摆,
嵌套着爱与CSS,奔向更清晰的明天。

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题清晰地总结了此PR的主要变更:为语义化目的添加图标元素属性支持。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • 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
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

The pull request successfully introduces semantic styling and class name props for the icon element within the tabs, aligning with the feature description. The changes in TabNode.tsx and index.tsx correctly propagate these new styling options, and the test cases in index.test.tsx validate the functionality. However, there are a couple of places where optional properties are accessed directly, which could lead to runtime errors.

[`${tabPrefix}-focus`]: focus,
})}
style={style}
style={styles.root}
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The styles prop is defined as optional in TabNodeProps, but styles.root is accessed directly here. This could lead to a runtime error if styles is undefined. Please use optional chaining (styles?.root) to safely access the property.

Suggested change
style={styles.root}
style={styles?.root}

)}
{icon && <span className={`${tabPrefix}-icon`}>{icon}</span>}
{icon && (
<span className={clsx(`${tabPrefix}-icon`, classNames?.icon)} style={styles.icon}>
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Similar to the root style, the styles prop is optional, but styles.icon is accessed directly. This could cause a runtime error if styles is undefined. Please use optional chaining (styles?.icon).

Suggested change
<span className={clsx(`${tabPrefix}-icon`, classNames?.icon)} style={styles.icon}>
<span className={clsx(`${tabPrefix}-icon`, classNames?.icon)} style={styles?.icon}>

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

🤖 Fix all issues with AI agents
In `@src/TabNavList/TabNode.tsx`:
- Line 98: The code uses styles.root directly which throws if styles is
undefined; update the usage in TabNode (where style={styles.root}) to guard with
optional chaining or a fallback (e.g. style={styles?.root} or
style={styles?.root ?? undefined}) so the component won't crash when the styles
prop is omitted; locate the style assignment in TabNode.tsx and replace
styles.root with styles?.root (or provide a default styles object) accordingly.
- Around line 129-133: 在 TabNode 组件的 JSX 中,style={styles.icon} 会在 styles
未定义时抛出异常;将其改为使用可选链(即 styles?.icon)或在组件开始处给 styles 默认值,确保访问 styles.icon
前先判空;在包含图标的 span(引用 tabPrefix、classNames?.icon 的位置)替换为使用 styles?.icon 以避免运行时错误。

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