From bade7ca80989b8d2fa97d0f290132713f80330fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=A0=E5=A3=B0?= Date: Wed, 13 Oct 2021 17:00:50 +0800 Subject: [PATCH 01/17] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- devui/skeleton/src/skeleton.scss | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/devui/skeleton/src/skeleton.scss b/devui/skeleton/src/skeleton.scss index 74508318..17ad0751 100644 --- a/devui/skeleton/src/skeleton.scss +++ b/devui/skeleton/src/skeleton.scss @@ -1,3 +1,5 @@ +@import '../../styles-var/devui-var.scss'; + .devui-skeleton { display: flex; justify-content: space-between; @@ -10,7 +12,7 @@ .avatar { width: 40px; height: 40px; - background-color: #cccccc; + background-color: #f2f2f2; border-radius: 50%; } } @@ -21,7 +23,7 @@ .devui-skeleton__item { width: 100%; height: 16px; - background-color: #cccccc; + background-color: #f2f2f2; display: inline-block; border-radius: 4px; } @@ -45,7 +47,7 @@ rgba(255, 255, 255, 0.5) 50%, rgba(255, 255, 255, 0) 60% ) - #cccccc; + #f2f2f2; background-size: 200% 100%; background-position-x: 180%; animation: 2s loading ease-in-out infinite; -- Gitee From af83c8fc802cb6a986ce9a7bd56cf1aea88e96f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=A0=E5=A3=B0?= Date: Wed, 13 Oct 2021 17:39:35 +0800 Subject: [PATCH 02/17] =?UTF-8?q?refactor:=20=E6=9F=AF=E9=87=8C=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- devui/skeleton/src/skeleton.tsx | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/devui/skeleton/src/skeleton.tsx b/devui/skeleton/src/skeleton.tsx index 1939a776..654bc0b1 100644 --- a/devui/skeleton/src/skeleton.tsx +++ b/devui/skeleton/src/skeleton.tsx @@ -8,22 +8,33 @@ export default defineComponent({ props: skeletonProps, setup(props: SkeletonProps, ctx) { const { slots } = ctx; - const arr = [] - for (let index = 0; index < props.row; index++) { - arr.push(1) + + function renderAnimate(bool) { + return bool ? 'devui-skeleton-animated' : '' + } + function renderAvatar(bool) { + return bool ?
: '' } + function renderParagraph(num) { + const arr = [] + for (let index = 0; index < num; index++) { + arr.push(1) + } + return
{ + arr.map(() => { + return
+ }) + }
+ } + return () => { if (props.loading) { - return
- {props.avatar ?
: null} -
{ - arr.map(() => { - return
- }) - }
+ return
+ {renderAvatar(props.avatar)} + {renderParagraph(props.row)}
} - return
{slots.default?.()} + return
{slots.default?.()}
} } -- Gitee From 38ff71e5312bd8dc782e38fc84f9a0a7a4128c06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=A0=E5=A3=B0?= Date: Wed, 13 Oct 2021 22:48:55 +0800 Subject: [PATCH 03/17] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- devui/skeleton/src/skeleton-types.ts | 4 +- devui/skeleton/src/skeleton.scss | 2 +- devui/skeleton/src/skeleton.tsx | 21 ++++++----- docs/components/skeleton/index.md | 55 ++++++++++++++++------------ 4 files changed, 46 insertions(+), 36 deletions(-) diff --git a/devui/skeleton/src/skeleton-types.ts b/devui/skeleton/src/skeleton-types.ts index 5774b491..15d79005 100644 --- a/devui/skeleton/src/skeleton-types.ts +++ b/devui/skeleton/src/skeleton-types.ts @@ -2,8 +2,8 @@ import type { ExtractPropTypes } from 'vue' export const skeletonProps = { row: { - type: Number || String, - default: 0 + type: Number, + required: true }, animate:{ type: Boolean, diff --git a/devui/skeleton/src/skeleton.scss b/devui/skeleton/src/skeleton.scss index 17ad0751..bdce0a9a 100644 --- a/devui/skeleton/src/skeleton.scss +++ b/devui/skeleton/src/skeleton.scss @@ -39,7 +39,7 @@ } .devui-skeleton-animated > .devui-skeleton__avatar > .avatar, -.devui-skeleton-animated > .devui-skeleton__item__group > .devui-skeleton__item { +.devui-skeleton-animated > .devui-skeleton__item__group > div > .devui-skeleton__item { background: linear-gradient( 100deg, diff --git a/devui/skeleton/src/skeleton.tsx b/devui/skeleton/src/skeleton.tsx index 654bc0b1..0d06a5ec 100644 --- a/devui/skeleton/src/skeleton.tsx +++ b/devui/skeleton/src/skeleton.tsx @@ -9,18 +9,15 @@ export default defineComponent({ setup(props: SkeletonProps, ctx) { const { slots } = ctx; - function renderAnimate(bool) { - return bool ? 'devui-skeleton-animated' : '' + function renderAnimate(isAnimate) { + return isAnimate ? 'devui-skeleton-animated' : '' } - function renderAvatar(bool) { - return bool ?
: '' - } - function renderParagraph(num) { + function renderParagraph(paragraphRowNum) { const arr = [] - for (let index = 0; index < num; index++) { + for (let index = 0; index < paragraphRowNum; index++) { arr.push(1) } - return
{ + return
{ arr.map(() => { return
}) @@ -30,8 +27,12 @@ export default defineComponent({ return () => { if (props.loading) { return
- {renderAvatar(props.avatar)} - {renderParagraph(props.row)} +
+
+
+
+ {renderParagraph(props.row)} +
} return
{slots.default?.()} diff --git a/docs/components/skeleton/index.md b/docs/components/skeleton/index.md index f4d8d530..ab0ba0d8 100644 --- a/docs/components/skeleton/index.md +++ b/docs/components/skeleton/index.md @@ -5,7 +5,7 @@ 在需要等待加载内容的位置设置一个骨架屏,某些场景下比 Loading 的视觉效果更好。 ### 基本用法 -基础的骨架效果, 通过 `row` 属性配置占位段落行数。 +最基本的占位效果。 :::demo @@ -16,28 +16,27 @@ ``` ::: -### 显示头像 -通过 avatar 属性显示头像占位图。 +### 复杂组合 :::demo ```vue -``` -::: - - -### 展示子组件 -将 loading 属性设置成 false 表示内容加载完成,此时会隐藏占位图,并显示 Skeleton 的子组件。 - -:::demo - -```vue -