2022-05-09 22:20:07 +08:00
|
|
|
import type { CSSObject } from '@ant-design/cssinjs';
|
2023-05-04 15:37:10 +08:00
|
|
|
import { resetComponent } from '../../style';
|
2023-11-14 09:42:37 +08:00
|
|
|
import type { FullToken, GenerateStyle, GetDefaultToken } from '../../theme/internal';
|
2023-11-29 17:23:45 +08:00
|
|
|
import { genStyleHooks, mergeToken } from '../../theme/internal';
|
2020-10-23 10:09:31 +08:00
|
|
|
|
2023-05-04 15:37:10 +08:00
|
|
|
export interface ComponentToken {
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 标题字体大小
|
|
|
|
* @descEN Title font size
|
|
|
|
*/
|
2023-05-09 19:24:50 +08:00
|
|
|
titleFontSize: number;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 内容字体大小
|
|
|
|
* @descEN Content font size
|
|
|
|
*/
|
2023-05-09 19:24:50 +08:00
|
|
|
contentFontSize: number;
|
2022-03-16 12:02:52 +08:00
|
|
|
}
|
|
|
|
|
2023-05-04 15:37:10 +08:00
|
|
|
interface StatisticToken extends FullToken<'Statistic'> {}
|
|
|
|
|
2022-06-02 12:06:27 +08:00
|
|
|
const genStatisticStyle: GenerateStyle<StatisticToken> = (token: StatisticToken): CSSObject => {
|
|
|
|
const {
|
|
|
|
componentCls,
|
|
|
|
marginXXS,
|
|
|
|
padding,
|
2022-08-04 16:16:50 +08:00
|
|
|
colorTextDescription,
|
2023-05-09 19:24:50 +08:00
|
|
|
titleFontSize,
|
2022-06-02 12:06:27 +08:00
|
|
|
colorTextHeading,
|
2023-05-09 19:24:50 +08:00
|
|
|
contentFontSize,
|
|
|
|
fontFamily,
|
2022-06-02 12:06:27 +08:00
|
|
|
} = token;
|
|
|
|
|
|
|
|
return {
|
|
|
|
[`${componentCls}`]: {
|
|
|
|
...resetComponent(token),
|
|
|
|
[`${componentCls}-title`]: {
|
|
|
|
marginBottom: marginXXS,
|
2022-08-04 16:16:50 +08:00
|
|
|
color: colorTextDescription,
|
2023-05-09 19:24:50 +08:00
|
|
|
fontSize: titleFontSize,
|
2022-03-16 12:02:52 +08:00
|
|
|
},
|
2022-06-02 12:06:27 +08:00
|
|
|
|
|
|
|
[`${componentCls}-skeleton`]: {
|
|
|
|
paddingTop: padding,
|
2022-03-16 12:02:52 +08:00
|
|
|
},
|
2022-06-02 12:06:27 +08:00
|
|
|
|
|
|
|
[`${componentCls}-content`]: {
|
|
|
|
color: colorTextHeading,
|
2023-05-09 19:24:50 +08:00
|
|
|
fontSize: contentFontSize,
|
|
|
|
fontFamily,
|
2022-06-02 12:06:27 +08:00
|
|
|
[`${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,
|
|
|
|
},
|
2022-03-16 12:02:52 +08:00
|
|
|
},
|
|
|
|
},
|
2022-06-02 12:06:27 +08:00
|
|
|
};
|
|
|
|
};
|
2022-03-16 12:02:52 +08:00
|
|
|
|
|
|
|
// ============================== Export ==============================
|
2023-11-14 09:42:37 +08:00
|
|
|
export const prepareComponentToken: GetDefaultToken<'Statistic'> = (token) => {
|
|
|
|
const { fontSizeHeading3, fontSize } = token;
|
|
|
|
return {
|
|
|
|
titleFontSize: fontSize,
|
|
|
|
contentFontSize: fontSizeHeading3,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-11-29 17:23:45 +08:00
|
|
|
export default genStyleHooks(
|
2023-05-04 15:37:10 +08:00
|
|
|
'Statistic',
|
|
|
|
(token) => {
|
|
|
|
const statisticToken = mergeToken<StatisticToken>(token, {});
|
|
|
|
return [genStatisticStyle(statisticToken)];
|
|
|
|
},
|
2023-11-14 09:42:37 +08:00
|
|
|
prepareComponentToken,
|
2023-05-04 15:37:10 +08:00
|
|
|
);
|