Skip to content
This repository was archived by the owner on Mar 8, 2025. It is now read-only.

Commit be9885a

Browse files
committed
feat: change img prop, internal logic
1 parent af1e21a commit be9885a

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/component/base/Img.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@ import React, { forwardRef } from 'react';
33
import type { ImageProps } from '@chakra-ui/next-js';
44
import { Image } from '@chakra-ui/next-js';
55

6-
const Img = forwardRef<HTMLImageElement, ImageProps>(
7-
(props: ImageProps, ref: Ref<HTMLImageElement>) => <Image ref={ref} {...props} />,
6+
type ImgProps = Omit<ImageProps, 'w' | 'width' | 'h' | 'height'> & {
7+
w?: number | `${number}` | undefined;
8+
h?: number | `${number}` | undefined;
9+
width?: number | `${number}` | undefined;
10+
height?: number | `${number}` | undefined;
11+
};
12+
13+
const Img = forwardRef<HTMLImageElement, ImgProps>(
14+
({ w, h, width, height, ...rest }: ImgProps, ref: Ref<HTMLImageElement>) => (
15+
<Image ref={ref} {...rest} width={width ?? w} height={height ?? h} />
16+
),
817
);
918
export { Img };
10-
export type { ImageProps as ImgProps };
19+
export type { ImgProps };

0 commit comments

Comments
 (0)