New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: component token support algorithm #43810
Conversation
Run & review this pull request in StackBlitz Codeflow. |
No top level dependency changes detected. Learn more about Socket for GitHub ↗︎ |
size-limit report 📦
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## feature #43810 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 658 658
Lines 11118 11143 +25
Branches 3009 3017 +8
=========================================
+ Hits 11118 11143 +25
☔ View full report in Codecov by Sentry. |
components/config-provider/index.tsx
Outdated
|
||
const parsedComponents: any = {}; | ||
Object.entries(components || {}).forEach(([componentName, componentToken]) => { | ||
parsedComponents[componentName] = { ...componentToken }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parsedComponents[componentName]
到处都是,这里提个变量出来
}; | ||
|
||
// Format if needed | ||
mergedDerivativeToken = formatToken(mergedDerivativeToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatToken 下面也调用了一次,这个确定是要这么做的么?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
只有这里调用了。cssinjs 里会被这个 getComputedToken 完全覆盖逻辑
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
所以理论上 useCacheToken 是可以不传 formatToken 的
[中文版模板 / Chinese template]
🤔 This is a ...
🔗 Related issue link
#43638
💡 Background and solution
https://preview-43810-ant-design.surge.sh/components/config-provider-cn#components-config-provider-demo-theme
Kapture.2023-07-26.at.12.03.11.mp4
📝 Changelog
algorithm
to calculate derivative tokens same as global.algorithm
,和全局 Token 一样可用算法计算派生。☑️ Self-Check before Merge
🚀 Summary
🤖 Generated by Copilot at 5121402
This pull request enhances the theme customization feature of the
ConfigProvider
component. It allows users to specify different theme tokens and derivation logic for individual components using thetheme
prop. It also updates the related hooks, context, interface, and demo files to support the new feature. It requires a newer version of@ant-design/cssinjs
dependency.🔍 Walkthrough
🤖 Generated by Copilot at 5121402
@ant-design/cssinjs
andcomponents/theme
in several files (link, link, link, link)ThemeConfig
interface and thetheme
prop of theConfigProvider
component to support component-specific theme tokens and algorithms (link, link, link, link, link, link)getComputedToken
function and theuseTheme
hook to apply the theme derivation logic to the global and component themes (link, link, link, link)DesignTokenContext.Provider
component to pass the component-specific theme tokens and themes to the context consumers (link)package.json
file to use the latest version of@ant-design/cssinjs
dependency (link)components/config-provider/demo/theme.tsx
to showcase the new theme customization features for different components (link, link, link, link)