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

svg support in icons.tsx (#7266)

This commit is contained in:
Prabhat Khera 2022-07-14 13:44:56 +12:00 committed by GitHub
parent 3d4d2b50ae
commit 35701f5899
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 75 additions and 0 deletions

View file

@ -3,6 +3,8 @@ import { ComponentType, ReactNode, useEffect } from 'react';
import featherIcons from 'feather-icons';
import { isValidElementType } from 'react-is';
import Svg, { SvgIcons } from './Svg';
export interface IconProps {
icon: ReactNode | ComponentType<unknown>;
featherIcon?: boolean;
@ -51,6 +53,11 @@ export function Icon({ icon, feather, className, mode, size }: Props) {
);
}
if (icon.indexOf('svg-') === 0) {
const svgIcon = icon.replace('svg-', '');
return <Svg icon={svgIcon as keyof typeof SvgIcons} className={classes} />;
}
if (feather) {
return (
<i