mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(Skeleton): round prop not work for title (#11225)
This commit is contained in:
parent
19cd0667e4
commit
8dcfb5c29a
@ -12,18 +12,18 @@ Register component globally via `app.use`, refer to [Component Registration](#/e
|
|||||||
import { createApp } from 'vue';
|
import { createApp } from 'vue';
|
||||||
import {
|
import {
|
||||||
Skeleton,
|
Skeleton,
|
||||||
VanSkeletonTitle,
|
SkeletonTitle,
|
||||||
VanSkeletonImage,
|
SkeletonImage,
|
||||||
VanSkeletonAvatar,
|
SkeletonAvatar,
|
||||||
VanSkeletonParagraph,
|
SkeletonParagraph,
|
||||||
} from 'vant';
|
} from 'vant';
|
||||||
|
|
||||||
const app = createApp();
|
const app = createApp();
|
||||||
app.use(Skeleton);
|
app.use(Skeleton);
|
||||||
app.use(VanSkeletonTitle);
|
app.use(SkeletonTitle);
|
||||||
app.use(VanSkeletonImage);
|
app.use(SkeletonImage);
|
||||||
app.use(VanSkeletonAvatar);
|
app.use(SkeletonAvatar);
|
||||||
app.use(VanSkeletonParagraph);
|
app.use(SkeletonParagraph);
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
@ -68,14 +68,14 @@ export default {
|
|||||||
|
|
||||||
### Custom Content
|
### Custom Content
|
||||||
|
|
||||||
Using `template` slots to display custom content.
|
Using `template` slots to custom skeleton content.
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<van-skeleton>
|
<van-skeleton>
|
||||||
<template #template>
|
<template #template>
|
||||||
<div class="template-slot">
|
<div :style="{ display: 'flex', width: '100%' }">
|
||||||
<van-skeleton-image />
|
<van-skeleton-image />
|
||||||
<div :style="{ flex: 1 }">
|
<div :style="{ flex: 1, marginLeft: '16px' }">
|
||||||
<van-skeleton-paragraph row-width="60%" />
|
<van-skeleton-paragraph row-width="60%" />
|
||||||
<van-skeleton-paragraph />
|
<van-skeleton-paragraph />
|
||||||
<van-skeleton-paragraph />
|
<van-skeleton-paragraph />
|
||||||
@ -148,6 +148,7 @@ import type {
|
|||||||
SkeletonImageProps,
|
SkeletonImageProps,
|
||||||
SkeletonTitleProps,
|
SkeletonTitleProps,
|
||||||
SkeletonAvatarShape,
|
SkeletonAvatarShape,
|
||||||
|
SkeletonImageShape,
|
||||||
SkeletonParagraphProps,
|
SkeletonParagraphProps,
|
||||||
} from 'vant';
|
} from 'vant';
|
||||||
```
|
```
|
||||||
|
@ -12,18 +12,18 @@
|
|||||||
import { createApp } from 'vue';
|
import { createApp } from 'vue';
|
||||||
import {
|
import {
|
||||||
Skeleton,
|
Skeleton,
|
||||||
VanSkeletonTitle,
|
SkeletonTitle,
|
||||||
VanSkeletonImage,
|
SkeletonImage,
|
||||||
VanSkeletonAvatar,
|
SkeletonAvatar,
|
||||||
VanSkeletonParagraph,
|
SkeletonParagraph,
|
||||||
} from 'vant';
|
} from 'vant';
|
||||||
|
|
||||||
const app = createApp();
|
const app = createApp();
|
||||||
app.use(Skeleton);
|
app.use(Skeleton);
|
||||||
app.use(VanSkeletonTitle);
|
app.use(SkeletonTitle);
|
||||||
app.use(VanSkeletonImage);
|
app.use(SkeletonImage);
|
||||||
app.use(VanSkeletonAvatar);
|
app.use(SkeletonAvatar);
|
||||||
app.use(VanSkeletonParagraph);
|
app.use(SkeletonParagraph);
|
||||||
```
|
```
|
||||||
|
|
||||||
## 代码演示
|
## 代码演示
|
||||||
@ -79,9 +79,9 @@ export default {
|
|||||||
```html
|
```html
|
||||||
<van-skeleton>
|
<van-skeleton>
|
||||||
<template #template>
|
<template #template>
|
||||||
<div class="template-slot">
|
<div :style="{ display: 'flex', width: '100%' }">
|
||||||
<van-skeleton-image />
|
<van-skeleton-image />
|
||||||
<div :style="{ flex: 1 }">
|
<div :style="{ flex: 1, marginLeft: '16px' }">
|
||||||
<van-skeleton-paragraph row-width="60%" />
|
<van-skeleton-paragraph row-width="60%" />
|
||||||
<van-skeleton-paragraph />
|
<van-skeleton-paragraph />
|
||||||
<van-skeleton-paragraph />
|
<van-skeleton-paragraph />
|
||||||
@ -153,6 +153,7 @@ import type {
|
|||||||
SkeletonProps,
|
SkeletonProps,
|
||||||
SkeletonImageProps,
|
SkeletonImageProps,
|
||||||
SkeletonTitleProps,
|
SkeletonTitleProps,
|
||||||
|
SkeletonImageShape,
|
||||||
SkeletonAvatarShape,
|
SkeletonAvatarShape,
|
||||||
SkeletonParagraphProps,
|
SkeletonParagraphProps,
|
||||||
} from 'vant';
|
} from 'vant';
|
||||||
|
@ -12,9 +12,12 @@ import {
|
|||||||
} from '../utils';
|
} from '../utils';
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
import SkeletonTitle from './Title';
|
import SkeletonTitle from './SkeletonTitle';
|
||||||
import SkeletonAvatar, { type SkeletonAvatarShape } from './Avatar';
|
import SkeletonAvatar from './SkeletonAvatar';
|
||||||
import SkeletonParagraph, { DEFAULT_ROW_WIDTH } from './Paragraph';
|
import SkeletonParagraph, { DEFAULT_ROW_WIDTH } from './SkeletonParagraph';
|
||||||
|
|
||||||
|
// Types
|
||||||
|
import type { SkeletonAvatarShape } from './types';
|
||||||
|
|
||||||
const [name, bem] = createNamespace('skeleton');
|
const [name, bem] = createNamespace('skeleton');
|
||||||
const DEFAULT_LAST_ROW_WIDTH = '60%';
|
const DEFAULT_LAST_ROW_WIDTH = '60%';
|
||||||
|
@ -8,9 +8,10 @@ import {
|
|||||||
createNamespace,
|
createNamespace,
|
||||||
} from '../utils';
|
} from '../utils';
|
||||||
|
|
||||||
const [name, bem] = createNamespace('skeleton-avatar');
|
// Types
|
||||||
|
import type { SkeletonAvatarShape } from './types';
|
||||||
|
|
||||||
export type SkeletonAvatarShape = 'square' | 'round';
|
const [name, bem] = createNamespace('skeleton-avatar');
|
||||||
|
|
||||||
export const skeletonAvatarProps = {
|
export const skeletonAvatarProps = {
|
||||||
avatarSize: numericProp,
|
avatarSize: numericProp,
|
@ -7,12 +7,13 @@ import {
|
|||||||
createNamespace,
|
createNamespace,
|
||||||
} from '../utils';
|
} from '../utils';
|
||||||
|
|
||||||
|
// Types
|
||||||
|
import type { SkeletonImageShape } from './types';
|
||||||
|
|
||||||
import { Icon } from '../icon';
|
import { Icon } from '../icon';
|
||||||
|
|
||||||
const [name, bem] = createNamespace('skeleton-image');
|
const [name, bem] = createNamespace('skeleton-image');
|
||||||
|
|
||||||
export type SkeletonImageShape = 'square' | 'round';
|
|
||||||
|
|
||||||
export const skeletonImageProps = {
|
export const skeletonImageProps = {
|
||||||
imageSize: numericProp,
|
imageSize: numericProp,
|
||||||
imageShape: makeStringProp<SkeletonImageShape>('square'),
|
imageShape: makeStringProp<SkeletonImageShape>('square'),
|
@ -49,9 +49,9 @@ const show = ref(false);
|
|||||||
<demo-block :title="t('customContent')">
|
<demo-block :title="t('customContent')">
|
||||||
<van-skeleton>
|
<van-skeleton>
|
||||||
<template #template>
|
<template #template>
|
||||||
<div class="template-slot">
|
<div :style="{ display: 'flex', width: '100%' }">
|
||||||
<van-skeleton-image />
|
<van-skeleton-image />
|
||||||
<div :style="{ flex: 1 }">
|
<div :style="{ flex: 1, marginLeft: '16px' }">
|
||||||
<van-skeleton-paragraph row-width="60%" />
|
<van-skeleton-paragraph row-width="60%" />
|
||||||
<van-skeleton-paragraph />
|
<van-skeleton-paragraph />
|
||||||
<van-skeleton-paragraph />
|
<van-skeleton-paragraph />
|
||||||
@ -98,14 +98,5 @@ const show = ref(false);
|
|||||||
margin-right: var(--van-padding-md);
|
margin-right: var(--van-padding-md);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.template-slot {
|
|
||||||
display: flex;
|
|
||||||
width: 100%;
|
|
||||||
|
|
||||||
.van-skeleton-image {
|
|
||||||
margin-right: var(--van-padding-md);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -38,6 +38,10 @@
|
|||||||
&-title {
|
&-title {
|
||||||
height: var(--van-skeleton-paragraph-height);
|
height: var(--van-skeleton-paragraph-height);
|
||||||
background: var(--van-skeleton-paragraph-background);
|
background: var(--van-skeleton-paragraph-background);
|
||||||
|
|
||||||
|
&--round {
|
||||||
|
border-radius: var(--van-radius-max);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&-title {
|
&-title {
|
||||||
@ -60,13 +64,6 @@
|
|||||||
infinite;
|
infinite;
|
||||||
}
|
}
|
||||||
|
|
||||||
&--round {
|
|
||||||
.van-skeleton-paragraph,
|
|
||||||
.van-skeleton-title {
|
|
||||||
border-radius: var(--van-radius-max);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&-image {
|
&-image {
|
||||||
display: flex;
|
display: flex;
|
||||||
width: var(--van-skeleton-image-size);
|
width: var(--van-skeleton-image-size);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import _Skeleton from './Skeleton';
|
import _Skeleton from './Skeleton';
|
||||||
import _SkeletonImage from './Image';
|
import _SkeletonImage from './SkeletonImage';
|
||||||
import _SkeletonTitle from './Title';
|
import _SkeletonTitle from './SkeletonTitle';
|
||||||
import _SkeletonAvatar from './Avatar';
|
import _SkeletonAvatar from './SkeletonAvatar';
|
||||||
import _SkeletonParagraph from './Paragraph';
|
import _SkeletonParagraph from './SkeletonParagraph';
|
||||||
|
|
||||||
import { withInstall } from '../utils';
|
import { withInstall } from '../utils';
|
||||||
|
|
||||||
@ -19,22 +19,26 @@ export { skeletonProps } from './Skeleton';
|
|||||||
export type { SkeletonProps } from './Skeleton';
|
export type { SkeletonProps } from './Skeleton';
|
||||||
|
|
||||||
// SkeletonImage
|
// SkeletonImage
|
||||||
export { skeletonImageProps } from './Image';
|
export { skeletonImageProps } from './SkeletonImage';
|
||||||
export type { SkeletonImageProps, SkeletonImageShape } from './Image';
|
export type { SkeletonImageProps } from './SkeletonImage';
|
||||||
|
|
||||||
// SkeletonAvatar
|
// SkeletonAvatar
|
||||||
export { skeletonAvatarProps } from './Avatar';
|
export { skeletonAvatarProps } from './SkeletonAvatar';
|
||||||
export type { SkeletonAvatarProps, SkeletonAvatarShape } from './Avatar';
|
export type { SkeletonAvatarProps } from './SkeletonAvatar';
|
||||||
|
|
||||||
// SkeletonParagraph
|
// SkeletonParagraph
|
||||||
export { skeletonParagraphProps } from './Paragraph';
|
export { skeletonParagraphProps } from './SkeletonParagraph';
|
||||||
export type { SkeletonParagraphProps } from './Paragraph';
|
export type { SkeletonParagraphProps } from './SkeletonParagraph';
|
||||||
|
|
||||||
// SkeletonTitle
|
// SkeletonTitle
|
||||||
export { skeletonTitleProps } from './Title';
|
export { skeletonTitleProps } from './SkeletonTitle';
|
||||||
export type { SkeletonTitleProps } from './Title';
|
export type { SkeletonTitleProps } from './SkeletonTitle';
|
||||||
|
|
||||||
export type { SkeletonThemeVars } from './types';
|
export type {
|
||||||
|
SkeletonThemeVars,
|
||||||
|
SkeletonImageShape,
|
||||||
|
SkeletonAvatarShape,
|
||||||
|
} from './types';
|
||||||
|
|
||||||
declare module 'vue' {
|
declare module 'vue' {
|
||||||
export interface GlobalComponents {
|
export interface GlobalComponents {
|
||||||
|
@ -75,12 +75,12 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="van-skeleton van-skeleton--animate">
|
<div class="van-skeleton van-skeleton--animate">
|
||||||
<div class="template-slot">
|
<div style="display: flex; width: 100%;">
|
||||||
<div class="van-skeleton-image van-skeleton-image--square">
|
<div class="van-skeleton-image van-skeleton-image--square">
|
||||||
<i class="van-badge__wrapper van-icon van-icon-photo van-skeleton-image__icon">
|
<i class="van-badge__wrapper van-icon van-icon-photo van-skeleton-image__icon">
|
||||||
</i>
|
</i>
|
||||||
</div>
|
</div>
|
||||||
<div style="flex: 1;">
|
<div style="flex: 1; margin-left: 16px;">
|
||||||
<div class="van-skeleton-paragraph"
|
<div class="van-skeleton-paragraph"
|
||||||
style="width: 60%;"
|
style="width: 60%;"
|
||||||
>
|
>
|
||||||
|
@ -97,7 +97,7 @@ test('should skeleton image works with imageSize prop', () => {
|
|||||||
expect(dom.style.height).toBe('20rem');
|
expect(dom.style.height).toBe('20rem');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should skeleton image worsk with imageShape prop', () => {
|
test('should skeleton image works with imageShape prop', () => {
|
||||||
const wrapper = mount(VanSkeletonImage, {
|
const wrapper = mount(VanSkeletonImage, {
|
||||||
props: {
|
props: {
|
||||||
imageShape: 'round',
|
imageShape: 'round',
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
export type SkeletonAvatarShape = 'square' | 'round';
|
||||||
|
|
||||||
|
export type SkeletonImageShape = 'square' | 'round';
|
||||||
|
|
||||||
export type SkeletonThemeVars = {
|
export type SkeletonThemeVars = {
|
||||||
skeletonParagraphHeight?: string;
|
skeletonParagraphHeight?: string;
|
||||||
skeletonParagraphBackground?: string;
|
skeletonParagraphBackground?: string;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user