2023-05-06 15:49:37 +08:00
|
|
|
import * as React from 'react';
|
2024-04-08 14:04:08 +08:00
|
|
|
import classNames from 'classnames';
|
|
|
|
|
2022-03-25 20:11:33 +08:00
|
|
|
import { ConfigContext } from '../config-provider';
|
2022-06-22 14:57:09 +08:00
|
|
|
import type { SkeletonElementProps } from './Element';
|
2022-03-29 20:55:44 +08:00
|
|
|
import useStyle from './style';
|
2020-06-28 22:41:59 +08:00
|
|
|
|
2022-07-10 12:05:35 +08:00
|
|
|
export interface SkeletonImageProps extends Omit<SkeletonElementProps, 'size' | 'shape'> {}
|
2020-06-28 22:41:59 +08:00
|
|
|
|
|
|
|
const path =
|
|
|
|
'M365.714286 329.142857q0 45.714286-32.036571 77.677714t-77.677714 32.036571-77.677714-32.036571-32.036571-77.677714 32.036571-77.677714 77.677714-32.036571 77.677714 32.036571 32.036571 77.677714zM950.857143 548.571429l0 256-804.571429 0 0-109.714286 182.857143-182.857143 91.428571 91.428571 292.571429-292.571429zM1005.714286 146.285714l-914.285714 0q-7.460571 0-12.873143 5.412571t-5.412571 12.873143l0 694.857143q0 7.460571 5.412571 12.873143t12.873143 5.412571l914.285714 0q7.460571 0 12.873143-5.412571t5.412571-12.873143l0-694.857143q0-7.460571-5.412571-12.873143t-12.873143-5.412571zM1097.142857 164.571429l0 694.857143q0 37.741714-26.843429 64.585143t-64.585143 26.843429l-914.285714 0q-37.741714 0-64.585143-26.843429t-26.843429-64.585143l0-694.857143q0-37.741714 26.843429-64.585143t64.585143-26.843429l914.285714 0q37.741714 0 64.585143 26.843429t26.843429 64.585143z';
|
|
|
|
|
2022-11-19 13:47:33 +08:00
|
|
|
const SkeletonImage: React.FC<SkeletonImageProps> = (props) => {
|
2023-01-20 11:03:50 +08:00
|
|
|
const { prefixCls: customizePrefixCls, className, rootClassName, style, active } = props;
|
2022-03-25 20:11:33 +08:00
|
|
|
const { getPrefixCls } = React.useContext(ConfigContext);
|
|
|
|
const prefixCls = getPrefixCls('skeleton', customizePrefixCls);
|
2023-12-14 14:58:53 +08:00
|
|
|
const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);
|
2022-07-11 12:04:18 +08:00
|
|
|
const cls = classNames(
|
|
|
|
prefixCls,
|
|
|
|
`${prefixCls}-element`,
|
|
|
|
{
|
|
|
|
[`${prefixCls}-active`]: active,
|
|
|
|
},
|
|
|
|
className,
|
2023-01-20 11:03:50 +08:00
|
|
|
rootClassName,
|
2022-07-12 17:09:43 +08:00
|
|
|
hashId,
|
2023-12-14 14:58:53 +08:00
|
|
|
cssVarCls,
|
2022-07-11 12:04:18 +08:00
|
|
|
);
|
2020-06-28 22:41:59 +08:00
|
|
|
|
2023-11-13 20:18:37 +08:00
|
|
|
return wrapCSSVar(
|
2022-03-25 20:11:33 +08:00
|
|
|
<div className={cls}>
|
|
|
|
<div className={classNames(`${prefixCls}-image`, className)} style={style}>
|
|
|
|
<svg
|
|
|
|
viewBox="0 0 1098 1024"
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
className={`${prefixCls}-image-svg`}
|
|
|
|
>
|
2024-06-22 21:59:12 +08:00
|
|
|
<title>Image placeholder</title>
|
2022-03-25 20:11:33 +08:00
|
|
|
<path d={path} className={`${prefixCls}-image-path`} />
|
|
|
|
</svg>
|
2020-06-28 22:41:59 +08:00
|
|
|
</div>
|
2022-03-29 20:55:44 +08:00
|
|
|
</div>,
|
2022-03-25 20:11:33 +08:00
|
|
|
);
|
2020-06-28 22:41:59 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
export default SkeletonImage;
|