|
|
|
// deps-lint-skip-all
|
|
|
|
import type { CSSObject } from '@ant-design/cssinjs';
|
|
|
|
import { Keyframes } from '@ant-design/cssinjs';
|
|
|
|
|
|
|
|
import { TinyColor } from '@ctrl/tinycolor';
|
|
|
|
import type { FullToken, GenerateStyle } from '../../_util/theme';
|
|
|
|
import { genComponentStyleHook, mergeToken } from '../../_util/theme';
|
|
|
|
|
|
|
|
export type ComponentToken = {
|
|
|
|
color: string;
|
|
|
|
colorGradientEnd: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
const skeletonClsLoading = new Keyframes(`ant-skeleton-loading`, {
|
|
|
|
'0%': {
|
|
|
|
transform: 'translateX(-37.5%)',
|
|
|
|
},
|
|
|
|
'100%': {
|
|
|
|
transform: 'translateX(37.5%)',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
interface SkeletonToken extends FullToken<'Skeleton'> {
|
|
|
|
skeletonAvatarCls: string;
|
|
|
|
skeletonTitleCls: string;
|
|
|
|
skeletonParagraphCls: string;
|
|
|
|
skeletonButtonCls: string;
|
|
|
|
skeletonInputCls: string;
|
|
|
|
skeletonImageCls: string;
|
|
|
|
imageSizeBase: number;
|
|
|
|
skeletonTitleHeight: number;
|
|
|
|
skeletonBlockRadius: number;
|
|
|
|
skeletonParagraphLineHeight: number;
|
|
|
|
skeletonParagraphMarginTop: number;
|
|
|
|
skeletonLoadingBackground: string;
|
|
|
|
skeletonLoadingMotionDuration: string;
|
|
|
|
borderRadius: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
const genSkeletonElementCommonSize = (size: number): CSSObject => ({
|
|
|
|
height: size,
|
|
|
|
lineHeight: `${size}px`,
|
|
|
|
});
|
|
|
|
|
|
|
|
const genSkeletonElementAvatarSize = (size: number): CSSObject => ({
|
|
|
|
width: size,
|
|
|
|
...genSkeletonElementCommonSize(size),
|
|
|
|
});
|
|
|
|
|
|
|
|
const genSkeletonColor = (token: SkeletonToken): CSSObject => ({
|
|
|
|
position: 'relative',
|
|
|
|
overflow: 'hidden',
|
|
|
|
background: 'transparent',
|
|
|
|
'&::after': {
|
|
|
|
position: 'absolute',
|
|
|
|
top: 0,
|
|
|
|
insetInlineEnd: '-150%',
|
|
|
|
bottom: 0,
|
|
|
|
insetInlineStart: '-150%',
|
|
|
|
background: token.skeletonLoadingBackground,
|
|
|
|
animationName: skeletonClsLoading,
|
|
|
|
animationDuration: token.skeletonLoadingMotionDuration,
|
|
|
|
animationTimingFunction: 'ease',
|
|
|
|
animationIterationCount: 'infinite',
|
|
|
|
content: '""',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const genSkeletonElementInputSize = (size: number): CSSObject => ({
|
|
|
|
width: size * 5,
|
|
|
|
minWidth: size * 5,
|
|
|
|
...genSkeletonElementCommonSize(size),
|
|
|
|
});
|
|
|
|
|
|
|
|
const genSkeletonElementAvatar = (token: SkeletonToken): CSSObject => {
|
|
|
|
const { skeletonAvatarCls, color, controlHeight, controlHeightLG, controlHeightSM } = token;
|
|
|
|
return {
|
|
|
|
[`${skeletonAvatarCls}`]: {
|
|
|
|
display: 'inline-block',
|
|
|
|
verticalAlign: 'top',
|
|
|
|
background: color,
|
|
|
|
...genSkeletonElementAvatarSize(controlHeight),
|
|
|
|
},
|
|
|
|
[`${skeletonAvatarCls}${skeletonAvatarCls}-circle`]: {
|
|
|
|
borderRadius: '50%',
|
|
|
|
},
|
|
|
|
[`${skeletonAvatarCls}${skeletonAvatarCls}-lg`]: {
|
|
|
|
...genSkeletonElementAvatarSize(controlHeightLG),
|
|
|
|
},
|
|
|
|
[`${skeletonAvatarCls}${skeletonAvatarCls}-sm`]: {
|
|
|
|
...genSkeletonElementAvatarSize(controlHeightSM),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const genSkeletonElementInput = (token: SkeletonToken): CSSObject => {
|
|
|
|
const { controlHeight, skeletonInputCls, controlHeightLG, controlHeightSM, color } = token;
|
|
|
|
return {
|
|
|
|
[`${skeletonInputCls}`]: {
|
|
|
|
display: 'inline-block',
|
|
|
|
verticalAlign: 'top',
|
|
|
|
background: color,
|
|
|
|
...genSkeletonElementInputSize(controlHeight),
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${skeletonInputCls}-lg`]: {
|
|
|
|
...genSkeletonElementInputSize(controlHeightLG),
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${skeletonInputCls}-sm`]: {
|
|
|
|
...genSkeletonElementInputSize(controlHeightSM),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const genSkeletonElementImageSize = (size: number): CSSObject => ({
|
|
|
|
|