mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 06:03:38 +08:00
refactor: Checkbox & Tree migrate to genComponentStyleHook (#34904)
* refactor: Checkbox migrate to genComponentStyleHook * refactor: tree migrate to genComponentStyleHook
This commit is contained in:
parent
8dd16a1f57
commit
064edfe22a
@ -43,6 +43,7 @@ export interface OverrideToken {
|
||||
Button?: ButtonComponentToken;
|
||||
Carousel?: {};
|
||||
Cascader?: CascaderComponentToken;
|
||||
Checkbox?: {};
|
||||
Divider?: DividerComponentToken;
|
||||
Empty?: EmptyComponentToken;
|
||||
Form?: {};
|
||||
@ -52,6 +53,7 @@ export interface OverrideToken {
|
||||
Pagination?: {};
|
||||
Select?: SelectComponentToken;
|
||||
Slider?: SliderComponentToken;
|
||||
Tree?: {};
|
||||
TreeSelect?: {};
|
||||
Typography?: TypographyComponentToken;
|
||||
}
|
||||
|
@ -1,15 +1,8 @@
|
||||
// deps-lint-skip-all
|
||||
import { Keyframes } from '@ant-design/cssinjs';
|
||||
import {
|
||||
DerivativeToken,
|
||||
useStyleRegister,
|
||||
useToken,
|
||||
resetComponent,
|
||||
UseComponentStyleResult,
|
||||
GenerateStyle,
|
||||
} from '../../_util/theme';
|
||||
import { resetComponent, GenerateStyle, genComponentStyleHook, FullToken } from '../../_util/theme';
|
||||
|
||||
interface CheckboxToken extends DerivativeToken {
|
||||
interface CheckboxToken extends FullToken<'Checkbox'> {
|
||||
checkboxCls: string;
|
||||
}
|
||||
|
||||
@ -242,7 +235,7 @@ export const genCheckboxStyle: GenerateStyle<CheckboxToken> = (token, hashId) =>
|
||||
};
|
||||
|
||||
// ============================== Export ==============================
|
||||
export function getStyle(prefixCls: string, token: DerivativeToken, hashId: string) {
|
||||
export function getStyle(prefixCls: string, token: FullToken<'Checkbox'>, hashId: string) {
|
||||
const checkboxToken: CheckboxToken = {
|
||||
...token,
|
||||
checkboxCls: `.${prefixCls}`,
|
||||
@ -251,13 +244,6 @@ export function getStyle(prefixCls: string, token: DerivativeToken, hashId: stri
|
||||
return [genCheckboxStyle(checkboxToken, hashId), antCheckboxEffect];
|
||||
}
|
||||
|
||||
export default function useStyle(prefixCls: string): UseComponentStyleResult {
|
||||
const [theme, token, hashId] = useToken();
|
||||
|
||||
return [
|
||||
useStyleRegister({ theme, token, hashId, path: [prefixCls] }, () =>
|
||||
getStyle(prefixCls, token, hashId),
|
||||
),
|
||||
hashId,
|
||||
];
|
||||
}
|
||||
export default genComponentStyleHook('Checkbox', (token, { prefixCls, hashId }) => [
|
||||
getStyle(prefixCls, token, hashId),
|
||||
]);
|
||||
|
@ -3,13 +3,7 @@
|
||||
|
||||
// deps-lint-skip-all
|
||||
import { CSSObject, CSSInterpolation, Keyframes } from '@ant-design/cssinjs';
|
||||
import {
|
||||
DerivativeToken,
|
||||
useStyleRegister,
|
||||
useToken,
|
||||
resetComponent,
|
||||
UseComponentStyleResult,
|
||||
} from '../../_util/theme';
|
||||
import { DerivativeToken, resetComponent, genComponentStyleHook } from '../../_util/theme';
|
||||
import { getStyle as getCheckboxStyle } from '../../checkbox/style';
|
||||
|
||||
// ============================ Keyframes =============================
|
||||
@ -471,15 +465,8 @@ export const genTreeStyle = (
|
||||
};
|
||||
|
||||
// ============================== Export ==============================
|
||||
export default function useStyle(prefixCls: string): UseComponentStyleResult {
|
||||
const [theme, token, hashId] = useToken();
|
||||
|
||||
return [
|
||||
useStyleRegister({ theme, token, hashId, path: [prefixCls] }, () => [
|
||||
getCheckboxStyle(`${prefixCls}-checkbox`, token, hashId),
|
||||
genTreeStyle(prefixCls, token, hashId),
|
||||
treeNodeFX,
|
||||
]),
|
||||
hashId,
|
||||
];
|
||||
}
|
||||
export default genComponentStyleHook('Tree', (token, { prefixCls, hashId }) => [
|
||||
getCheckboxStyle(`${prefixCls}-checkbox`, token, hashId),
|
||||
genTreeStyle(prefixCls, token, hashId),
|
||||
treeNodeFX,
|
||||
]);
|
||||
|
Loading…
Reference in New Issue
Block a user