ant-design/components/statistic/style/index.tsx

70 lines
2.0 KiB
TypeScript
Raw Normal View History

2022-05-09 22:20:07 +08:00
import type { CSSObject } from '@ant-design/cssinjs';
import type { FullToken, GenerateStyle } from '../../theme';
import { genComponentStyleHook, mergeToken } from '../../theme';
import { resetComponent } from '../../style';
interface StatisticToken extends FullToken<'Statistic'> {
statisticTitleFontSize: number;
statisticContentFontSize: number;
statisticFontFamily: string;
}
const genStatisticStyle: GenerateStyle<StatisticToken> = (token: StatisticToken): CSSObject => {
const {
componentCls,
marginXXS,
padding,
2022-08-04 16:16:50 +08:00
colorTextDescription,
statisticTitleFontSize,
colorTextHeading,
statisticContentFontSize,
statisticFontFamily,
} = token;
return {
[`${componentCls}`]: {
...resetComponent(token),
[`${componentCls}-title`]: {
marginBottom: marginXXS,
2022-08-04 16:16:50 +08:00
color: colorTextDescription,
fontSize: statisticTitleFontSize,
},
[`${componentCls}-skeleton`]: {
paddingTop: padding,
},
[`${componentCls}-content`]: {
color: colorTextHeading,
fontSize: statisticContentFontSize,
fontFamily: statisticFontFamily,
[`${componentCls}-content-value`]: {
display: 'inline-block',
direction: 'ltr',
},
[`${componentCls}-content-prefix, ${componentCls}-content-suffix`]: {
display: 'inline-block',
},
[`${componentCls}-content-prefix`]: {
marginInlineEnd: marginXXS,
},
[`${componentCls}-content-suffix`]: {
marginInlineStart: marginXXS,
},
},
},
};
};
// ============================== Export ==============================
export default genComponentStyleHook('Statistic', token => {
const { fontSizeHeading3, fontSize, fontFamily } = token;
const statisticToken = mergeToken<StatisticToken>(token, {
statisticTitleFontSize: fontSize,
statisticContentFontSize: fontSizeHeading3,
statisticFontFamily: fontFamily,
});
return [genStatisticStyle(statisticToken)];
});