Skip to content

feat(empty): Support better customization with semantic classNames/styles as function#55007

Merged
zombieJ merged 31 commits intoant-design:nextfrom
Susuperli:feat/empty-semantic-next-based
Sep 30, 2025
Merged

feat(empty): Support better customization with semantic classNames/styles as function#55007
zombieJ merged 31 commits intoant-design:nextfrom
Susuperli:feat/empty-semantic-next-based

Conversation

@Susuperli
Copy link
Contributor

中文版模板 / Chinese template

🤔 This is a ...

  • 🆕 New feature
  • 🐞 Bug fix
  • 📝 Site / documentation improvement
  • 📽️ Demo improvement
  • 💄 Component style improvement
  • 🤖 TypeScript definition improvement
  • 📦 Bundle size optimization
  • ⚡️ Performance optimization
  • ⭐️ Feature enhancement
  • 🌐 Internationalization
  • 🛠 Refactoring
  • 🎨 Code style optimization
  • ✅ Test Case
  • 🔀 Branch merge
  • ⏩ Workflow
  • ⌨️ Accessibility improvement
  • ❓ Other (about what?)

🔗 Related Issues

💡 Background and Solution

  • The specific problem to be addressed.
  • List the final API implementation and usage if needed.
  • If there are UI/interaction changes, consider providing screenshots or GIFs.

📝 Change Log

Language Changelog
🇺🇸 English Support better customization with semantic classNames/styles as function
🇨🇳 Chinese 使用语义类名/样式作为函数,支持更好的自定义

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 13, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

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.

✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 13, 2025

👁 Visual Regression Report for PR #55007 Failed ❌

🎯 Target branch: next (a97235f)
📖 View Full Report ↗︎
📖 Alternative Report ↗︎
📊 Summary: 🔄 4 changed, 🆕 3 added

Expected (Branch next) Actual (Current PR) Diff
auto-complete-variant.compact.png auto-complete-variant.compact.png auto-complete-variant.compact.png auto-complete-variant.compact.png
auto-complete-variant.dark.png auto-complete-variant.dark.png auto-complete-variant.dark.png auto-complete-variant.dark.png
auto-complete-variant.default.png auto-complete-variant.default.png auto-complete-variant.default.png auto-complete-variant.default.png
table-sticky.dark.png table-sticky.dark.png table-sticky.dark.png table-sticky.dark.png
empty-style-class.compact.png empty-style-class.compact.png 🆕🆕🆕 Added 🆕🆕🆕
empty-style-class.dark.png empty-style-class.dark.png 🆕🆕🆕 Added 🆕🆕🆕
empty-style-class.default.png empty-style-class.default.png 🆕🆕🆕 Added 🆕🆕🆕

Important

There are 7 diffs found in this PR: 🔄 4 changed, 🆕 3 added.
Please check all items:

  • Visual diff is acceptable

@github-actions
Copy link
Contributor

github-actions bot commented Sep 13, 2025

Preview is ready

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 @Susuperli, 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 Empty component within the Ant Design library, enabling developers to customize its appearance with greater flexibility. By allowing semantic classNames and styles to be defined as functions, the component can now adapt its styling dynamically based on its internal state or external props, leading to more robust and adaptable UI implementations. This change improves the overall customizability of the Empty component, aligning it with modern styling practices and developer expectations.

Highlights

  • Enhanced Empty Component Customization: The Empty component now supports semantic classNames and styles properties, allowing for more granular control over its appearance.
  • Function-based Customization: The classNames and styles properties can now accept functions, enabling dynamic styling based on component props.
  • New Test Coverage: A new test case has been added to ConfigProvider to validate the correct application of these new customization options for the Empty component.
  • Updated Documentation and Demos: The API documentation for the Empty component has been updated, and a new demo (style-class.tsx) has been added to illustrate the usage of these new customization features.
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

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

This pull request introduces a valuable enhancement to the Empty component by allowing classNames and styles to be provided as functions for more dynamic customization. The implementation looks solid, and the new documentation and snapshot tests are correctly updated.

My review includes a few suggestions:

  • The useMemo for mergedProps in Empty/index.tsx is not effective and can be simplified.
  • A crucial test case is missing for the new function-based classNames and styles props.
  • The new demo could be improved by showcasing the function-based usage.

Overall, this is a great feature addition. Addressing these points will make it more robust and complete.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 13, 2025

@codecov
Copy link

codecov bot commented Sep 13, 2025

Bundle Report

Changes will increase total bundle size by 7.92MB (211.09%) ⬆️⚠️, exceeding the configured threshold of 5%.

Bundle name Size Change
antd.min-array-push 11.67MB 7.92MB (211.09%) ⬆️⚠️

Affected Assets, Files, and Routes:

view changes for bundle: antd.min-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
antd-with-locales.js (New) 6.14MB 6.14MB 100.0% 🚀
antd.js (New) 5.53MB 5.53MB 100.0% 🚀
antd-with-locales.min.js (Deleted) -2.06MB 0 bytes -100.0% 🗑️
antd.min.js (Deleted) -1.69MB 0 bytes -100.0% 🗑️

- 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
- 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
- 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
- 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
…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
…der 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
- 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.
@Susuperli Susuperli force-pushed the feat/empty-semantic-next-based branch from df12e03 to 9b4cafd Compare September 15, 2025 11:53
@meet-student
Copy link
Member

meet-student commented Sep 16, 2025

改下comment 内容 @Susuperli

@Susuperli
Copy link
Contributor Author

改下comment 内容 @Susuperli

好的,刚才点错了😂

- 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
@Susuperli
Copy link
Contributor Author

改下comment 内容 @Susuperli

done

@thinkasany
Copy link
Member

@Susuperli 可以不用点击同步,一般我们会帮你同步最新的next分支,由于是第一次 PR,PR 的 ci 会被阻止,需要人工 ap 才运行。

主要是需要等待核心成员验收,我们看了大概没问题了(ci完整通过的话)。就只需要耐心等待即可。

也是希望到时候豆酱老师有空来看的时候,ci 是一个完整的通过状态,就可以直接合了,不然还得等待,时间确实有久。

感谢你的贡献~

@Susuperli
Copy link
Contributor Author

Susuperli commented Sep 19, 2025 via email

Signed-off-by: 遇见同学 <1875694521@qq.com>
Signed-off-by: 遇见同学 <1875694521@qq.com>
@thinkasany
Copy link
Member

@meet-student 更新完记得 ap ci,第一次 PR 的同学,ci不会自动运行。

};

// Object-based styles
const objectStyles = {
Copy link
Member

Choose a reason for hiding this comment

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

demo 参考下这个精简下。样式搭配和谐一些

https://github.com/ant-design/ant-design/pull/54957/files#diff-71c24f063ec1a30f721c1a2bfb648454753dfa9f3b907e9e87fe7302472b3727

classNames 使用同一个,然后 styles 根据 props (尽量选择 type、size、variant)做一下区分

Copy link
Contributor Author

Choose a reason for hiding this comment

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

改了一下看看

- 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
- 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
- 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
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Sep 30, 2025
@zombieJ zombieJ merged commit 5d7c8cc into ant-design:next Sep 30, 2025
39 checks passed
@github-actions
Copy link
Contributor

🎉 Thank you for your contribution! If you have not yet joined our DingTalk community group, please feel free to join us (when joining, please provide the link to this PR).

🎉 感谢您的贡献!如果您还没有加入钉钉社区群,请扫描下方二维码加入我们(加群时请提供此 PR 链接)。

钉钉社区群二维码

@zombieJ zombieJ mentioned this pull request Nov 4, 2025
17 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants