Skip to content

Commit 0a439ad

Browse files
committed
refactor: replace Progressing component with Icon in GenericSectionErrorState; add lazy loading to images in ImageWithFallback; enhance type definitions for imageProps and ScannedByToolModal
1 parent 2185e42 commit 0a439ad

File tree

6 files changed

+22
-15
lines changed

6 files changed

+22
-15
lines changed

src/Shared/Components/GenericSectionErrorState/GenericSectionErrorState.component.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
import { ReactNode } from 'react'
1818
import { ComponentSizeType } from '@Shared/constants'
19-
import { Progressing } from '@Common/Progressing'
2019
import { ReactComponent as ErrorIcon } from '@Icons/ic-error-exclamation.svg'
2120
import { ReactComponent as ICInfoOutline } from '@Icons/ic-info-outline.svg'
21+
import { Icon } from '../Icon'
2222
import { Button, ButtonVariantType } from '../Button'
2323
import { GenericSectionErrorStateProps } from './types'
2424

@@ -35,7 +35,7 @@ const GenericSectionErrorState = ({
3535
}: GenericSectionErrorStateProps) => {
3636
const renderMarker = () => {
3737
if (progressingProps) {
38-
return <Progressing {...progressingProps} />
38+
return <Icon name="ic-circle-loader" {...progressingProps} />
3939
}
4040

4141
if (useInfoIcon) {

src/Shared/Components/GenericSectionErrorState/types.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
import { ReactNode } from 'react'
18-
import { ProgressingProps } from '@Common/Types'
18+
import { IconsProps } from '../Icon'
1919

2020
export type GenericSectionErrorStateProps = {
2121
/**
@@ -51,10 +51,10 @@ export type GenericSectionErrorStateProps = {
5151
} & (
5252
| {
5353
/**
54-
* If provided, would render the Progressing component with given props instead of error icon
54+
* If provided, Icon with ic-circle-loader
5555
*/
56-
progressingProps: ProgressingProps
57-
useInfoIcon?: never
56+
progressingProps: Omit<IconsProps, 'name'>
57+
useInfoIcon?: false
5858
}
5959
| {
6060
progressingProps?: never
@@ -63,7 +63,7 @@ export type GenericSectionErrorStateProps = {
6363
*
6464
* @default false
6565
*/
66-
useInfoIcon: boolean
66+
useInfoIcon: true
6767
}
6868
| {
6969
progressingProps?: never

src/Shared/Components/ImageWithFallback/ImageWithFallback.component.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@ const ImageWithFallback = ({ imageProps, fallbackImage }: ImageWithFallbackProps
4040
// eslint-disable-next-line react/jsx-no-useless-fragment
4141
<>
4242
{imageUrl || (!imageUrl && typeof fallbackImage === 'string') ? (
43-
<img alt="" {...imageProps} src={imageUrl || (fallbackImage as string)} onError={handleImageError} />
43+
<img
44+
loading="lazy"
45+
alt=""
46+
{...imageProps}
47+
src={imageUrl || (fallbackImage as string)}
48+
onError={handleImageError}
49+
/>
4450
) : (
4551
fallbackImage
4652
)}

src/Shared/Components/ImageWithFallback/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ export interface ImageWithFallbackProps {
2020
/**
2121
* Props for the image
2222
*/
23-
imageProps: ImgHTMLAttributes<HTMLImageElement>
23+
imageProps: Omit<ImgHTMLAttributes<HTMLImageElement>, 'alt' | 'height' | 'width'> &
24+
Required<Pick<ImgHTMLAttributes<HTMLImageElement>, 'alt' | 'height' | 'width'>>
2425
/**
2526
* Fallback image; can be a url or a jsx element
2627
*/

src/Shared/Components/ScannedByToolModal/ScannedByToolModal.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ const ScannedByToolModal: React.FC<ScannedByToolModalProps> = ({
3737
src: scanToolUrl,
3838
className: 'icon-dim-20-imp',
3939
alt: 'scan-tool',
40+
height: 20,
41+
width: 20,
4042
}}
4143
fallbackImage={<ICScanFallback className="icon-dim-20-imp dc__no-shrink" />}
4244
/>

src/Shared/Components/SelectPicker/common.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ export const SelectPickerOption = <OptionValue, IsMulti extends boolean>({
195195
selectOption(data)
196196
}
197197

198+
const iconBaseClass = 'dc__no-shrink icon-dim-16 flex dc__fill-available-space'
199+
198200
return (
199201
<components.Option {...props}>
200202
<Tooltip {...getTooltipProps(tooltipProps)}>
@@ -210,9 +212,7 @@ export const SelectPickerOption = <OptionValue, IsMulti extends boolean>({
210212
/>
211213
)}
212214
<div className={`flex left w-100 ${showDescription ? 'top' : ''} dc__gap-8`}>
213-
{startIcon && (
214-
<div className="dc__no-shrink icon-dim-16 flex dc__fill-available-space">{startIcon}</div>
215-
)}
215+
{startIcon && <div className={`${iconBaseClass} mt-2`}>{startIcon}</div>}
216216
<div className="flex-grow-1">
217217
<Tooltip content={label} placement="right">
218218
<h4
@@ -233,9 +233,7 @@ export const SelectPickerOption = <OptionValue, IsMulti extends boolean>({
233233
<div className="fs-12 lh-18">{description}</div>
234234
))}
235235
</div>
236-
{endIcon && (
237-
<div className="dc__no-shrink icon-dim-16 flex dc__fill-available-space">{endIcon}</div>
238-
)}
236+
{endIcon && <div className={iconBaseClass}>{endIcon}</div>}
239237
</div>
240238
</div>
241239
</Tooltip>

0 commit comments

Comments
 (0)