fix: Skeleton missing style (#33405)

This commit is contained in:
二货机器人 2021-12-24 14:23:32 +08:00 committed by GitHub
parent 0edf04253e
commit 9c086c5328
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 1 deletions

View File

@ -17,6 +17,7 @@ export interface SkeletonProps {
loading?: boolean; loading?: boolean;
prefixCls?: string; prefixCls?: string;
className?: string; className?: string;
style?: React.CSSProperties;
children?: React.ReactNode; children?: React.ReactNode;
avatar?: SkeletonAvatarProps | boolean; avatar?: SkeletonAvatarProps | boolean;
title?: SkeletonTitleProps | boolean; title?: SkeletonTitleProps | boolean;
@ -76,6 +77,7 @@ const Skeleton = (props: SkeletonProps) => {
prefixCls: customizePrefixCls, prefixCls: customizePrefixCls,
loading, loading,
className, className,
style,
children, children,
avatar, avatar,
title, title,
@ -153,7 +155,7 @@ const Skeleton = (props: SkeletonProps) => {
); );
return ( return (
<div className={cls}> <div className={cls} style={style}>
{avatarNode} {avatarNode}
{contentNode} {contentNode}
</div> </div>

View File

@ -526,6 +526,31 @@ exports[`Skeleton should square avatar 1`] = `
</div> </div>
`; `;
exports[`Skeleton should support style 1`] = `
<div
class="ant-skeleton"
style="background: blue;"
>
<div
class="ant-skeleton-content"
>
<h3
class="ant-skeleton-title"
style="width: 38%;"
/>
<ul
class="ant-skeleton-paragraph"
>
<li />
<li />
<li
style="width: 61%;"
/>
</ul>
</div>
</div>
`;
exports[`Skeleton should without avatar and paragraph 1`] = ` exports[`Skeleton should without avatar and paragraph 1`] = `
<div <div
class="ant-skeleton" class="ant-skeleton"

View File

@ -147,4 +147,9 @@ describe('Skeleton', () => {
expect(wrapper.render()).toMatchSnapshot(); expect(wrapper.render()).toMatchSnapshot();
}); });
}); });
it('should support style', () => {
const wrapper = genSkeleton({ style: { background: 'blue' } });
expect(wrapper.render()).toMatchSnapshot();
});
}); });