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

feat(ui): portainer base component css change [EE-3381] (#7115)

This commit is contained in:
Chaim Lev-Ari 2022-06-23 09:32:18 +03:00 committed by GitHub
parent 825269c119
commit f78a6568a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
70 changed files with 999 additions and 1596 deletions

View file

@ -0,0 +1,48 @@
import clsx from 'clsx';
import { ComponentType, ReactNode, useEffect } from 'react';
import featherIcons from 'feather-icons';
import { isValidElementType } from 'react-is';
export interface IconProps {
icon: ReactNode | ComponentType<unknown>;
featherIcon?: boolean;
}
interface Props {
icon: ReactNode | ComponentType<unknown>;
feather?: boolean;
className?: string;
}
export function Icon({ icon, feather, className }: Props) {
useEffect(() => {
if (feather) {
featherIcons.replace();
}
}, [feather]);
if (typeof icon !== 'string') {
const Icon = isValidElementType(icon) ? icon : null;
return (
<span className={className} aria-hidden="true" role="img">
{Icon == null ? <>{icon}</> : <Icon />}
</span>
);
}
if (feather) {
return (
<i
data-feather={icon}
className={className}
aria-hidden="true"
role="img"
/>
);
}
return (
<i className={clsx('fa', icon, className)} aria-hidden="true" role="img" />
);
}