2022-07-11 12:04:18 +08:00
|
|
|
import DotChartOutlined from '@ant-design/icons/DotChartOutlined';
|
|
|
|
import classNames from 'classnames';
|
2023-05-05 20:52:44 +08:00
|
|
|
import React from 'react';
|
2022-07-11 12:04:18 +08:00
|
|
|
import { ConfigContext } from '../config-provider';
|
|
|
|
import type { SkeletonElementProps } from './Element';
|
2023-01-20 11:03:50 +08:00
|
|
|
import useStyle from './style';
|
2022-07-11 12:04:18 +08:00
|
|
|
|
|
|
|
export interface SkeletonNodeProps extends Omit<SkeletonElementProps, 'size' | 'shape'> {
|
|
|
|
fullSize?: boolean;
|
|
|
|
children?: React.ReactNode;
|
|
|
|
}
|
|
|
|
|
2022-11-19 13:47:33 +08:00
|
|
|
const SkeletonNode: React.FC<SkeletonNodeProps> = (props) => {
|
2023-01-20 11:03:50 +08:00
|
|
|
const {
|
|
|
|
prefixCls: customizePrefixCls,
|
|
|
|
className,
|
|
|
|
rootClassName,
|
|
|
|
style,
|
|
|
|
active,
|
|
|
|
children,
|
|
|
|
} = props;
|
2022-07-11 12:04:18 +08:00
|
|
|
const { getPrefixCls } = React.useContext(ConfigContext);
|
|
|
|
const prefixCls = getPrefixCls('skeleton', customizePrefixCls);
|
2022-10-27 17:03:02 +08:00
|
|
|
const [wrapSSR, hashId] = useStyle(prefixCls);
|
2022-07-11 12:04:18 +08:00
|
|
|
|
|
|
|
const cls = classNames(
|
|
|
|
prefixCls,
|
|
|
|
`${prefixCls}-element`,
|
|
|
|
{
|
|
|
|
[`${prefixCls}-active`]: active,
|
|
|
|
},
|
2022-10-27 17:03:02 +08:00
|
|
|
hashId,
|
2022-07-11 12:04:18 +08:00
|
|
|
className,
|
2023-01-20 11:03:50 +08:00
|
|
|
rootClassName,
|
2022-07-11 12:04:18 +08:00
|
|
|
);
|
|
|
|
|
2022-09-27 09:57:36 +08:00
|
|
|
const content = children ?? <DotChartOutlined />;
|
2022-07-11 12:04:18 +08:00
|
|
|
|
2022-10-27 17:03:02 +08:00
|
|
|
return wrapSSR(
|
2022-07-11 12:04:18 +08:00
|
|
|
<div className={cls}>
|
|
|
|
<div className={classNames(`${prefixCls}-image`, className)} style={style}>
|
|
|
|
{content}
|
|
|
|
</div>
|
2022-10-27 17:03:02 +08:00
|
|
|
</div>,
|
2022-07-11 12:04:18 +08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default SkeletonNode;
|