Skip to content

Commit 86127b1

Browse files
committed
chore: replaced LazyImage with ImageWithFallback
1 parent a85d9e2 commit 86127b1

File tree

2 files changed

+303
-308
lines changed

2 files changed

+303
-308
lines changed

src/components/charts/ChartCard.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
ComponentSizeType,
2222
handleAnalyticsEvent,
2323
Icon,
24+
ImageWithFallback,
2425
noop,
2526
stopPropagation,
2627
useMainContext,
@@ -29,9 +30,8 @@ import {
2930
import { ReactComponent as ICCaretSmall } from '@Icons/ic-caret-left-small.svg'
3031
import { InteractiveCellText } from '@Components/common/helpers/InteractiveCellText/InteractiveCellText'
3132

32-
import placeHolder from '../../assets/icons/ic-default-chart.svg'
33+
import { ReactComponent as Helm } from '../../assets/icons/ic-default-chart.svg'
3334
import { SERVER_MODE } from '../../config'
34-
import { LazyImage } from '../common'
3535
import { ChartSelectProps } from './charts.types'
3636
import { renderDeprecatedWarning } from './charts.util'
3737

@@ -46,12 +46,6 @@ const ChartCard = ({
4646
}: ChartSelectProps) => {
4747
const { serverMode } = useMainContext()
4848

49-
const handleImageError = (e): void => {
50-
const target = e.target as HTMLImageElement
51-
target.onerror = null
52-
target.src = placeHolder
53-
}
54-
5549
const addChartTab = (e): void => {
5650
stopPropagation(e)
5751
addChart(chart.id)
@@ -95,13 +89,19 @@ const ChartCard = ({
9589
ariaLabel="Remove chart from selection"
9690
/>
9791
)
92+
const chartIconClass = 'dc__chart-grid-item__icon chart-icon-dim br-4 dc__no-shrink'
9893

9994
const renderIcon = () => (
10095
<div className="icon-wrapper">
101-
<LazyImage
102-
className={`${isListView ? 'dc__list-icon' : ''} dc__chart-grid-item__icon chart-icon-dim br-4`}
103-
src={chart.icon}
104-
onError={handleImageError}
96+
<ImageWithFallback
97+
imageProps={{
98+
height: 32,
99+
width: 32,
100+
src: chart.icon,
101+
alt: 'chart',
102+
className: chartIconClass,
103+
}}
104+
fallbackImage={<Helm className={chartIconClass} />}
105105
/>
106106
</div>
107107
)

0 commit comments

Comments
 (0)