Skip to content

Commit c0ae384

Browse files
author
kkmch
committed
feat: using extraProps in Image
1 parent c3c02ff commit c0ae384

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

src/blocks/Tabs/Tabs.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ export const TabsBlock = ({
4848
imageProps = themedImage && getMediaImage(themedImage);
4949
if (activeTabData.caption && imageProps) {
5050
Object.assign(imageProps, {
51-
'aria-describedby': captionId,
51+
extraProps: {
52+
'aria-describedby': captionId,
53+
},
5254
});
5355
}
5456
}

src/components/Image/Image.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
1-
import React, {CSSProperties, Fragment, MouseEventHandler, useContext, useState} from 'react';
1+
import React, {
2+
CSSProperties,
3+
Fragment,
4+
HTMLProps,
5+
MouseEventHandler,
6+
useContext,
7+
useState,
8+
} from 'react';
29

310
import {BREAKPOINTS} from '../../constants';
411
import {ProjectSettingsContext} from '../../context/projectSettingsContext';
512
import {ImageDeviceProps, ImageObjectProps, QAProps} from '../../models';
613
import {getQaAttrubutes} from '../../utils';
714
import {isCompressible} from '../../utils/imageCompress';
8-
import ImageBase from '../ImageBase/ImageBase';
15+
import ImageBase, {ImageBaseProps} from '../ImageBase/ImageBase';
916

1017
export interface ImageProps extends Partial<ImageObjectProps>, Partial<ImageDeviceProps>, QAProps {
1118
style?: CSSProperties;
1219
className?: string;
1320
onClick?: MouseEventHandler;
1421
containerClassName?: string;
22+
extraProps?: Omit<HTMLProps<HTMLImageElement>, keyof ImageBaseProps>;
1523
}
1624

1725
export interface DeviceSpecificFragmentProps extends QAProps {
@@ -57,6 +65,7 @@ const Image = (props: ImageProps) => {
5765
onClick,
5866
containerClassName,
5967
qa,
68+
extraProps,
6069
} = props;
6170
const [imgLoadingError, setImgLoadingError] = useState(false);
6271

@@ -113,6 +122,7 @@ const Image = (props: ImageProps) => {
113122
style={style}
114123
onClick={onClick}
115124
onError={() => setImgLoadingError(true)}
125+
{...extraProps}
116126
/>
117127
</picture>
118128
);

src/models/constructor-items/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ interface LoopProps {
124124

125125
// images
126126

127-
export interface ImageInfoProps extends Pick<HTMLProps<HTMLImageElement>, 'aria-describedby'> {
127+
export interface ImageInfoProps {
128128
alt?: string;
129129
disableCompress?: boolean;
130130
}

0 commit comments

Comments
 (0)