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

feat(ui): ui-improvements-helm EE-3476 (#7344)

* feat(ui): helm views ui update EE-3476
This commit is contained in:
Ali 2022-08-01 19:13:58 +12:00 committed by GitHub
parent e28a1491d4
commit 57e53d1a21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 283 additions and 119 deletions

View file

@ -0,0 +1,58 @@
import clsx from 'clsx';
import { useEffect, useState } from 'react';
import { Icon, IconMode, IconSize } from './Icon';
interface Props {
// props for the image to load
src: string; // a link to an external image
fallbackIcon: string;
alt?: string;
size?: IconSize;
className?: string;
// additional fallback icon props
fallbackMode?: IconMode;
fallbackClassName?: string;
feather?: boolean;
}
export function FallbackImage({
src,
fallbackIcon,
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) {
return (
<img
className={classes}
src={src}
alt={alt}
onError={() => setError(true)}
/>
);
}
// fallback icon if there is an error loading the image
return (
<Icon
icon={fallbackIcon}
feather={feather}
className={fallbackClassName}
size={size}
mode={fallbackMode}
/>
);
}