-
Notifications
You must be signed in to change notification settings - Fork 39
✨ feat: support antd v6 cssVar #198
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
base: master
Are you sure you want to change the base?
Changes from all commits
cd838b0
35732f5
a1bd816
cb9936f
968626e
b922a94
f739af5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| import { useMemo } from 'react'; | ||
|
|
||
| import { AntdTheme } from '@/types'; | ||
| import { theme } from 'antd'; | ||
| import { useAntdStylish } from './useAntdStylish'; | ||
| import { useAntdToken } from './useAntdToken'; | ||
|
|
||
| export const useAntdTheme = (): AntdTheme => { | ||
| const token = useAntdToken(); | ||
| const { token, cssVar } = theme.useToken(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chain验证 theme.useToken() 返回 cssVar 确认 antd v6.0.0-alpha.1 的 theme.useToken() 确实返回 cssVar 属性。 🌐 Web query: 💡 Result: In Ant Design v6.0.0-alpha.1, the However, it's important to note that Ant Design's theming system does not natively support the use of CSS variables within tokens. This limitation arises because the theming algorithm does not interpret CSS variables, which can lead to issues when attempting to use them in tokens. (github.com) To incorporate CSS variables into your Ant Design theming, you can utilize the In summary, while Citations:
修复 theme.useToken() 解构 Ant Design v6.0.0-alpha.1 中, 请处理以下位置:
🤖 Prompt for AI Agents |
||
| const stylish = useAntdStylish(); | ||
|
|
||
| return useMemo(() => ({ ...token, stylish }), [token, stylish]); | ||
| return useMemo(() => ({ ...token, stylish, cssVar }), [token, stylish, cssVar]); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -53,7 +53,9 @@ describe('extractStaticStyle', () => { | |||||||||||||
| const item = result.find((i) => i.key === 'antd')!; | ||||||||||||||
| expect(item).toBeDefined(); | ||||||||||||||
| expect(item.css).toMatch(/\.ant-/); | ||||||||||||||
| expect(item.tag).toMatch(/<style data-rc-order="prepend" data-rc-priority="-9999" data-antd-version="[0-9]+\.[0-9]+\.[0-9]+">\s*/); | ||||||||||||||
| expect(item.tag).toMatch( | ||||||||||||||
| /<style data-rc-order="prepend" data-rc-priority="-9999" data-antd-version="6.0.0-alpha.1">\s*/, | ||||||||||||||
| ); | ||||||||||||||
|
Comment on lines
+56
to
+58
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 考虑测试断言的维护性 将版本断言从语义版本模式改为硬编码的 "6.0.0-alpha.1" 可能会在 antd 版本更新时导致测试失败。 建议考虑以下方案之一:
- expect(item.tag).toMatch(
- /<style data-rc-order="prepend" data-rc-priority="-9999" data-antd-version="6.0.0-alpha.1">\s*/,
- );
+ expect(item.tag).toMatch(
+ /<style data-rc-order="prepend" data-rc-priority="-9999" data-antd-version="6\.\d+\.\d+(-\w+\.\d+)?">\s*/,
+ );📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
| }); | ||||||||||||||
|
|
||||||||||||||
| // FIXME: 迁移到 vitest 后,不知道为什么 无法提取 extractStaticStyle 了 | ||||||||||||||
|
|
||||||||||||||
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.
修复标题层级,避免 markdownlint 报错
版本标题使用了
#,与文件中其他版本标题的##不一致,且导致#➜###直接跳过一级标题层级,被markdownlint标记为MD001。请统一为二级标题。📝 Committable suggestion
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
5-5: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3
(MD001, heading-increment)
🤖 Prompt for AI Agents