mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(Image): add @image-loading-icon-size、@image-error-icon-size var
This commit is contained in:
parent
dd8559a2aa
commit
d7ae8c5a26
@ -6,7 +6,7 @@ exports[`renders demo correctly 1`] = `
|
||||
<div class="van-card">
|
||||
<div class="van-card__header"><a class="van-card__thumb">
|
||||
<div class="van-image" style="width: 100%; height: 100%;"><img src="https://img.yzcdn.cn/vant/t-thirt.jpg" class="van-image__img" style="object-fit: contain;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div>
|
||||
</a>
|
||||
@ -29,7 +29,7 @@ exports[`renders demo correctly 1`] = `
|
||||
<div class="van-card">
|
||||
<div class="van-card__header"><a class="van-card__thumb">
|
||||
<div class="van-image" style="width: 100%; height: 100%;"><img src="https://img.yzcdn.cn/vant/t-thirt.jpg" class="van-image__img" style="object-fit: contain;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div>
|
||||
<div class="van-card__tag"><span class="van-tag van-tag--mark van-tag--danger">标签</span></div>
|
||||
@ -54,7 +54,7 @@ exports[`renders demo correctly 1`] = `
|
||||
<div class="van-card">
|
||||
<div class="van-card__header"><a class="van-card__thumb">
|
||||
<div class="van-image" style="width: 100%; height: 100%;"><img src="https://img.yzcdn.cn/vant/t-thirt.jpg" class="van-image__img" style="object-fit: contain;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div>
|
||||
</a>
|
||||
|
@ -55,7 +55,7 @@ exports[`renders demo correctly 1`] = `
|
||||
<div class="van-grid-item" style="flex-basis: 33.333333333333336%;">
|
||||
<div class="van-grid-item__content van-grid-item__content--center">
|
||||
<div class="van-image"><img src="https://img.yzcdn.cn/vant/apple-1.jpg" class="van-image__img" style="object-fit: contain;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div>
|
||||
</div>
|
||||
@ -63,7 +63,7 @@ exports[`renders demo correctly 1`] = `
|
||||
<div class="van-grid-item" style="flex-basis: 33.333333333333336%;">
|
||||
<div class="van-grid-item__content van-grid-item__content--center">
|
||||
<div class="van-image"><img src="https://img.yzcdn.cn/vant/apple-2.jpg" class="van-image__img" style="object-fit: contain;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div>
|
||||
</div>
|
||||
@ -71,7 +71,7 @@ exports[`renders demo correctly 1`] = `
|
||||
<div class="van-grid-item" style="flex-basis: 33.333333333333336%;">
|
||||
<div class="van-grid-item__content van-grid-item__content--center">
|
||||
<div class="van-image"><img src="https://img.yzcdn.cn/vant/apple-3.jpg" class="van-image__img" style="object-fit: contain;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -108,7 +108,9 @@ export default createComponent({
|
||||
if (this.loading && this.showLoading) {
|
||||
return (
|
||||
<div class={bem('loading')}>
|
||||
{this.slots('loading') || <Icon name="photo-o" size="22" />}
|
||||
{this.slots('loading') || (
|
||||
<Icon name="photo-o" class={bem('loading-icon')} />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@ -116,7 +118,9 @@ export default createComponent({
|
||||
if (this.error && this.showError) {
|
||||
return (
|
||||
<div class={bem('error')}>
|
||||
{this.slots('error') || <Icon name="warning-o" size="22" />}
|
||||
{this.slots('error') || (
|
||||
<Icon name="warning-o" class={bem('error-icon')} />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@ -142,14 +146,23 @@ export default createComponent({
|
||||
}
|
||||
|
||||
return (
|
||||
<img src={this.src} onLoad={this.onLoad} onError={this.onError} {...imgData} />
|
||||
<img
|
||||
src={this.src}
|
||||
onLoad={this.onLoad}
|
||||
onError={this.onError}
|
||||
{...imgData}
|
||||
/>
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div class={bem({ round: this.round })} style={this.style} onClick={this.onClick}>
|
||||
<div
|
||||
class={bem({ round: this.round })}
|
||||
style={this.style}
|
||||
onClick={this.onClick}
|
||||
>
|
||||
{this.genImage()}
|
||||
{this.genPlaceholder()}
|
||||
</div>
|
||||
|
@ -34,4 +34,12 @@
|
||||
font-size: @image-placeholder-font-size;
|
||||
background-color: @image-placeholder-background-color;
|
||||
}
|
||||
|
||||
&__loading-icon {
|
||||
font-size: @image-loading-icon-size;
|
||||
}
|
||||
|
||||
&__error-icon {
|
||||
font-size: @image-error-icon-size;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ exports[`renders demo correctly 1`] = `
|
||||
<div>
|
||||
<div class="van-row">
|
||||
<div class="van-image" style="width: 100px; height: 100px;"><img src="https://img.yzcdn.cn/vant/cat.jpeg" class="van-image__img">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div>
|
||||
</div>
|
||||
@ -14,35 +14,35 @@ exports[`renders demo correctly 1`] = `
|
||||
<div class="van-row" style="margin-left: -10px; margin-right: -10px;">
|
||||
<div class="van-col van-col--8" style="padding-left: 10px; padding-right: 10px;">
|
||||
<div class="van-image" style="width: 100%; height: 27vw;"><img src="https://img.yzcdn.cn/vant/cat.jpeg" class="van-image__img" style="object-fit: contain;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div>
|
||||
<div class="text">contain</div>
|
||||
</div>
|
||||
<div class="van-col van-col--8" style="padding-left: 10px; padding-right: 10px;">
|
||||
<div class="van-image" style="width: 100%; height: 27vw;"><img src="https://img.yzcdn.cn/vant/cat.jpeg" class="van-image__img" style="object-fit: cover;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div>
|
||||
<div class="text">cover</div>
|
||||
</div>
|
||||
<div class="van-col van-col--8" style="padding-left: 10px; padding-right: 10px;">
|
||||
<div class="van-image" style="width: 100%; height: 27vw;"><img src="https://img.yzcdn.cn/vant/cat.jpeg" class="van-image__img" style="object-fit: fill;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div>
|
||||
<div class="text">fill</div>
|
||||
</div>
|
||||
<div class="van-col van-col--8" style="padding-left: 10px; padding-right: 10px;">
|
||||
<div class="van-image" style="width: 100%; height: 27vw;"><img src="https://img.yzcdn.cn/vant/cat.jpeg" class="van-image__img" style="object-fit: none;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div>
|
||||
<div class="text">none</div>
|
||||
</div>
|
||||
<div class="van-col van-col--8" style="padding-left: 10px; padding-right: 10px;">
|
||||
<div class="van-image" style="width: 100%; height: 27vw;"><img src="https://img.yzcdn.cn/vant/cat.jpeg" class="van-image__img" style="object-fit: scale-down;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div>
|
||||
<div class="text">scale-down</div>
|
||||
@ -53,35 +53,35 @@ exports[`renders demo correctly 1`] = `
|
||||
<div class="van-row" style="margin-left: -10px; margin-right: -10px;">
|
||||
<div class="van-col van-col--8" style="padding-left: 10px; padding-right: 10px;">
|
||||
<div class="van-image van-image--round" style="width: 100%; height: 27vw;"><img src="https://img.yzcdn.cn/vant/cat.jpeg" class="van-image__img" style="object-fit: contain;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div>
|
||||
<div class="text">contain</div>
|
||||
</div>
|
||||
<div class="van-col van-col--8" style="padding-left: 10px; padding-right: 10px;">
|
||||
<div class="van-image van-image--round" style="width: 100%; height: 27vw;"><img src="https://img.yzcdn.cn/vant/cat.jpeg" class="van-image__img" style="object-fit: cover;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div>
|
||||
<div class="text">cover</div>
|
||||
</div>
|
||||
<div class="van-col van-col--8" style="padding-left: 10px; padding-right: 10px;">
|
||||
<div class="van-image van-image--round" style="width: 100%; height: 27vw;"><img src="https://img.yzcdn.cn/vant/cat.jpeg" class="van-image__img" style="object-fit: fill;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div>
|
||||
<div class="text">fill</div>
|
||||
</div>
|
||||
<div class="van-col van-col--8" style="padding-left: 10px; padding-right: 10px;">
|
||||
<div class="van-image van-image--round" style="width: 100%; height: 27vw;"><img src="https://img.yzcdn.cn/vant/cat.jpeg" class="van-image__img" style="object-fit: none;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div>
|
||||
<div class="text">none</div>
|
||||
</div>
|
||||
<div class="van-col van-col--8" style="padding-left: 10px; padding-right: 10px;">
|
||||
<div class="van-image van-image--round" style="width: 100%; height: 27vw;"><img src="https://img.yzcdn.cn/vant/cat.jpeg" class="van-image__img" style="object-fit: scale-down;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div>
|
||||
<div class="text">scale-down</div>
|
||||
@ -92,7 +92,7 @@ exports[`renders demo correctly 1`] = `
|
||||
<div class="van-row" style="margin-left: -10px; margin-right: -10px;">
|
||||
<div class="van-col van-col--8" style="padding-left: 10px; padding-right: 10px;">
|
||||
<div class="van-image" style="width: 100%; height: 27vw;"><img class="van-image__img">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div>
|
||||
<div class="text">默认提示</div>
|
||||
@ -111,14 +111,14 @@ exports[`renders demo correctly 1`] = `
|
||||
<div class="van-row" style="margin-left: -10px; margin-right: -10px;">
|
||||
<div class="van-col van-col--8" style="padding-left: 10px; padding-right: 10px;">
|
||||
<div class="van-image" style="width: 100%; height: 27vw;"><img src="x" class="van-image__img">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div>
|
||||
<div class="text">默认提示</div>
|
||||
</div>
|
||||
<div class="van-col van-col--8" style="padding-left: 10px; padding-right: 10px;">
|
||||
<div class="van-image" style="width: 100%; height: 27vw;"><img src="x" class="van-image__img">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div>
|
||||
<div class="text">自定义提示</div>
|
||||
|
@ -2,14 +2,14 @@
|
||||
|
||||
exports[`lazy load 1`] = `
|
||||
<div class="van-image"><img class="van-image__img">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`lazy-load error event 1`] = `
|
||||
<div class="van-image">
|
||||
<div class="van-image__error"><i class="van-icon van-icon-warning-o" style="font-size: 22px;">
|
||||
<div class="van-image__error"><i class="van-icon van-icon-warning-o van-image__error-icon">
|
||||
<!----></i></div>
|
||||
</div>
|
||||
`;
|
||||
@ -20,14 +20,14 @@ exports[`load event 1`] = `<div class="van-image"><img src="https://img.yzcdn.cn
|
||||
|
||||
exports[`load event 2`] = `
|
||||
<div class="van-image"><img src="" class="van-image__img">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`radius prop 1`] = `
|
||||
<div class="van-image" style="overflow: hidden; border-radius: 3px;"><img src="https://img.yzcdn.cn/vant/cat.jpeg" class="van-image__img">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div>
|
||||
`;
|
||||
|
@ -395,6 +395,8 @@
|
||||
@image-placeholder-text-color: @gray-6;
|
||||
@image-placeholder-font-size: @font-size-md;
|
||||
@image-placeholder-background-color: @background-color;
|
||||
@image-loading-icon-size: 22px;
|
||||
@image-error-icon-size: 22px;
|
||||
|
||||
// ImagePreview
|
||||
@image-preview-index-text-color: @white;
|
||||
|
@ -64,7 +64,7 @@ exports[`renders demo correctly 1`] = `
|
||||
</a></div>
|
||||
<div class="van-tree-select__content">
|
||||
<div class="van-image"><img src="https://img.yzcdn.cn/vant/apple-1.jpg" class="van-image__img">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div>
|
||||
<!---->
|
||||
|
@ -15,14 +15,14 @@ exports[`renders demo correctly 1`] = `
|
||||
<div class="van-uploader__wrapper">
|
||||
<div class="van-uploader__preview">
|
||||
<div class="van-image van-uploader__preview-image" style="overflow: hidden; border-radius: 4px;"><img src="https://img.yzcdn.cn/vant/leaf.jpg" class="van-image__img" style="object-fit: cover;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div><i class="van-icon van-icon-clear van-uploader__preview-delete">
|
||||
<!----></i>
|
||||
</div>
|
||||
<div class="van-uploader__preview">
|
||||
<div class="van-image van-uploader__preview-image" style="overflow: hidden; border-radius: 4px;"><img src="https://img.yzcdn.cn/vant/tree.jpg" class="van-image__img" style="object-fit: cover;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div><i class="van-icon van-icon-clear van-uploader__preview-delete">
|
||||
<!----></i>
|
||||
@ -37,7 +37,7 @@ exports[`renders demo correctly 1`] = `
|
||||
<div class="van-uploader__wrapper">
|
||||
<div class="van-uploader__preview">
|
||||
<div class="van-image van-uploader__preview-image" style="overflow: hidden; border-radius: 4px;"><img src="https://img.yzcdn.cn/vant/sand.jpg" class="van-image__img" style="object-fit: cover;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div><i class="van-icon van-icon-clear van-uploader__preview-delete">
|
||||
<!----></i>
|
||||
|
@ -23,7 +23,7 @@ exports[`image-fit prop 1`] = `
|
||||
<div class="van-uploader__wrapper">
|
||||
<div class="van-uploader__preview">
|
||||
<div class="van-image van-uploader__preview-image" style="overflow: hidden; border-radius: 4px;"><img src="https://img.yzcdn.cn/vant/cat.jpeg" class="van-image__img" style="object-fit: contain;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div><i class="van-icon van-icon-clear van-uploader__preview-delete">
|
||||
<!----></i>
|
||||
@ -39,7 +39,7 @@ exports[`max-count prop 1`] = `
|
||||
<div class="van-uploader__wrapper">
|
||||
<div class="van-uploader__preview">
|
||||
<div class="van-image van-uploader__preview-image" style="overflow: hidden; border-radius: 4px;"><img src="data:image/test" class="van-image__img" style="object-fit: cover;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div><i class="van-icon van-icon-clear van-uploader__preview-delete">
|
||||
<!----></i>
|
||||
@ -53,7 +53,7 @@ exports[`preview-size prop 1`] = `
|
||||
<div class="van-uploader__wrapper">
|
||||
<div class="van-uploader__preview" style="">
|
||||
<div class="van-image van-uploader__preview-image" style="width: 30px; height: 30px; overflow: hidden; border-radius: 4px;"><img src="data:image/test" class="van-image__img" style="object-fit: cover;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div><i class="van-icon van-icon-clear van-uploader__preview-delete">
|
||||
<!----></i>
|
||||
@ -69,7 +69,7 @@ exports[`render preview image 1`] = `
|
||||
<div class="van-uploader__wrapper">
|
||||
<div class="van-uploader__preview">
|
||||
<div class="van-image van-uploader__preview-image" style="overflow: hidden; border-radius: 4px;"><img src="https://img.yzcdn.cn/vant/cat.jpeg" class="van-image__img" style="object-fit: cover;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div><i class="van-icon van-icon-clear van-uploader__preview-delete">
|
||||
<!----></i>
|
||||
@ -90,7 +90,7 @@ exports[`render preview image 1`] = `
|
||||
</div>
|
||||
<div class="van-uploader__preview">
|
||||
<div class="van-image van-uploader__preview-image" style="overflow: hidden; border-radius: 4px;"><img src="data:image/test" class="van-image__img" style="object-fit: cover;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o" style="font-size: 22px;">
|
||||
<div class="van-image__loading"><i class="van-icon van-icon-photo-o van-image__loading-icon">
|
||||
<!----></i></div>
|
||||
</div><i class="van-icon van-icon-clear van-uploader__preview-delete">
|
||||
<!----></i>
|
||||
|
Loading…
x
Reference in New Issue
Block a user