1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 07:49:41 +02:00

fix(helm): helm charts view bad icon aspect ratio EE-4451 (#7875)

This commit is contained in:
Ali 2022-10-20 14:14:55 +13:00 committed by GitHub
parent 1100a2bd28
commit 368e6b2a44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 104 additions and 81 deletions

View file

@ -1,18 +1,15 @@
import clsx from 'clsx';
import { useEffect, useState } from 'react';
import { Icon, IconMode, IconSize } from './Icon';
import { BadgeIcon, BadgeSize } from './BadgeIcon/BadgeIcon';
interface Props {
// props for the image to load
src: string; // a link to an external image
fallbackIcon: string;
alt?: string;
size?: IconSize;
size?: BadgeSize;
className?: string;
// additional fallback icon props
fallbackMode?: IconMode;
fallbackClassName?: string;
// additional fallback badge props
feather?: boolean;
}
@ -22,22 +19,18 @@ export function FallbackImage({
alt,
size,
className,
fallbackMode,
fallbackClassName,
feather,
}: Props) {
const [error, setError] = useState(false);
const classes = clsx(className, { [`icon-${size}`]: size });
useEffect(() => {
setError(false);
}, [src]);
if (!error) {
if (!error && src) {
return (
<img
className={classes}
className={className}
src={src}
alt={alt}
onError={() => setError(true)}
@ -46,13 +39,5 @@ export function FallbackImage({
}
// fallback icon if there is an error loading the image
return (
<Icon
icon={fallbackIcon}
feather={feather}
className={fallbackClassName}
size={size}
mode={fallbackMode}
/>
);
return <BadgeIcon icon={fallbackIcon} featherIcon={feather} size={size} />;
}