2022-03-16 12:02:52 +08:00
|
|
|
// deps-lint-skip-all
|
|
|
|
import { CSSObject } from '@ant-design/cssinjs';
|
|
|
|
import {
|
|
|
|
useStyleRegister,
|
|
|
|
useToken,
|
|
|
|
resetComponent,
|
|
|
|
GenerateStyle,
|
|
|
|
UseComponentStyleResult,
|
|
|
|
} from '../../_util/theme';
|
|
|
|
import type { DerivativeToken } from '../../_util/theme';
|
2020-10-23 10:09:31 +08:00
|
|
|
|
2022-03-16 12:02:52 +08:00
|
|
|
interface StatisticToken extends DerivativeToken {
|
|
|
|
statisticCls: string;
|
|
|
|
statisticTitleFontSize: number;
|
|
|
|
statisticContentFontSize: number;
|
|
|
|
statisticFontFamily: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
const genStatisticStyle: GenerateStyle<StatisticToken> = (token: StatisticToken): CSSObject => ({
|
|
|
|
[`${token.statisticCls}`]: {
|
|
|
|
...resetComponent(token),
|
|
|
|
[`${token.statisticCls}-title`]: {
|
|
|
|
marginBottom: token.marginXXS,
|
2022-03-22 13:26:29 +08:00
|
|
|
color: token.colorTextSecondary,
|
2022-03-16 12:02:52 +08:00
|
|
|
fontSize: token.statisticTitleFontSize,
|
|
|
|
},
|
|
|
|
[`${token.statisticCls}-content`]: {
|
2022-03-22 20:02:04 +08:00
|
|
|
color: token.colorTextHeading,
|
2022-03-16 12:02:52 +08:00
|
|
|
fontSize: token.statisticContentFontSize,
|
|
|
|
fontFamily: token.statisticFontFamily,
|
|
|
|
[`${token.statisticCls}-content-value`]: {
|
|
|
|
display: 'inline-block',
|
|
|
|
direction: 'ltr',
|
|
|
|
},
|
|
|
|
[`${token.statisticCls}-content-prefix, ${token.statisticCls}-content-suffix`]: {
|
|
|
|
display: 'inline-block',
|
|
|
|
},
|
|
|
|
[`${token.statisticCls}-content-prefix`]: {
|
|
|
|
marginInlineStart: 4, // FIXME: hard code
|
|
|
|
},
|
|
|
|
[`${token.statisticCls}-content-suffix`]: {
|
|
|
|
marginInlineEnd: 4, // FIXME: hard code
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
// ============================== Export ==============================
|
|
|
|
export default function useStyle(prefixCls: string): UseComponentStyleResult {
|
|
|
|
const [theme, token, hashId] = useToken();
|
|
|
|
|
|
|
|
const statisticToken: StatisticToken = {
|
|
|
|
...token,
|
|
|
|
statisticCls: `.${prefixCls}`,
|
|
|
|
statisticTitleFontSize: token.fontSize,
|
|
|
|
statisticContentFontSize: 24, // FIXME: hard code
|
|
|
|
statisticFontFamily: token.fontFamily,
|
|
|
|
};
|
|
|
|
|
|
|
|
return [
|
|
|
|
useStyleRegister({ theme, token, hashId, path: [prefixCls] }, () => [
|
|
|
|
genStatisticStyle(statisticToken),
|
|
|
|
]),
|
|
|
|
hashId,
|
|
|
|
];
|
|
|
|
}
|