-
Notifications
You must be signed in to change notification settings - Fork 65
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: add util genCalc and type AbstractCalculator #184
Conversation
🎊 PR Preview 1e06d3f has been successfully built and deployed to https://ant-design-cssinjs-preview-pr-184.surge.sh 🕐 Build time: 92.05s 🤖 By surge-preview |
@@ -55,6 +56,7 @@ export type { | |||
Transformer, | |||
Linter, | |||
StyleProviderProps, | |||
AbstractCalculator, |
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.
这个不用 export 了吧
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.
|
[RFC] Migrate the genCalc util from antd repo
Summary
genCalc
API 由原 https://github.com/ant-design/ant-design/tree/master/components/theme/util/calc 迁移至@ant-design/cssinjs
Motivation
在 antd 中书写组件样式时,均统一使用 repo 中的
genStyleHooks
、mergeToken
、genPresetColor
、genSubStyleComponent
等 API,目前都统一存放于 https://github.com/ant-design/ant-design/tree/master/components/theme/util 目录下。当前 antd 有类似
@ant-design/web3
、@ant-design/x
等生态库,在生态库中编写组件样式时目前几种选择:@ant-design/cssinjs
简单实现类似的功能封装@ant-design/cssinjs
,尽可能减少重复代码对于方式一,并不可取,不同的库同样的代码,这会给后续的维护造成负担。
方式二,使用了当前已有的
@ant-design/cssinjs
API,如useStyleRegister
等,详见:https://github.com/ant-design/ant-design-web3/blob/main/packages/web3/src/theme/useStyle/index.ts方式三,将通用的工具、逻辑抽离至
@ant-design/cssinjs
,尽可能减少重复代码。该 RFC 仅迁移工具函数genCalc
及其对应抽象类AbstractCalculator
API
genCalc
type AbstractCalculator
Basic Example
genCalc
type AbstractCalculator
Unresolved questions
由于 antd 中常用API
genStyleHooks
调用genSubStyleComponent
调用genCalc
,迁移genCalc
仅解决部分代码重复问题,后续仍需要持续优化。另外,需要在 antd 中提 PR 对此次变更兼容。后续将补充。