Skip to content

feat(message): support better customization with semantic classNames/styles - #55054

Merged
thinkasany merged 31 commits into
ant-design:nextfrom
nmsn:feat/message
Sep 30, 2025
Merged

thinkasany merged 31 commits into
ant-design:nextfrom
nmsn:feat/message

Conversation

@nmsn

@nmsn nmsn commented Sep 17, 2025 •

Copy link
Copy Markdown
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

  • 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 Support better customization with semantic classNames/styles
🇨🇳 Chinese Support better customization with semantic classNames/styles

@bolt-new-by-stackblitz

Copy link
Copy Markdown

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

@coderabbitai

coderabbitai Bot commented Sep 17, 2025 •

Copy link
Copy Markdown
Contributor

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

github-actions Bot commented Sep 17, 2025 •

Copy link
Copy Markdown
Contributor

Preview is ready

@github-actions

github-actions Bot commented Sep 17, 2025 •

Copy link
Copy Markdown
Contributor

👁 Visual Regression Report for PR #55054 Failed ❌

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

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

Important

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

  • Visual diff is acceptable

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Summary of Changes

Hello @nmsn, 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 significant enhancements to the message component, enabling developers to achieve more precise and flexible customization of its appearance. By exposing classNames and styles props that can accept both static objects and dynamic functions, users can now target specific semantic elements within the message structure for tailored styling. This is underpinned by a new mergeSemantic utility, ensuring consistent and robust merging of customization options across different contexts.

Highlights

  • Enhanced Customization for Message Component: The message component now supports classNames and styles props, allowing for more granular control over its internal semantic DOM elements.
  • Flexible Customization Options: Both classNames and styles props can accept either an object for static customization or a function for dynamic, context-aware styling based on component props.
  • New Semantic Merging Utility: A new mergeSemantic utility hook has been introduced to consistently merge class names and styles from multiple sources, including context and component configurations.
  • Improved Code Structure: Internal style merging logic has been refactored into shared utility functions (resolveCallbackValue, mergeStyles) within useMergeSemantic for better maintainability and reusability.
  • Comprehensive Documentation and Demos: New documentation and a dedicated demo (style-class.tsx) have been added to illustrate the usage and capabilities of the new classNames and styles 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 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. ↩

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 great feature for better customization of the message component by adding support for semantic classNames and styles, which can be provided as objects or functions. The implementation is well-structured, extracting shared logic into a useMergeSemantic hook and a non-hook mergeSemantic utility, making the code cleaner and more maintainable. I've found one potential issue that could lead to a runtime error and have also included a suggestion to improve test coverage for the new feature.

@pkg-pr-new

pkg-pr-new Bot commented Sep 17, 2025 •

Copy link
Copy Markdown

@codecov

codecov Bot commented Sep 17, 2025 •

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 498 bytes (0.01%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
antd.min-array-push 3.76MB 498 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 249 bytes 2.07MB 0.01%
antd.min.js 249 bytes 1.68MB 0.01%

@codecov

codecov Bot commented Sep 17, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (c7f5379) to head (23deb25).
⚠️ Report is 3 commits behind head on next.

Additional details and impacted files
@@            Coverage Diff            @@
##              next    #55054   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          798       798           
  Lines        14734     14747   +13     
  Branches      3894      3897    +3     
=========================================
+ Hits         14734     14747   +13     

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

Comment thread components/message/PurePanel.tsx Resolved
@meet-student meet-student changed the title feat(message): support better customization with semantic classNames/… feat(message): support better customization with semantic classNames/styles Sep 18, 2025
Comment thread components/message/PurePanel.tsx Resolved
Comment thread components/message/index.en-US.md Resolved
Comment thread components/message/index.en-US.md Resolved
Comment thread components/message/index.en-US.md Resolved
Comment thread components/message/index.zh-CN.md Resolved
Comment thread components/message/index.zh-CN.md Resolved
Comment thread components/message/index.zh-CN.md Resolved
Comment thread components/message/index.zh-CN.md Resolved
Comment thread components/message/index.en-US.md Resolved
Signed-off-by: 遇见同学 <1875694521@qq.com>
Comment thread components/message/useMessage.tsx Outdated
}

// Handle function classNames and styles
const contextClassNames =

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

这段逻辑感觉能优化下

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

相似逻辑抽离个函数处理下?还是怎么说

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

嗯抽

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

这块我单独 提pr 修改 @zombieJ

@thinkasany

Copy link
Copy Markdown
Member

单测覆盖率还差一点点
image

Comment thread components/message/demo/style-class.tsx Outdated
import type { MessageArgsProps } from 'antd';
import { createStyles } from 'antd-style';

const useStyle = createStyles(({ css }) => ({

@zombieJ zombieJ Sep 30, 2025 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Image

不做 margin 的偏移,就调本身的样式吧,否则看起来像是个 bug

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Sep 30, 2025
@thinkasany
thinkasany merged commit b8a5731 into ant-design:next Sep 30, 2025
@github-actions

Copy link
Copy Markdown
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 链接)。

钉钉社区群二维码

@nmsn
nmsn deleted the feat/message branch September 30, 2025 11:14
@zombieJ zombieJ mentioned this pull request Nov 4, 2025
1 of 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