docs: fix Skeleton style and demo layout (#38625)

* docs: fix skeleton demo style

* docs: update skeleton demo
This commit is contained in:
afc163 2022-11-17 18:49:41 +08:00 committed by GitHub
parent c6c35cc0ad
commit ac1e1c230b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 48 additions and 50 deletions

View File

@ -49,17 +49,17 @@ exports[`renders ./components/skeleton/demo/basic.tsx extend context correctly 1
`; `;
exports[`renders ./components/skeleton/demo/children.tsx extend context correctly 1`] = ` exports[`renders ./components/skeleton/demo/children.tsx extend context correctly 1`] = `
<div Array [
class="article" <h4
> style="margin-bottom:16px"
<div> >
<h4> Ant Design, a design language
Ant Design, a design language </h4>,
</h4> <p
<p> style="margin-bottom:16px"
We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure), to help people create their product prototypes beautifully and efficiently. >
</p> We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure), to help people create their product prototypes beautifully and efficiently.
</div> </p>,
<button <button
class="ant-btn ant-btn-default" class="ant-btn ant-btn-default"
type="button" type="button"
@ -67,8 +67,8 @@ exports[`renders ./components/skeleton/demo/children.tsx extend context correctl
<span> <span>
Show Skeleton Show Skeleton
</span> </span>
</button> </button>,
</div> ]
`; `;
exports[`renders ./components/skeleton/demo/complex.tsx extend context correctly 1`] = ` exports[`renders ./components/skeleton/demo/complex.tsx extend context correctly 1`] = `

View File

@ -49,17 +49,17 @@ exports[`renders ./components/skeleton/demo/basic.tsx correctly 1`] = `
`; `;
exports[`renders ./components/skeleton/demo/children.tsx correctly 1`] = ` exports[`renders ./components/skeleton/demo/children.tsx correctly 1`] = `
<div Array [
class="article" <h4
> style="margin-bottom:16px"
<div> >
<h4> Ant Design, a design language
Ant Design, a design language </h4>,
</h4> <p
<p> style="margin-bottom:16px"
We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure), to help people create their product prototypes beautifully and efficiently. >
</p> We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure), to help people create their product prototypes beautifully and efficiently.
</div> </p>,
<button <button
class="ant-btn ant-btn-default" class="ant-btn ant-btn-default"
type="button" type="button"
@ -67,8 +67,8 @@ exports[`renders ./components/skeleton/demo/children.tsx correctly 1`] = `
<span> <span>
Show Skeleton Show Skeleton
</span> </span>
</button> </button>,
</div> ]
`; `;
exports[`renders ./components/skeleton/demo/complex.tsx correctly 1`] = ` exports[`renders ./components/skeleton/demo/complex.tsx correctly 1`] = `

View File

@ -5,12 +5,3 @@
## en-US ## en-US
Skeleton contains sub component. Skeleton contains sub component.
<style>
.article h4 {
margin-bottom: 16px;
}
.article button {
margin-top: 16px;
}
</style>

View File

@ -13,21 +13,19 @@ const App: React.FC = () => {
}; };
return ( return (
<div className="article"> <>
<Skeleton loading={loading}> <Skeleton loading={loading}>
<div> <h4 style={{ marginBottom: 16 }}>Ant Design, a design language</h4>
<h4>Ant Design, a design language</h4> <p style={{ marginBottom: 16 }}>
<p> We supply a series of design principles, practical patterns and high quality design
We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure), to help people create their product prototypes beautifully
resources (Sketch and Axure), to help people create their product prototypes beautifully and efficiently.
and efficiently. </p>
</p>
</div>
</Skeleton> </Skeleton>
<Button onClick={showSkeleton} disabled={loading}> <Button onClick={showSkeleton} disabled={loading}>
Show Skeleton Show Skeleton
</Button> </Button>
</div> </>
); );
}; };

View File

@ -5,7 +5,7 @@ title: Skeleton
cover: https://gw.alipayobjects.com/zos/alicdn/KpcciCJgv/Skeleton.svg cover: https://gw.alipayobjects.com/zos/alicdn/KpcciCJgv/Skeleton.svg
--- ---
Provide a placeholder while you wait for content to load, or to visualise content that doesn't exist yet. Provide a placeholder while you wait for content to load, or to visualize content that doesn't exist yet.
## When To Use ## When To Use

View File

@ -95,12 +95,20 @@ const genSkeletonElementAvatar = (token: SkeletonToken): CSSObject => {
}; };
const genSkeletonElementInput = (token: SkeletonToken): CSSObject => { const genSkeletonElementInput = (token: SkeletonToken): CSSObject => {
const { controlHeight, skeletonInputCls, controlHeightLG, controlHeightSM, color } = token; const {
controlHeight,
borderRadiusSM,
skeletonInputCls,
controlHeightLG,
controlHeightSM,
color,
} = token;
return { return {
[`${skeletonInputCls}`]: { [`${skeletonInputCls}`]: {
display: 'inline-block', display: 'inline-block',
verticalAlign: 'top', verticalAlign: 'top',
background: color, background: color,
borderRadius: borderRadiusSM,
...genSkeletonElementInputSize(controlHeight), ...genSkeletonElementInputSize(controlHeight),
}, },
@ -120,7 +128,7 @@ const genSkeletonElementImageSize = (size: number): CSSObject => ({
}); });
const genSkeletonElementImage = (token: SkeletonToken): CSSObject => { const genSkeletonElementImage = (token: SkeletonToken): CSSObject => {
const { skeletonImageCls, imageSizeBase, color } = token; const { skeletonImageCls, imageSizeBase, color, borderRadiusSM } = token;
return { return {
[`${skeletonImageCls}`]: { [`${skeletonImageCls}`]: {
display: 'flex', display: 'flex',
@ -128,6 +136,7 @@ const genSkeletonElementImage = (token: SkeletonToken): CSSObject => {
justifyContent: 'center', justifyContent: 'center',
verticalAlign: 'top', verticalAlign: 'top',
background: color, background: color,
borderRadius: borderRadiusSM,
...genSkeletonElementImageSize(imageSizeBase * 2), ...genSkeletonElementImageSize(imageSizeBase * 2),
[`${skeletonImageCls}-path`]: { [`${skeletonImageCls}-path`]: {
fill: '#bfbfbf', fill: '#bfbfbf',
@ -347,7 +356,7 @@ const genBaseStyle: GenerateStyle<SkeletonToken> = (token: SkeletonToken) => {
// ============================== Export ============================== // ============================== Export ==============================
export default genComponentStyleHook( export default genComponentStyleHook(
'Skeleton', 'Skeleton',
token => { (token) => {
const { componentCls } = token; const { componentCls } = token;
const skeletonToken = mergeToken<SkeletonToken>(token, { const skeletonToken = mergeToken<SkeletonToken>(token, {
@ -368,7 +377,7 @@ export default genComponentStyleHook(
}); });
return [genBaseStyle(skeletonToken)]; return [genBaseStyle(skeletonToken)];
}, },
token => { (token) => {
const { colorFillContent, colorFill } = token; const { colorFillContent, colorFill } = token;
return { return {