Skip to content

Commit

Permalink
[Fleet] Lazy load package icons in integrations grid (#132455)
Browse files Browse the repository at this point in the history
(cherry picked from commit 6cf8ebf)

# Conflicts:
#	x-pack/plugins/fleet/public/components/package_icon.tsx
  • Loading branch information
joshdover committed May 30, 2022
1 parent 5995138 commit e517185
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions x-pack/plugins/fleet/public/components/package_icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import { usePackageIconType } from '../hooks';
export const PackageIcon: React.FunctionComponent<UsePackageIconType & Omit<EuiIconProps, 'type'>> =
({ packageName, integrationName, version, icons, tryApi, ...euiIconProps }) => {
const iconType = usePackageIconType({ packageName, integrationName, version, icons, tryApi });
return <EuiIcon size="s" type={iconType} {...euiIconProps} />;
// @ts-expect-error loading="lazy" is not supported by EuiIcon
return <EuiIcon size="s" type={iconType} {...euiIconProps} loading="lazy" />;
};

export const CardIcon: React.FunctionComponent<UsePackageIconType & Omit<EuiIconProps, 'type'>> = (
Expand All @@ -25,7 +26,8 @@ export const CardIcon: React.FunctionComponent<UsePackageIconType & Omit<EuiIcon
if (icons && icons.length === 1 && icons[0].type === 'eui') {
return <EuiIcon size={'xl'} type={icons[0].src} {...props} />;
} else if (icons && icons.length === 1 && icons[0].type === 'svg') {
return <EuiIcon size={'xl'} type={icons[0].src} {...props} />;
// @ts-expect-error loading="lazy" is not supported by EuiIcon
return <EuiIcon size={'xl'} type={icons[0].src} {...props} loading="lazy" />;
} else {
return <PackageIcon {...props} />;
}
Expand Down

0 comments on commit e517185

Please sign in to comment.