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

Commit d241e4d

Browse files
authored
fix: change img prop type (#5)
2 parents f66a5d7 + dba93db commit d241e4d

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/component/base/Img.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,25 @@ import type { Ref } from 'react';
22
import React, { forwardRef } from 'react';
33
import type { ImageProps } from '@chakra-ui/next-js';
44
import { Image } from '@chakra-ui/next-js';
5+
import type CSS from 'csstype';
56

6-
type ImgProps = Omit<ImageProps, 'w' | 'width' | 'h' | 'height'> & {
7+
type ImgProps = Omit<ImageProps, 'w' | 'width' | 'h' | 'height' | 'objectFit'> & {
78
w?: number | `${number}` | undefined;
89
h?: number | `${number}` | undefined;
910
width?: number | `${number}` | undefined;
1011
height?: number | `${number}` | undefined;
12+
objectFit?: CSS.Property.ObjectFit;
1113
};
1214

1315
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+
({ w, h, width, height, objectFit, style, ...rest }: ImgProps, ref: Ref<HTMLImageElement>) => (
17+
<Image
18+
ref={ref}
19+
{...rest}
20+
style={{ objectFit, ...style }}
21+
width={width ?? w}
22+
height={height ?? h}
23+
/>
1624
),
1725
);
1826
export { Img };

0 commit comments

Comments
 (0)