Skip to content

Commit a6fe005

Browse files
authored
fix(kami-design): image size (#1534)
fix #1533
1 parent 5d7b4b8 commit a6fe005

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

packages/kami-design/components/Image/component.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,15 @@ interface ImageProps {
3939
const Image: FC<
4040
{
4141
popup?: boolean
42-
42+
height?: number | string
43+
width?: number | string
4344
loaderFn: () => void
4445
loaded: boolean
4546
} & Pick<
4647
DetailedHTMLProps<ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>,
4748
'src' | 'alt'
4849
>
49-
> = memo(({ src, alt, popup = false, loaded, loaderFn }) => {
50+
> = memo(({ src, alt, height, width, popup = false, loaded, loaderFn }) => {
5051
const imageRef = useRef<HTMLImageElement>(null)
5152

5253
useEffect(() => {
@@ -79,7 +80,13 @@ const Image: FC<
7980
data-status={loaded ? 'loaded' : 'loading'}
8081
onAnimationEnd={onImageAnimationEnd}
8182
>
82-
<img src={src} alt={alt} ref={imageRef} loading="lazy" />
83+
<img
84+
src={src}
85+
alt={alt}
86+
ref={imageRef}
87+
loading="lazy"
88+
style={{ width, height }}
89+
/>
8390
</div>
8491
</>
8592
)
@@ -228,6 +235,8 @@ export const ImageLazy = memo(
228235
<Image
229236
src={src}
230237
alt={alt}
238+
height={height || calculatedSize.height}
239+
width={width || calculatedSize.width}
231240
popup={popup}
232241
loaded={loaded}
233242
loaderFn={loaderFn}

0 commit comments

Comments
 (0)