Skip to content

Commit ab90e3f

Browse files
committed
style: update image code, #5531
1 parent bc3843b commit ab90e3f

File tree

4 files changed

+11
-15
lines changed

4 files changed

+11
-15
lines changed

components/image/index.en-US.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Previewable image.
2222
| placeholder | Load placeholder, use default placeholder when set `true` | boolean \| slot | - | 2.0.0 |
2323
| preview | preview config, disabled when `false` | boolean \| [previewType](#previewType) | true | 2.0.0 |
2424
| src | Image path | string | - | 2.0.0 |
25-
| previewMask | custom mask | boolean \| function \| slot | - | 3.2.0 |
25+
| previewMask | custom mask | false \| function \| slot | - | 3.2.0 |
2626
| width | Image width | string \| number | - | 2.0.0 |
2727

2828
### events

components/image/index.tsx

+8-12
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,20 @@ const Image = defineComponent<ImageProps>({
4141

4242
return () => {
4343
const imageLocale = configProvider.locale?.Image || defaultLocale.Image;
44-
44+
const defaultPreviewMask = () => (
45+
<div class={`${prefixCls.value}-mask-info`}>
46+
<EyeOutlined />
47+
{imageLocale?.preview}
48+
</div>
49+
);
50+
const { previewMask = slots.previewMask || defaultPreviewMask } = props;
4551
return (
4652
<ImageInternal
4753
{...{ ...attrs, ...props, prefixCls: prefixCls.value }}
4854
preview={mergedPreview.value}
4955
v-slots={{
5056
...slots,
51-
previewMask:
52-
props.previewMask === false
53-
? null
54-
: props.previewMask ??
55-
slots.previewMask ??
56-
(() => (
57-
<div class={`${prefixCls.value}-mask-info`}>
58-
<EyeOutlined />
59-
{imageLocale?.preview}
60-
</div>
61-
)),
57+
previewMask: typeof previewMask === 'function' ? previewMask : null,
6258
}}
6359
></ImageInternal>
6460
);

components/image/index.zh-CN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ cover: https://gw.alipayobjects.com/zos/antfincdn/D1dXz9PZqa/image.svg
2323
| placeholder | 加载占位, 为 `true` 时使用默认占位 | boolean \| slot | - | 2.0.0 |
2424
| preview | 预览参数,为 `false` 时禁用 | boolean \| [previewType](#previewType) | true | 2.0.0 |
2525
| src | 图片地址 | string | - | 2.0.0 |
26-
| previewMask | 自定义 mask | boolean \| function \| slot | - | 3.2.0 |
26+
| previewMask | 自定义 mask | false \| function \| slot | - | 3.2.0 |
2727
| width | 图像宽度 | string \| number | - | 2.0.0 |
2828

2929
### 事件

components/vc-image/src/Image.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const imageProps = () => ({
3333
prefixCls: String,
3434
previewPrefixCls: String,
3535
previewMask: {
36-
type: [Boolean, Function] as PropType<boolean | (() => any)>,
36+
type: [Boolean, Function] as PropType<false | (() => any)>,
3737
default: undefined,
3838
},
3939
placeholder: PropTypes.any,

0 commit comments

Comments
 (0)