|
1 |
| -import '../../style/index.less'; |
2 |
| -import './index.less'; |
| 1 | +import type { CSSObject } from '../../_util/cssinjs'; |
| 2 | +import type { FullToken, GenerateStyle } from '../../theme/internal'; |
| 3 | +import { genComponentStyleHook, mergeToken } from '../../theme/internal'; |
| 4 | +import { resetComponent } from '../../_style'; |
| 5 | + |
| 6 | +interface StatisticToken extends FullToken<'Statistic'> { |
| 7 | + statisticTitleFontSize: number; |
| 8 | + statisticContentFontSize: number; |
| 9 | + statisticFontFamily: string; |
| 10 | +} |
| 11 | + |
| 12 | +const genStatisticStyle: GenerateStyle<StatisticToken> = (token: StatisticToken): CSSObject => { |
| 13 | + const { |
| 14 | + componentCls, |
| 15 | + marginXXS, |
| 16 | + padding, |
| 17 | + colorTextDescription, |
| 18 | + statisticTitleFontSize, |
| 19 | + colorTextHeading, |
| 20 | + statisticContentFontSize, |
| 21 | + statisticFontFamily, |
| 22 | + } = token; |
| 23 | + |
| 24 | + return { |
| 25 | + [`${componentCls}`]: { |
| 26 | + ...resetComponent(token), |
| 27 | + [`${componentCls}-title`]: { |
| 28 | + marginBottom: marginXXS, |
| 29 | + color: colorTextDescription, |
| 30 | + fontSize: statisticTitleFontSize, |
| 31 | + }, |
| 32 | + |
| 33 | + [`${componentCls}-skeleton`]: { |
| 34 | + paddingTop: padding, |
| 35 | + }, |
| 36 | + |
| 37 | + [`${componentCls}-content`]: { |
| 38 | + color: colorTextHeading, |
| 39 | + fontSize: statisticContentFontSize, |
| 40 | + fontFamily: statisticFontFamily, |
| 41 | + [`${componentCls}-content-value`]: { |
| 42 | + display: 'inline-block', |
| 43 | + direction: 'ltr', |
| 44 | + }, |
| 45 | + [`${componentCls}-content-prefix, ${componentCls}-content-suffix`]: { |
| 46 | + display: 'inline-block', |
| 47 | + }, |
| 48 | + [`${componentCls}-content-prefix`]: { |
| 49 | + marginInlineEnd: marginXXS, |
| 50 | + }, |
| 51 | + [`${componentCls}-content-suffix`]: { |
| 52 | + marginInlineStart: marginXXS, |
| 53 | + }, |
| 54 | + }, |
| 55 | + }, |
| 56 | + }; |
| 57 | +}; |
| 58 | + |
| 59 | +// ============================== Export ============================== |
| 60 | +export default genComponentStyleHook('Statistic', token => { |
| 61 | + const { fontSizeHeading3, fontSize, fontFamily } = token; |
| 62 | + |
| 63 | + const statisticToken = mergeToken<StatisticToken>(token, { |
| 64 | + statisticTitleFontSize: fontSize, |
| 65 | + statisticContentFontSize: fontSizeHeading3, |
| 66 | + statisticFontFamily: fontFamily, |
| 67 | + }); |
| 68 | + return [genStatisticStyle(statisticToken)]; |
| 69 | +}); |
0 commit comments