feat(float-button): Support better customization with semantic classNames/styles as function#54917
feat(float-button): Support better customization with semantic classNames/styles as function#54917zombieJ merged 7 commits intoant-design:nextfrom meet-student:float-button
Conversation
…ames/styles as function
…classNames/styles as function
|
|
|
Note Other AI code review bot(s) detectedCodeRabbit 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. Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
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. Comment |
👁 Visual Regression Report for PR #54917 Failed ❌
Important There are 7 diffs found in this PR: 🔄
|
There was a problem hiding this comment.
Summary of Changes
Hello @meet-student, 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 FloatButton component by enabling more flexible and dynamic styling. Developers can now define classNames and styles as functions, which receive the component's properties, allowing for highly conditional and adaptive visual adjustments. This change provides greater control over the component's appearance without altering its core functionality.
Highlights
- Enhanced Customization for FloatButton: The
FloatButtoncomponent now supports functions for itsclassNamesandstylesprops, allowing for dynamic application of CSS classes and inline styles based on the component's current properties (e.g.,type,shape). - New Demo and Documentation: A new demo (
style-class.tsx) and corresponding documentation (style-class.md) have been added to showcase how to leverage the new function-basedclassNamesandstylesfor advanced customization. - Improved Type Definitions and Internal Logic: The type definitions for
FloatButtonPropshave been updated to reflect the new function capabilities, and the internaluseMergeSemantichook integration has been adjusted to correctly pass component props for dynamic evaluation.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| 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 issue 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
-
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. ↩
There was a problem hiding this comment.
Code Review
This pull request introduces a new feature to the FloatButton component, allowing classNames and styles props to be provided as functions for more dynamic customization. The implementation is solid, with new types, logic to handle function props, and corresponding tests and documentation updates. My review includes a couple of suggestions for improvement: one is to remove an unnecessary as any type cast in a test file to enhance type safety, and the other is to correct the documentation for FloatButton.Group which incorrectly removes the styles prop.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next #54917 +/- ##
========================================
Coverage ? 100.00%
========================================
Files ? 792
Lines ? 14589
Branches ? 3881
========================================
Hits ? 14589
Misses ? 0
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: 遇见同学 <[email protected]>
More templates
commit: |
Bundle ReportChanges will increase total bundle size by 7.85MB (209.25%) ⬆️
Affected Assets, Files, and Routes:view changes for bundle: antd.min-array-pushAssets Changed:
|
- Add classNames and styles props for semantic customization - Support four semantic parts: root, image, description, footer - Use advanced useMergeSemantic hook with type parameters - Add SemanticClassNamesType and SemanticStylesType utility types - Implement mergedProps pattern for conditional semantic logic - Add comprehensive semantic demo with style-class example - Add ConfigProvider-level test for Empty semantic customization - Update API documentation in both English and Chinese - Follow PR ant-design#54917 pattern for consistent semantic implementation - Based on next branch with latest semantic infrastructure
…4917 pattern - Simplify semantic test cases to match FloatButton implementation - Use more focused test structure with rerender pattern - Add proper EmptyProps type import for type safety - Follow exact naming convention from FloatButton tests: * 'should apply dynamic classNames and styles from props function' * 'should apply object classNames and styles' - Remove overly complex test cases, keep essential functionality tests - Ensure test structure matches established Ant Design patterns Based on FloatButton semantic tests analysis from PR ant-design#54917
- Add classNames and styles props for semantic customization - Support four semantic parts: root, image, description, footer - Use advanced useMergeSemantic hook with type parameters - Add SemanticClassNamesType and SemanticStylesType utility types - Implement mergedProps pattern for conditional semantic logic - Add comprehensive semantic demo with style-class example - Add ConfigProvider-level test for Empty semantic customization - Update API documentation in both English and Chinese - Follow PR ant-design#54917 pattern for consistent semantic implementation - Based on next branch with latest semantic infrastructure
…4917 pattern - Simplify semantic test cases to match FloatButton implementation - Use more focused test structure with rerender pattern - Add proper EmptyProps type import for type safety - Follow exact naming convention from FloatButton tests: * 'should apply dynamic classNames and styles from props function' * 'should apply object classNames and styles' - Remove overly complex test cases, keep essential functionality tests - Ensure test structure matches established Ant Design patterns Based on FloatButton semantic tests analysis from PR ant-design#54917
…yles as function (#55007) * feat(empty): add semantic customization support based on next branch - Add classNames and styles props for semantic customization - Support four semantic parts: root, image, description, footer - Use advanced useMergeSemantic hook with type parameters - Add SemanticClassNamesType and SemanticStylesType utility types - Implement mergedProps pattern for conditional semantic logic - Add comprehensive semantic demo with style-class example - Add ConfigProvider-level test for Empty semantic customization - Update API documentation in both English and Chinese - Follow PR #54917 pattern for consistent semantic implementation - Based on next branch with latest semantic infrastructure * test: add snapshots for Empty semantic style-class demo - Add snapshot for style-class.tsx demo in demo.test.ts.snap - Add snapshot for style-class.tsx demo in demo-extend.test.ts.snap - Snapshots include semantic classNames and styles verification: * custom-empty-root with backgroundColor, padding, borderRadius * custom-empty-image with filter grayscale * custom-empty-description with color and fontWeight * custom-empty-footer with marginTop - Verify semantic customization is properly applied to DOM elements - Complete test coverage for Empty component semantic features * fix: improve Empty semantic implementation based on review feedback - Add default semantic classNames for image, description, footer parts - Update API documentation with detailed descriptions and function type support - Follow FloatButton pattern for consistent semantic implementation - Improve documentation clarity for classNames and styles props - Support both object and function-based semantic customization - Ensure proper semantic class application to DOM elements * fix: address PR review feedback for Empty semantic implementation - Remove ineffective React.useMemo for mergedProps, use simple object spread - Add comprehensive function-based semantic tests in describe('semantic classNames/styles') - Add ConfigProvider-level function-based semantic tests - Enhance demo to showcase both object and function-based semantic customization - Add interactive demo with Switch to demonstrate dynamic function-based styling - Test function parameter passing and prop dependency handling - Ensure complete test coverage for both object and function semantic patterns Addresses gemini-code-assist bot feedback: 1. Fixed ineffective useMemo with props dependency 2. Added function-based semantic test coverage 3. Enhanced demo to show function-based capabilities * refactor: align Empty semantic tests with FloatButton PR #54917 pattern - Simplify semantic test cases to match FloatButton implementation - Use more focused test structure with rerender pattern - Add proper EmptyProps type import for type safety - Follow exact naming convention from FloatButton tests: * 'should apply dynamic classNames and styles from props function' * 'should apply object classNames and styles' - Remove overly complex test cases, keep essential functionality tests - Ensure test structure matches established Ant Design patterns Based on FloatButton semantic tests analysis from PR #54917 * docs: improve Empty semantic API documentation and remove ConfigProvider tests - Update Chinese documentation for classNames and styles properties - Use more concise and consistent descriptions matching Ant Design standards - Update version from 5.23.0 to 6.0.0 for semantic API - Add missing documentation for style-class demo in both languages - Remove ConfigProvider-level Empty semantic tests as requested - Keep semantic tests focused in Empty component test file only Changes: - components/empty/index.zh-CN.md: Improved API descriptions - components/empty/demo/style-class.md: Added demo documentation - components/config-provider/__tests__/style.test.tsx: Removed Empty tests * refactor: clean up Empty semantic tests and demo - Remove remaining Empty semantic tests from ConfigProvider test file - Simplify style-class demo to basic implementation - Remove demo documentation to keep it minimal - Focus semantic tests in Empty component test file only This ensures cleaner separation of concerns and avoids test duplication. * fix: resolve Empty semantic classNames duplication and update documentation * refactor: address Meet-student review feedback for Empty semantic demo - Fix documentation: change 'buttons' to 'empty' in both Chinese and English - Remove iframe attribute from demo documentation - Simplify demo to show 4 different usage patterns without complex toggle logic - Add comprehensive examples: object/function forms with external/inline definitions - Fix TypeScript warnings and improve code clarity * refactor: address Meet-student review feedback and optimize demo structure - Remove version numbers from API documentation (classNames/styles) - Simplify demo to show 4 separate examples for each semantic property - Add comprehensive ConfigProvider tests for function-based semantic usage - Optimize demo structure: separate objectClassNames, objectStyles, functionClassNames, functionStyles - Each demo example focuses on single property for better clarity * refactor(empty): Optimize the type definitions and style types in the Empty component demo. * fix: ensure CSS-in-JS prefix classes are applied to Empty semantic elements - Add manual prefix class application for image, description, and footer elements - Remove emptyClassNames from useMergeSemantic to avoid duplication - Ensure CSS-in-JS styles can properly target semantic elements - Fix issue where custom prefixCls wouldn't work with CSS select * test: Update snapshot * refactor(components/empty): Remove unused merge property code * Update components/empty/demo/style-class.md Signed-off-by: 遇见同学 <[email protected]> * Update components/empty/demo/style-class.md Signed-off-by: 遇见同学 <[email protected]> * refactor(empty): simplify style-class demo following pagination pattern - Keep four essential objects: classNamesObject, classNamesFn, stylesObject, stylesFn - Use same classNames across examples with sharedClassNames - Differentiate styles based on props in stylesFn - Reduce code from 115 to 68 lines (40% reduction) - Add clear English comments for each object - Update snapshots for new structure - Follow pagination demo concise style * test(empty): update snapshots after style-class demo refactor - Update demo.test.ts.snap with new simplified structure - Update demo-extend.test.ts.snap accordingly - Snapshots now reflect the refactored demo with 4 examples - All tests passing with updated snapshots * refactor(empty): simplify style-class demo - Remove classNamesObject and classNamesFn as suggested 'use style instead' - Reduce to 2 examples as requested 'use two examples only' - Keep Object styles and Function styles to demonstrate styles usage - Update snapshots accordingly --------- Signed-off-by: 遇见同学 <[email protected]> Co-authored-by: lijianan <[email protected]> Co-authored-by: 遇见同学 <[email protected]>










中文版模板 / Chinese template
🤔 This is a ...
🔗 Related Issues
💡 Background and Solution
📝 Change Log