Skip to content

Commit

Permalink
chore: Image component props support native img element attributes (#…
Browse files Browse the repository at this point in the history
…2427)

Co-authored-by: pointhalo <88709023+pointhalo@users.noreply.github.com>
  • Loading branch information
YyumeiZhang and pointhalo committed Aug 20, 2024
1 parent b55b4ee commit 63d0a0b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions content/show/image/index-en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,8 @@ import { Image, ImagePreview } from '@douyinfe/semi-ui';
| width | Image display width | number | - | |
| setDownloadName | Set the name of the downloaded image | (src: string) => string | - | 2.40.0 |

Other attributes same as [img](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attributes)。Other attributes will be transmitted to the underlying img node.

### ImagePreview

| Properties | Instructions | Type | Default | Version |
Expand Down
2 changes: 2 additions & 0 deletions content/show/image/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,8 @@ import { Image, ImagePreview } from '@douyinfe/semi-ui';
| width | 图片显示宽度 | number | - | |
| setDownloadName | 设置图片下载名称 | (src: string) => string | - | 2.40.0 |

其他支持的属性同 [img](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attributes)。其他属性将透传至底层的 img 节点。

### ImagePreview

| 属性 | 说明 | 类型 | 默认值 | 版本 |
Expand Down
3 changes: 2 additions & 1 deletion packages/semi-ui/image/_story/image.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ export const BasicPreview = () => {
{srcList1.map((src, index) => {
return (
<Image
key={index}
key={`${index}`}
src={src}
width={200}
loading='lazy'
alt={`lamp${index + 1}`}
data-test={'data-test'}
onClick={()=>{}}
Expand Down
4 changes: 2 additions & 2 deletions packages/semi-ui/image/interface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface ImageStates {
previewVisible: boolean
}

export interface ImageProps extends BaseProps {
export interface ImageProps extends BaseProps, Omit<React.ImgHTMLAttributes<HTMLImageElement>, 'onLoad' | 'onError'> {
src?: string;
width?: string | number;
height?: string | number;
Expand Down Expand Up @@ -190,7 +190,7 @@ export interface PreviewImageStates {
width: number;
height: number;
translate: ImageTranslate;
currZoom: number;
currZoom: number
}

export interface DragDirection {
Expand Down

0 comments on commit 63d0a0b

Please sign in to comment.