2022-05-09 22:20:07 +08:00
|
|
|
|
import type { CSSObject } from '@ant-design/cssinjs';
|
2024-04-08 14:04:08 +08:00
|
|
|
|
|
2022-11-23 20:22:38 +08:00
|
|
|
|
import type { FullToken, GenerateStyle } from '../../theme/internal';
|
2023-11-29 17:23:45 +08:00
|
|
|
|
import { genStyleHooks, mergeToken } from '../../theme/internal';
|
2022-04-02 18:17:14 +08:00
|
|
|
|
|
|
|
|
|
/** Component only token. Which will handle additional calculation of alias token */
|
2024-06-22 21:59:12 +08:00
|
|
|
|
// biome-ignore lint/suspicious/noEmptyInterface: ComponentToken need to be empty by default
|
2022-04-02 18:17:14 +08:00
|
|
|
|
export interface ComponentToken {}
|
|
|
|
|
|
2022-05-17 18:39:13 +08:00
|
|
|
|
interface EmptyToken extends FullToken<'Empty'> {
|
2022-04-02 18:17:14 +08:00
|
|
|
|
emptyImgCls: string;
|
2023-11-13 14:13:17 +08:00
|
|
|
|
emptyImgHeight: number | string;
|
|
|
|
|
emptyImgHeightSM: number | string;
|
2024-07-12 10:12:56 +08:00
|
|
|
|
emptyImgHeightMD: number;
|
2022-04-02 18:17:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ============================== Shared ==============================
|
|
|
|
|
const genSharedEmptyStyle: GenerateStyle<EmptyToken> = (token): CSSObject => {
|
2022-11-01 15:06:38 +08:00
|
|
|
|
const { componentCls, margin, marginXS, marginXL, fontSize, lineHeight } = token;
|
2022-04-02 18:17:14 +08:00
|
|
|
|
|
|
|
|
|
return {
|
2022-05-17 18:39:13 +08:00
|
|
|
|
[componentCls]: {
|
2022-05-18 15:37:27 +08:00
|
|
|
|
marginInline: marginXS,
|
2022-11-01 15:06:38 +08:00
|
|
|
|
fontSize,
|
2022-05-18 15:37:27 +08:00
|
|
|
|
lineHeight,
|
2022-04-02 18:17:14 +08:00
|
|
|
|
textAlign: 'center',
|
|
|
|
|
|
2024-07-26 16:40:48 +08:00
|
|
|
|
// 原来 &-image 没有父子结构,现在为了外层承担我们的 hashId,改成父子结构
|
2022-05-17 18:39:13 +08:00
|
|
|
|
[`${componentCls}-image`]: {
|
2022-05-18 15:37:27 +08:00
|
|
|
|
height: token.emptyImgHeight,
|
|
|
|
|
marginBottom: marginXS,
|
2022-06-17 18:47:47 +08:00
|
|
|
|
opacity: token.opacityImage,
|
2022-04-02 18:17:14 +08:00
|
|
|
|
|
|
|
|
|
img: {
|
|
|
|
|
height: '100%',
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
svg: {
|
2023-04-10 13:11:34 +08:00
|
|
|
|
maxWidth: '100%',
|
2022-04-02 18:17:14 +08:00
|
|
|
|
height: '100%',
|
|
|
|
|
margin: 'auto',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
2023-02-07 12:22:44 +08:00
|
|
|
|
[`${componentCls}-description`]: {
|
2024-06-14 11:58:52 +08:00
|
|
|
|
color: token.colorTextDescription,
|
2023-02-07 12:22:44 +08:00
|
|
|
|
},
|
|
|
|
|
|
2024-07-26 16:40:48 +08:00
|
|
|
|
// 原来 &-footer 没有父子结构,现在为了外层承担我们的 hashId,改成父子结构
|
2022-05-17 18:39:13 +08:00
|
|
|
|
[`${componentCls}-footer`]: {
|
2022-05-18 15:37:27 +08:00
|
|
|
|
marginTop: margin,
|
2022-04-02 18:17:14 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
'&-normal': {
|
2022-05-18 15:37:27 +08:00
|
|
|
|
marginBlock: marginXL,
|
2024-03-16 22:05:59 +08:00
|
|
|
|
color: token.colorTextDescription,
|
2022-04-02 18:17:14 +08:00
|
|
|
|
|
2023-02-07 12:22:44 +08:00
|
|
|
|
[`${componentCls}-description`]: {
|
2024-03-16 22:05:59 +08:00
|
|
|
|
color: token.colorTextDescription,
|
2023-02-07 12:22:44 +08:00
|
|
|
|
},
|
|
|
|
|
|
2022-05-17 18:39:13 +08:00
|
|
|
|
[`${componentCls}-image`]: {
|
2022-05-18 15:37:27 +08:00
|
|
|
|
height: token.emptyImgHeightMD,
|
2022-04-02 18:17:14 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
'&-small': {
|
2022-05-18 15:37:27 +08:00
|
|
|
|
marginBlock: marginXS,
|
2024-03-16 22:05:59 +08:00
|
|
|
|
color: token.colorTextDescription,
|
2022-04-02 18:17:14 +08:00
|
|
|
|
|
2022-05-17 18:39:13 +08:00
|
|
|
|
[`${componentCls}-image`]: {
|
2022-05-18 15:37:27 +08:00
|
|
|
|
height: token.emptyImgHeightSM,
|
2022-04-02 18:17:14 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// ============================== Export ==============================
|
2023-11-29 17:23:45 +08:00
|
|
|
|
export default genStyleHooks('Empty', (token) => {
|
2023-11-13 14:13:17 +08:00
|
|
|
|
const { componentCls, controlHeightLG, calc } = token;
|
2022-05-18 15:37:27 +08:00
|
|
|
|
|
|
|
|
|
const emptyToken: EmptyToken = mergeToken<EmptyToken>(token, {
|
|
|
|
|
emptyImgCls: `${componentCls}-img`,
|
2023-11-13 14:13:17 +08:00
|
|
|
|
emptyImgHeight: calc(controlHeightLG).mul(2.5).equal(),
|
2022-05-18 15:37:27 +08:00
|
|
|
|
emptyImgHeightMD: controlHeightLG,
|
2023-11-13 14:13:17 +08:00
|
|
|
|
emptyImgHeightSM: calc(controlHeightLG).mul(0.875).equal(),
|
2022-05-18 15:37:27 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return [genSharedEmptyStyle(emptyToken)];
|
2022-05-17 18:39:13 +08:00
|
|
|
|
});
|