fix: ant- prefix default set font family & size (#37541)

* fix: missing global font size

* chore: patch fontsize

* chore: clean up
This commit is contained in:
二货爱吃白萝卜 2022-09-15 11:37:10 +08:00 committed by GitHub
parent 9293d1043a
commit b24e9ef846
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 4 deletions

View File

@ -15,6 +15,7 @@ export const resetComponent = (token: DerivativeToken): CSSObject => ({
lineHeight: token.lineHeight,
listStyle: 'none',
// font-feature-settings: @font-feature-settings-base;
fontFamily: token.fontFamily,
});
export const resetIcon = (): CSSObject => ({
@ -96,6 +97,17 @@ export const genLinkStyle = (token: DerivativeToken): CSSObject => ({
},
});
export const genFontStyle = (token: DerivativeToken, rootPrefixCls: string) => {
const { fontFamily, fontSize } = token;
return {
[`[class^="${rootPrefixCls}-"], [class*=" ${rootPrefixCls}-"]`]: {
fontFamily,
fontSize,
},
};
};
export const genFocusOutline = (token: DerivativeToken): CSSObject => ({
outline: `${token.lineWidth * 4}px solid ${token.colorPrimaryBorder}`,
outlineOffset: 1,

View File

@ -2,7 +2,7 @@
import type { CSSInterpolation } from '@ant-design/cssinjs';
import { useStyleRegister } from '@ant-design/cssinjs';
import { useContext } from 'react';
import { genLinkStyle } from '../../style';
import { genFontStyle, genLinkStyle } from '../../style';
import { ConfigContext } from '../../config-provider/context';
import type { UseComponentStyleResult } from '../index';
import { mergeToken, statisticToken, useToken } from '../index';
@ -61,9 +61,13 @@ export default function genComponentStyleHook<ComponentName extends OverrideComp
}
// Generate style for all a tags in antd component.
useStyleRegister({ theme, token, hashId, path: ['Link'] }, () => ({
'&': genLinkStyle(token),
}));
useStyleRegister({ theme, token, hashId, path: ['Shared', rootPrefixCls] }, () => [
{
// Link
'&': genLinkStyle(token),
},
genFontStyle(token, rootPrefixCls),
]);
return [
useStyleRegister(