mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-26 19:36:36 +08:00
feat(Skeleton): add round prop (#6441)
This commit is contained in:
parent
9a4b09bcc1
commit
4d731a3fa8
@ -56,6 +56,7 @@ export default {
|
|||||||
| avatar | Whether to show avatar placeholder | _boolean_ | `false` |
|
| avatar | Whether to show avatar placeholder | _boolean_ | `false` |
|
||||||
| loading | Whether to show skeleton,pass `false` to show child component | _boolean_ | `true` |
|
| loading | Whether to show skeleton,pass `false` to show child component | _boolean_ | `true` |
|
||||||
| animate | Whether to enable animation | _boolean_ | `true` |
|
| animate | Whether to enable animation | _boolean_ | `true` |
|
||||||
|
| round `v2.8.5` | Whether to show round title and row | _boolean_ | `false` |
|
||||||
| title-width | Title width | _number \| string_ | `40%` |
|
| title-width | Title width | _number \| string_ | `40%` |
|
||||||
| avatar-size | Size of avatar placeholder | _number \| string_ | `32px` |
|
| avatar-size | Size of avatar placeholder | _number \| string_ | `32px` |
|
||||||
| avatar-shape | Shape of avatar placeholder,can be set to `square` | _string_ | `round` |
|
| avatar-shape | Shape of avatar placeholder,can be set to `square` | _string_ | `round` |
|
||||||
|
@ -60,8 +60,9 @@ export default {
|
|||||||
| row-width | 段落占位图宽度,可传数组来设置每一行的宽度 | _number \| string \|<br>(number \| string)[]_ | `100%` |
|
| row-width | 段落占位图宽度,可传数组来设置每一行的宽度 | _number \| string \|<br>(number \| string)[]_ | `100%` |
|
||||||
| title | 是否显示标题占位图 | _boolean_ | `false` |
|
| title | 是否显示标题占位图 | _boolean_ | `false` |
|
||||||
| avatar | 是否显示头像占位图 | _boolean_ | `false` |
|
| avatar | 是否显示头像占位图 | _boolean_ | `false` |
|
||||||
| loading | 是否显示骨架屏,传`false`时会展示子组件内容 | _boolean_ | `true` |
|
| loading | 是否显示骨架屏,传 `false` 时会展示子组件内容 | _boolean_ | `true` |
|
||||||
| animate | 是否开启动画 | _boolean_ | `true` |
|
| animate | 是否开启动画 | _boolean_ | `true` |
|
||||||
|
| round `v2.8.5` | 是否将标题和段落显示为圆角风格 | _boolean_ | `false` |
|
||||||
| title-width | 标题占位图宽度 | _number \| string_ | `40%` |
|
| title-width | 标题占位图宽度 | _number \| string_ | `40%` |
|
||||||
| avatar-size | 头像占位图大小 | _number \| string_ | `32px` |
|
| avatar-size | 头像占位图大小 | _number \| string_ | `32px` |
|
||||||
| avatar-shape | 头像占位图形状,可选值为`square` | _string_ | `round` |
|
| avatar-shape | 头像占位图形状,可选值为`square` | _string_ | `round` |
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
background-color: @skeleton-avatar-background-color;
|
background-color: @skeleton-avatar-background-color;
|
||||||
|
|
||||||
&--round {
|
&--round {
|
||||||
border-radius: 100%;
|
border-radius: @border-radius-max;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +46,13 @@
|
|||||||
animation: van-skeleton-blink @skeleton-animation-duration ease-in-out
|
animation: van-skeleton-blink @skeleton-animation-duration ease-in-out
|
||||||
infinite;
|
infinite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&--round {
|
||||||
|
.van-skeleton__row,
|
||||||
|
.van-skeleton__title {
|
||||||
|
border-radius: @border-radius-max;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes van-skeleton-blink {
|
@keyframes van-skeleton-blink {
|
||||||
|
@ -9,6 +9,7 @@ import { DefaultSlots } from '../utils/types';
|
|||||||
export type SkeletonProps = {
|
export type SkeletonProps = {
|
||||||
row: number | string;
|
row: number | string;
|
||||||
title?: boolean;
|
title?: boolean;
|
||||||
|
round?: boolean;
|
||||||
avatar?: boolean;
|
avatar?: boolean;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
animate: boolean;
|
animate: boolean;
|
||||||
@ -78,7 +79,10 @@ function Skeleton(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class={bem({ animate: props.animate })} {...inherit(ctx)}>
|
<div
|
||||||
|
class={bem({ animate: props.animate, round: props.round })}
|
||||||
|
{...inherit(ctx)}
|
||||||
|
>
|
||||||
{Avatar()}
|
{Avatar()}
|
||||||
<div class={bem('content')}>
|
<div class={bem('content')}>
|
||||||
{Title()}
|
{Title()}
|
||||||
@ -90,6 +94,7 @@ function Skeleton(
|
|||||||
|
|
||||||
Skeleton.props = {
|
Skeleton.props = {
|
||||||
title: Boolean,
|
title: Boolean,
|
||||||
|
round: Boolean,
|
||||||
avatar: Boolean,
|
avatar: Boolean,
|
||||||
row: {
|
row: {
|
||||||
type: [Number, String],
|
type: [Number, String],
|
||||||
|
@ -17,6 +17,15 @@ exports[`disable animate 1`] = `
|
|||||||
|
|
||||||
exports[`render chidren 1`] = `<div>Content</div>`;
|
exports[`render chidren 1`] = `<div>Content</div>`;
|
||||||
|
|
||||||
|
exports[`round prop 1`] = `
|
||||||
|
<div class="van-skeleton van-skeleton--animate van-skeleton--round">
|
||||||
|
<div class="van-skeleton__avatar van-skeleton__avatar--round" style="width: 32px; height: 32px;"></div>
|
||||||
|
<div class="van-skeleton__content">
|
||||||
|
<h3 class="van-skeleton__title" style="width: 40%;"></h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`row-width array 1`] = `
|
exports[`row-width array 1`] = `
|
||||||
<div class="van-skeleton van-skeleton--animate">
|
<div class="van-skeleton van-skeleton--animate">
|
||||||
<div class="van-skeleton__content">
|
<div class="van-skeleton__content">
|
||||||
|
@ -34,6 +34,17 @@ test('avatar shape', () => {
|
|||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('round prop', () => {
|
||||||
|
const wrapper = mount(Skeleton, {
|
||||||
|
propsData: {
|
||||||
|
title: true,
|
||||||
|
round: true,
|
||||||
|
avatar: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
test('disable animate', () => {
|
test('disable animate', () => {
|
||||||
const wrapper = mount(Skeleton, {
|
const wrapper = mount(Skeleton, {
|
||||||
propsData: {
|
propsData: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user