import React, { useEffect, useState } from "react"; import LogoSvg from "./LogoSvg" import LogoutSvg from "./LogoutSvg" import ShareSvg from "./ShareSvg" import GridSvg from "./GridSvg" import UserSvg from "./UserSvg" import ImageSvg from "./ImageSvg" import BankNoteSvg from "./BankNoteSvg" import BuildingSvg from "./BuildingSvg" import UsersSvg from "./UsersSvg" import HomeSvg from "./HomeSvg" import FileSvg from "./FileSvg" import CalenderSvg from "./Calender"; import ReceiptSvg from "./ReceiptSvg"; import MailSvg from "./MailSvg" import SettingsSvg from "./SettingsSvg" import ArrowSvg from "./ArrowSvg" import ChevronSvg from "./ChevronSvg" import TrashSvg from "./TrashSvg" import PencilSvg from "./PencilSvg" import PlusSvg from "./PlusSvg" import MinusSvg from "./MinusSvg" import DotsSvg from "./DotsSvg" import StarSvg from "./StarSvg" const getIcon = (type, className, id, fill, onClick, onKeyUp, variant) => { const icons = { logo: , logout: , pencil: , share: , grid: , user: , image: , banknote: , building: , users: , home: , file: , calender: , receipt: , mail: , settings: , arrow: , chevron: , trash: , plus: , minus: , dots: , star: } return icons[type] || null; } const Icon = ({ className, id, fill = '', onClick, onKeyUp, type, variant }) => { const [icon, setIcon] = useState(null); useEffect(() => { if (type) { // Remove all white space from the string, with the regex const iconType = type.toLocaleLowerCase().replace(/\s+/g, ''); // set the icon based on icon type change, useful for conditional icon renderings setIcon(getIcon(iconType, className, id, fill, onClick, onKeyUp, variant)); } }, [type, className]); return icon; }; export default Icon