Skip to content

Comments

feat(card): Support better customization with semantic classNames/styles as function#55161

Merged
zombieJ merged 15 commits intoant-design:nextfrom
lovelts:feat-card-semantic
Sep 30, 2025
Merged

feat(card): Support better customization with semantic classNames/styles as function#55161
zombieJ merged 15 commits intoant-design:nextfrom
lovelts:feat-card-semantic

Conversation

@lovelts
Copy link
Contributor

@lovelts lovelts commented Sep 27, 2025

中文版模板 / 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

  • Describe the source of related requirements, such as links to relevant issue discussions.
  • For example: close #xxxx, fix #xxxx

💡 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 feat(card): Support better customization with semantic classNames/styles as function
🇨🇳 Chinese feat(card): Support better customization with semantic classNames/styles as function

@bolt-new-by-stackblitz
Copy link

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

@github-actions
Copy link
Contributor

github-actions bot commented Sep 27, 2025

Preview is ready

@github-actions
Copy link
Contributor

github-actions bot commented Sep 27, 2025

👁 Visual Regression Report for PR #55161 Failed ❌

🎯 Target branch: next (ec1be4a)
📖 View Full Report ↗︎
📖 Alternative Report ↗︎
📊 Summary: 🆕 3 added

Expected (Branch next) Actual (Current PR) Diff
card-style-class.compact.png card-style-class.compact.png 🆕🆕🆕 Added 🆕🆕🆕
card-style-class.dark.png card-style-class.dark.png 🆕🆕🆕 Added 🆕🆕🆕
card-style-class.default.png card-style-class.default.png 🆕🆕🆕 Added 🆕🆕🆕

Important

There are 3 diffs found in this PR: 🆕 3 added.
Please check all items:

  • Visual diff is acceptable

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 27, 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

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
🧪 Early access (Sonnet 4.5): enabled

We are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience.

Note:

  • Public repositories are always opted into early access features.
  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Contributor

Hi @lovelts. Thanks for your contribution. The path .github/ or scripts/ and CHANGELOG is only maintained by team members. This current PR will be closed and team members will help on this.

@lovelts lovelts changed the base branch from master to next September 27, 2025 13:53
@github-actions github-actions bot closed this Sep 27, 2025
@meet-student meet-student reopened this Sep 27, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @lovelts, 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 significantly enhances the customization capabilities of Ant Design components by introducing semantic classNames and styles props, allowing developers to target specific internal DOM elements for styling. It also marks a major internal refactoring effort, transitioning the styling system to rely more heavily on CSS variables and updating core utility libraries. Several APIs have been streamlined or deprecated to improve consistency and maintainability, alongside the introduction of new utility hooks and an innovative AI theme generation feature for the documentation site.

Highlights

  • Semantic Customization: Introduced semantic classNames and styles props across numerous components (e.g., Alert, Anchor, AutoComplete, Badge.Ribbon, Breadcrumb) to enable more granular and flexible styling customization, supporting both object and function values.
  • CSS Variable Migration: Migrated the documentation and demo sites to primarily use CSS variables (cssVar) instead of direct token values for styling, aligning with a broader framework shift towards CSS variables by default.
  • API Unification and Deprecations: Unified several component APIs, such as replacing message with title in Alert, onSearch with showSearch.onSearch in AutoComplete, and direction with orientation in various layout components. Several older props like onClose, afterClose, closeText in Alert are now consolidated under the closable object. The BackTop component has been removed, and Dropdown.Button is deprecated in favor of Space.Compact.
  • Internal Library Updates: Updated numerous internal utility imports from rc-util to @rc-component/util and rc-motion to @rc-component/motion, reflecting a dependency modernization.
  • New Utilities and Hooks: Added new utility hooks like useMergeSemantic, useMergedMask, and useOrientation, along with a new copy utility for clipboard operations. An AI Theme Generator has also been integrated into the documentation site.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/test-v6.yml
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
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 Card and Card.Meta components by allowing classNames and styles props to be functions. This provides greater flexibility for dynamic styling. The implementation looks solid, leveraging a new useMergeSemantic hook to handle the logic cleanly. The changes are well-tested with new unit tests covering both object and function-based props, and a new demo has been added to showcase the feature.

My review focuses on improving the accuracy of the updated API documentation. I've pointed out a typo in the prop types in the Chinese documentation and suggested a precision improvement for the English documentation.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 27, 2025

More templates

npm i https://pkg.pr.new/ant-design/ant-design/antd@55161

commit: 50e04d8

@codecov
Copy link

codecov bot commented Sep 27, 2025

Bundle Report

Changes will decrease total bundle size by 314 bytes (-0.01%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
antd.min-array-push 3.75MB -314 bytes (-0.01%) ⬇️

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.min.js -157 bytes 2.07MB -0.01%
antd.min.js -157 bytes 1.68MB -0.01%

Co-authored-by: lijianan <[email protected]>
Signed-off-by: 遇见同学 <[email protected]>
@thinkasany
Copy link
Member

@meet-student 同步后,记得为新同学 ap ci workflow
image

Copy link

@accesslint accesslint bot left a comment

Choose a reason for hiding this comment

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

There are accessibility issues in these changes.

Copy link

@accesslint accesslint bot left a comment

Choose a reason for hiding this comment

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

There are accessibility issues in these changes.

@codecov
Copy link

codecov bot commented Sep 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (ec1be4a) to head (50e04d8).
⚠️ Report is 13 commits behind head on next.

Additional details and impacted files
@@            Coverage Diff            @@
##              next    #55161   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          798       798           
  Lines        14716     14712    -4     
  Branches      3893      3893           
=========================================
- Hits         14716     14712    -4     

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

@thinkasany
Copy link
Member

怎么出现了两个 card
#55132

@li-jia-nan
Copy link
Member

重复了吧,另外一边可以关了,那边好几天没回复了,CI 也是挂的

meet-student and others added 2 commits September 28, 2025 20:11
Co-authored-by: lijianan <[email protected]>
Signed-off-by: 遇见同学 <[email protected]>
Co-authored-by: lijianan <[email protected]>
Signed-off-by: 遇见同学 <[email protected]>
@thinkasany thinkasany requested a review from Copilot September 28, 2025 12:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the Card component to support better customization by allowing classNames and styles props to accept either objects or functions that receive component props as context. The feature enables dynamic styling based on component state and props.

  • Update Card and CardMeta components to use useMergeSemantic hook for better semantic prop handling
  • Add function-based support for classNames and styles props with component context
  • Include comprehensive test coverage and demo examples for the new functionality

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
components/index.ts Export CardMetaProps type for external usage
components/card/index.zh-CN.md Update Chinese documentation with function-based classNames/styles API
components/card/index.en-US.md Update English documentation with function-based classNames/styles API
components/card/demo/style-class.tsx Add comprehensive demo showcasing object and function-based styling
components/card/demo/style-class.md Add demo documentation in both languages
components/card/tests/index.test.tsx Add test coverage for both object and function-based semantic styling
components/card/tests/snapshots/demo.test.ts.snap Update test snapshots for new demo
components/card/tests/snapshots/demo-extend.test.ts.snap Update extended test snapshots
components/card/Meta.tsx Refactor to use useMergeSemantic hook and support function-based props
components/card/Card.tsx Refactor to use useMergeSemantic hook and support function-based props

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: 遇见同学 <[email protected]>
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Sep 30, 2025
@zombieJ zombieJ merged commit 6a24056 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 skip-verify-files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants