Skip to content

Commit

Permalink
feat: using extraProps in Image
Browse files Browse the repository at this point in the history
  • Loading branch information
kkmch authored and Kezhik Kyzyl-ool committed Jan 30, 2024
1 parent fc9f16f commit b7c6d1c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/blocks/Tabs/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ export const TabsBlock = ({

if (activeTabData.caption && imageProps) {
Object.assign(imageProps, {
'aria-describedby': captionId,
extraProps: {
'aria-describedby': captionId,
},
});
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/components/Image/Image.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, {
CSSProperties,
Fragment,
HTMLProps,
MouseEventHandler,
ReactEventHandler,
useContext,
Expand All @@ -12,14 +13,15 @@ import {ProjectSettingsContext} from '../../context/projectSettingsContext';
import {ImageDeviceProps, ImageObjectProps, QAProps} from '../../models';
import {getQaAttrubutes} from '../../utils';
import {isCompressible} from '../../utils/imageCompress';
import ImageBase from '../ImageBase/ImageBase';
import ImageBase, {ImageBaseProps} from '../ImageBase/ImageBase';

export interface ImageProps extends Partial<ImageObjectProps>, Partial<ImageDeviceProps>, QAProps {
style?: CSSProperties;
className?: string;
onClick?: MouseEventHandler;
onLoad?: ReactEventHandler<HTMLDivElement>;
containerClassName?: string;
extraProps?: Omit<HTMLProps<HTMLImageElement>, keyof ImageBaseProps>;
}

export interface DeviceSpecificFragmentProps extends QAProps {
Expand Down Expand Up @@ -66,6 +68,7 @@ const Image = (props: ImageProps) => {
onLoad,
containerClassName,
qa,
extraProps,
} = props;
const [imgLoadingError, setImgLoadingError] = useState(false);

Expand Down Expand Up @@ -123,6 +126,7 @@ const Image = (props: ImageProps) => {
onClick={onClick}
onError={() => setImgLoadingError(true)}
onLoad={onLoad}
{...extraProps}
/>
</picture>
);
Expand Down
2 changes: 1 addition & 1 deletion src/models/constructor-items/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ interface LoopProps {

// images

export interface ImageInfoProps extends Pick<HTMLProps<HTMLImageElement>, 'aria-describedby'> {
export interface ImageInfoProps {
alt?: string;
disableCompress?: boolean;
}
Expand Down

0 comments on commit b7c6d1c

Please sign in to comment.