Skip to content

Conversation

@zombieJ
Copy link
Member

@zombieJ zombieJ commented Jan 14, 2026

Summary by CodeRabbit

发布说明

  • 新功能
    • ColorBlock 组件现已支持通过新增属性对内部元素进行自定义样式设置,提供更灵活的样式扩展能力。

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

@coderabbitai
Copy link

coderabbitai bot commented Jan 14, 2026

Walkthrough

向ColorBlock组件添加了两个可选的内部自定义属性(innerClassName和innerStyle),以支持对内部颜色元素的样式定制。同时更新了测试配置并添加了相应的测试用例验证新功能。

Changes

聚合 / 文件 变更摘要
ColorBlock 组件增强
src/components/ColorBlock.tsx
向 ColorBlockProps 接口添加两个可选属性:innerClassName?: stringinnerStyle?: React.CSSProperties,用于定制内部颜色div元素的样式
测试更新
tests/components.test.tsx
添加 ColorBlock 到公共导出,并引入新测试用例验证 innerClassName 和 innerStyle 属性的功能
TypeScript 配置
tsconfig.json
将 "@testing-library/jest-dom" 添加至编译器选项的全局类型定义中

Estimated code review effort

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

Poem

🐰 一个小兔子跳啊跳,
ColorBlock 披上新衣裳,
innerClassName 和 innerStyle 来帮忙,
自定义样式真舒爽,
测试文件齐整装!

🚥 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 The pull request title 'feat: ColorBlock support inner style' accurately describes the main changes: adding innerClassName and innerStyle props to the ColorBlock component for customizing the inner element.
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
  • Commit unit tests in branch color-block-inner


📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3895c8a and 51e8d4d.

📒 Files selected for processing (3)
  • src/components/ColorBlock.tsx
  • tests/components.test.tsx
  • tsconfig.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: test / react component workflow
  • GitHub Check: preview
🔇 Additional comments (5)
tsconfig.json (1)

11-11: LGTM!

添加 @testing-library/jest-dom 类型定义是正确的,这支持测试中使用的 toHaveClasstoHaveStyle 等匹配器。

src/components/ColorBlock.tsx (2)

9-12: LGTM!

新增的 innerClassNameinnerStyle 属性定义清晰,JSDoc 注释明确标注了内部使用场景。类型定义正确。


32-35: 确认样式合并顺序是否符合预期

当前实现中 innerStyle 会覆盖 background 属性。如果这是预期行为(允许完全自定义内部样式),则没有问题。但如果希望 color 始终作为背景色,可以考虑调整合并顺序:

-        style={{ background: color, ...innerStyle }}
+        style={{ ...innerStyle, background: color }}
tests/components.test.tsx (2)

60-73: LGTM!

测试用例覆盖了 innerClassNameinnerStyle 两个新属性,断言清晰,测试逻辑正确。使用 color 样式而非 background 作为测试用例是合理的选择,避免与组件自身的背景色设置冲突。


5-5: 导入语句正确且完整。ColorBlock、BaseSliderProps 均已正确从 src/index.tsx 导出,无需调整。

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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.

@gemini-code-assist
Copy link

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 introduces new styling capabilities to the ColorBlock component by adding innerClassName and innerStyle props. These additions provide greater control over the visual presentation of the component's inner elements, specifically for internal use within the antd ColorPicker's structure. The changes are thoroughly validated with new unit tests, and the project's TypeScript configuration has been updated to support the testing environment.

Highlights

  • ColorBlock Component Enhancement: The ColorBlock component now accepts innerClassName and innerStyle props, allowing for direct styling and class application to its internal color display element. These props are intended for internal usage within the antd ColorPicker semantic structure.
  • New Test Coverage: A new test case has been added to tests/components.test.tsx to verify that the innerClassName and innerStyle props are correctly applied to the inner div of the ColorBlock component.
  • TypeScript Configuration Update: The tsconfig.json file has been updated to include @testing-library/jest-dom in the types array, enhancing type support for DOM-related assertions in tests.

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

@codecov
Copy link

codecov bot commented Jan 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (3895c8a) to head (51e8d4d).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #273   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           15        15           
  Lines          893       902    +9     
  Branches        89        89           
=========================================
+ Hits           893       902    +9     

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

@github-actions
Copy link

github-actions bot commented Jan 14, 2026

🎊 PR Preview 51e8d4d has been successfully built and deployed to https://react-component-color-picker-preview-pr-273.surge.sh

🕐 Build time: 95.205s

🤖 By surge-preview

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 introduces innerClassName and innerStyle props to the ColorBlock component, enhancing its styling flexibility for internal use. The implementation is straightforward and includes corresponding test coverage. My review includes a couple of suggestions to improve the clarity of the new prop documentation and to make the new test case more robust.

Comment on lines +9 to +12
/** Internal usage. Only used in antd ColorPicker semantic structure only */
innerClassName?: string;
/** Internal usage. Only used in antd ColorPicker semantic structure only */
innerStyle?: React.CSSProperties;

Choose a reason for hiding this comment

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

medium

The comments for innerClassName and innerStyle are a bit verbose and could be more direct. The phrase "semantic structure only" is also slightly ambiguous. Consider using the @internal JSDoc tag to signify internal usage, which is a standard convention and can be picked up by documentation generation tools. A more concise comment would improve readability and maintainability.

Suggested change
/** Internal usage. Only used in antd ColorPicker semantic structure only */
innerClassName?: string;
/** Internal usage. Only used in antd ColorPicker semantic structure only */
innerStyle?: React.CSSProperties;
/** @internal For internal antd ColorPicker usage only. */
innerClassName?: string;
/** @internal For internal antd ColorPicker usage only. */
innerStyle?: React.CSSProperties;

prefixCls="test"
color="red"
innerClassName="my-inner-class"
innerStyle={{ color: '#903' }}

Choose a reason for hiding this comment

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

medium

The test for innerStyle uses color: '#903'. The color CSS property sets the color of text, but the div being tested does not contain any text. While this test is technically correct and will pass, it doesn't meaningfully verify the visual effect of the applied style. To make the test more robust, consider using a style property that has a visible effect on a div element, such as border.

Suggested change
innerStyle={{ color: '#903' }}
innerStyle={{ border: '1px solid green' }}


const innerDiv = container.querySelector('.test-color-block-inner');
expect(innerDiv).toHaveClass('my-inner-class');
expect(innerDiv).toHaveStyle({ color: '#903' });

Choose a reason for hiding this comment

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

medium

To align with the suggestion to test a more meaningful style property, please update this assertion to check for the border style instead of color.

Suggested change
expect(innerDiv).toHaveStyle({ color: '#903' });
expect(innerDiv).toHaveStyle({ border: '1px solid green' });

@zombieJ zombieJ merged commit c8f642b into master Jan 14, 2026
9 checks passed
@zombieJ zombieJ deleted the color-block-inner branch January 14, 2026 08:34
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.

2 participants