Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fleet] Lazy load package icons in integrations grid #132455

Merged
merged 1 commit into from
May 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -16,7 +16,8 @@ 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 @@ -26,7 +27,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