2024-04-08 14:04:08 +08:00
|
|
|
import * as React from 'react';
|
2022-07-11 12:04:18 +08:00
|
|
|
import classNames from 'classnames';
|
2024-04-08 14:04:08 +08:00
|
|
|
|
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);
|
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,
|
|
|
|
},
|
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,
|
2023-12-14 14:58:53 +08:00
|
|
|
cssVarCls,
|
2022-07-11 12:04:18 +08:00
|
|
|
);
|
|
|
|
|
2023-11-13 20:18:37 +08:00
|
|
|
return wrapCSSVar(
|
2022-07-11 12:04:18 +08:00
|
|
|
<div className={cls}>
|
|
|
|
<div className={classNames(`${prefixCls}-image`, className)} style={style}>
|
2024-08-07 23:12:15 +08:00
|
|
|
{children}
|
2022-07-11 12:04:18 +08:00
|
|
|
</div>
|
2022-10-27 17:03:02 +08:00
|
|
|
</div>,
|
2022-07-11 12:04:18 +08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default SkeletonNode;
|