From 35701f5899b39a869169d1aa692d51476bf542d4 Mon Sep 17 00:00:00 2001 From: Prabhat Khera <91852476+prabhat-org@users.noreply.github.com> Date: Thu, 14 Jul 2022 13:44:56 +1200 Subject: [PATCH] svg support in icons.tsx (#7266) --- app/assets/icons/git-logo.svg | 3 ++ app/react/components/Icon.tsx | 7 ++++ app/react/components/Svg.tsx | 65 +++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 app/assets/icons/git-logo.svg create mode 100644 app/react/components/Svg.tsx diff --git a/app/assets/icons/git-logo.svg b/app/assets/icons/git-logo.svg new file mode 100644 index 000000000..0ff160fa9 --- /dev/null +++ b/app/assets/icons/git-logo.svg @@ -0,0 +1,3 @@ + + + diff --git a/app/react/components/Icon.tsx b/app/react/components/Icon.tsx index 112c65ba9..8413c1410 100644 --- a/app/react/components/Icon.tsx +++ b/app/react/components/Icon.tsx @@ -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; 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 ; + } + if (feather) { return ( + + + ); +} + +export default Svg;