|
|
@ -4,8 +4,16 @@ import type { FullToken, GenerateStyle } from '../../theme/internal'; |
|
|
|
import { genComponentStyleHook, mergeToken } from '../../theme/internal'; |
|
|
|
|
|
|
|
export type ComponentToken = { |
|
|
|
/** @deprecated use gradientFromColor instead. */ |
|
|
|
color: string; |
|
|
|
/** @deprecated use gradientToColor instead. */ |
|
|
|
colorGradientEnd: string; |
|
|
|
gradientFromColor: string; |
|
|
|
gradientToColor: string; |
|
|
|
titleHeight: number; |
|
|
|
blockRadius: number; |
|
|
|
paragraphMarginTop: number; |
|
|
|
paragraphLiHeight: number; |
|
|
|
}; |
|
|
|
|
|
|
|
const skeletonClsLoading = new Keyframes(`ant-skeleton-loading`, { |
|
|
@ -25,10 +33,6 @@ interface SkeletonToken extends FullToken<'Skeleton'> { |
|
|
|
skeletonInputCls: string; |
|
|
|
skeletonImageCls: string; |
|
|
|
imageSizeBase: number; |
|
|
|
skeletonTitleHeight: number; |
|
|
|
skeletonBlockRadius: number; |
|
|
|
skeletonParagraphLineHeight: number; |
|
|
|
skeletonParagraphMarginTop: number; |
|
|
|
skeletonLoadingBackground: string; |
|
|
|
skeletonLoadingMotionDuration: string; |
|
|
|
borderRadius: number; |
|
|
@ -60,12 +64,13 @@ const genSkeletonElementInputSize = (size: number): CSSObject => ({ |
|
|
|
}); |
|
|
|
|
|
|
|
const genSkeletonElementAvatar = (token: SkeletonToken): CSSObject => { |
|
|
|
const { skeletonAvatarCls, color, controlHeight, controlHeightLG, controlHeightSM } = token; |
|
|
|
const { skeletonAvatarCls, gradientFromColor, controlHeight, controlHeightLG, controlHeightSM } = |
|
|
|
token; |
|
|
|
return { |
|
|
|
[`${skeletonAvatarCls}`]: { |
|
|
|
display: 'inline-block', |
|
|
|
verticalAlign: 'top', |
|
|
|
background: color, |
|
|
|
background: gradientFromColor, |
|
|
|
...genSkeletonElementAvatarSize(controlHeight), |
|
|
|
}, |
|
|
|
[`${skeletonAvatarCls}${skeletonAvatarCls}-circle`]: { |
|
|
@ -87,13 +92,13 @@ const genSkeletonElementInput = (token: SkeletonToken): CSSObject => { |
|
|
|
skeletonInputCls, |
|
|
|
controlHeightLG, |
|
|
|
controlHeightSM, |
|
|
|
color, |
|
|
|
gradientFromColor, |
|
|
|
} = token; |
|
|
|
return { |
|
|
|
[`${skeletonInputCls}`]: { |
|
|
|
display: 'inline-block', |
|
|
|
verticalAlign: 'top', |
|
|
|
background: color, |
|
|
|
background: gradientFromColor, |
|
|
|
borderRadius: borderRadiusSM, |
|
|
|
...genSkeletonElementInputSize(controlHeight), |
|
|
|
}, |
|
|
@ -114,14 +119,14 @@ const genSkeletonElementImageSize = (size: number): CSSObject => ({ |
|
|
|
}); |
|
|
|
|
|
|
|
const genSkeletonElementImage = (token: SkeletonToken): CSSObject => { |
|
|
|
const { skeletonImageCls, imageSizeBase, color, borderRadiusSM } = token; |
|
|
|
const { skeletonImageCls, imageSizeBase, gradientFromColor, borderRadiusSM } = token; |
|
|
|
return { |
|
|
|
[`${skeletonImageCls}`]: { |
|
|
|
display: 'flex', |
|
|
|
alignItems: 'center', |
|
|
|
justifyContent: 'center', |
|
|
|
verticalAlign: 'top', |
|
|
|
background: color, |
|
|
|
background: gradientFromColor, |
|
|
|
borderRadius: borderRadiusSM, |
|
|
|
...genSkeletonElementImageSize(imageSizeBase * 2), |
|
|
|
[`${skeletonImageCls}-path`]: { |
|
|
@ -172,13 +177,13 @@ const genSkeletonElementButton = (token: SkeletonToken): CSSObject => { |
|
|
|
controlHeight, |
|
|
|
controlHeightLG, |
|
|
|
controlHeightSM, |
|
|
|
color, |
|
|
|
gradientFromColor, |
|
|
|
} = token; |
|
|
|
return { |
|
|
|
[`${skeletonButtonCls}`]: { |
|
|
|
display: 'inline-block', |
|
|
|
verticalAlign: 'top', |
|
|
|
background: color, |
|
|
|
background: gradientFromColor, |
|
|
|
borderRadius: borderRadiusSM, |
|
|
|
width: controlHeight * 2, |
|
|
|
minWidth: controlHeight * 2, |
|
|
@ -211,15 +216,15 @@ const genBaseStyle: GenerateStyle<SkeletonToken> = (token: SkeletonToken) => { |
|
|
|
controlHeight, |
|
|
|
controlHeightLG, |
|
|
|
controlHeightSM, |
|
|
|
color, |
|
|
|
gradientFromColor, |
|
|
|
padding, |
|
|
|
marginSM, |
|
|
|
borderRadius, |
|
|
|
skeletonTitleHeight, |
|
|
|
skeletonBlockRadius, |
|
|
|
skeletonParagraphLineHeight, |
|
|
|
titleHeight, |
|
|
|
blockRadius, |
|
|
|
paragraphLiHeight, |
|
|
|
controlHeightXS, |
|
|
|
skeletonParagraphMarginTop, |
|
|
|
paragraphMarginTop, |
|
|
|
} = token; |
|
|
|
|
|
|
|
return { |
|
|
@ -236,7 +241,7 @@ const genBaseStyle: GenerateStyle<SkeletonToken> = (token: SkeletonToken) => { |
|
|
|
[`${skeletonAvatarCls}`]: { |
|
|
|
display: 'inline-block', |
|
|
|
verticalAlign: 'top', |
|
|
|
background: color, |
|
|
|
background: gradientFromColor, |
|
|
|
...genSkeletonElementAvatarSize(controlHeight), |
|
|
|
}, |
|
|
|
[`${skeletonAvatarCls}-circle`]: { |
|
|
@ -257,9 +262,9 @@ const genBaseStyle: GenerateStyle<SkeletonToken> = (token: SkeletonToken) => { |
|
|
|
// Title
|
|
|
|
[`${skeletonTitleCls}`]: { |
|
|
|
width: '100%', |
|
|
|
height: skeletonTitleHeight, |
|
|
|
background: color, |
|
|
|
borderRadius: skeletonBlockRadius, |
|
|
|
height: titleHeight, |
|
|
|
background: gradientFromColor, |
|
|
|
borderRadius: blockRadius, |
|
|
|
[`+ ${skeletonParagraphCls}`]: { |
|
|
|
marginBlockStart: controlHeightSM, |
|
|
|
}, |
|
|
@ -270,10 +275,10 @@ const genBaseStyle: GenerateStyle<SkeletonToken> = (token: SkeletonToken) => { |
|
|
|
padding: 0, |
|
|
|
'> li': { |
|
|
|
width: '100%', |
|
|
|
height: skeletonParagraphLineHeight, |
|
|
|
height: paragraphLiHeight, |
|
|
|
listStyle: 'none', |
|
|
|
background: color, |
|
|
|
borderRadius: skeletonBlockRadius, |
|
|
|
background: gradientFromColor, |
|
|
|
borderRadius: blockRadius, |
|
|
|
'+ li': { |
|
|
|
marginBlockStart: controlHeightXS, |
|
|
|
}, |
|
|
@ -297,7 +302,7 @@ const genBaseStyle: GenerateStyle<SkeletonToken> = (token: SkeletonToken) => { |
|
|
|
marginBlockStart: marginSM, |
|
|
|
|
|
|
|
[`+ ${skeletonParagraphCls}`]: { |
|
|
|
marginBlockStart: skeletonParagraphMarginTop, |
|
|
|
marginBlockStart: paragraphMarginTop, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -353,22 +358,31 @@ export default genComponentStyleHook( |
|
|
|
skeletonInputCls: `${componentCls}-input`, |
|
|
|
skeletonImageCls: `${componentCls}-image`, |
|
|
|
imageSizeBase: token.controlHeight * 1.5, |
|
|
|
skeletonTitleHeight: token.controlHeight / 2, |
|
|
|
skeletonBlockRadius: token.borderRadiusSM, |
|
|
|
skeletonParagraphLineHeight: token.controlHeight / 2, |
|
|
|
skeletonParagraphMarginTop: token.marginLG + token.marginXXS, |
|
|
|
borderRadius: 100, // Large number to make capsule shape
|
|
|
|
skeletonLoadingBackground: `linear-gradient(90deg, ${token.color} 25%, ${token.colorGradientEnd} 37%, ${token.color} 63%)`, |
|
|
|
skeletonLoadingBackground: `linear-gradient(90deg, ${token.gradientFromColor} 25%, ${token.gradientToColor} 37%, ${token.gradientFromColor} 63%)`, |
|
|
|
skeletonLoadingMotionDuration: '1.4s', |
|
|
|
}); |
|
|
|
return [genBaseStyle(skeletonToken)]; |
|
|
|
}, |
|
|
|
(token) => { |
|
|
|
const { colorFillContent, colorFill } = token; |
|
|
|
|
|
|
|
const gradientFromColor = colorFillContent; |
|
|
|
const gradientToColor = colorFill; |
|
|
|
return { |
|
|
|
color: colorFillContent, |
|
|
|
colorGradientEnd: colorFill, |
|
|
|
color: gradientFromColor, |
|
|
|
colorGradientEnd: gradientToColor, |
|
|
|
gradientFromColor, |
|
|
|
gradientToColor, |
|
|
|
titleHeight: token.controlHeight / 2, |
|
|
|
blockRadius: token.borderRadiusSM, |
|
|
|
paragraphMarginTop: token.marginLG + token.marginXXS, |
|
|
|
paragraphLiHeight: token.controlHeight / 2, |
|
|
|
}; |
|
|
|
}, |
|
|
|
{ |
|
|
|
deprecatedTokens: [ |
|
|
|
['color', 'gradientFromColor'], |
|
|
|
['colorGradientEnd', 'gradientToColor'], |
|
|
|
], |
|
|
|
}, |
|
|
|
); |
|
|
|