import clsx from 'clsx'; import { ComponentType, ReactNode } from 'react'; import * as lucideIcons from 'lucide-react'; import { isValidElementType } from 'react-is'; import Svg, { SvgIcons } from './Svg'; export interface IconProps { icon: ReactNode | ComponentType; } export type IconMode = | 'alt' | 'primary' | 'primary-alt' | 'secondary' | 'secondary-alt' | 'warning' | 'warning-alt' | 'danger' | 'danger-alt' | 'success' | 'success-alt'; export type IconSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'; interface Props { icon: ReactNode | ComponentType<{ size?: string | number }>; className?: string; size?: IconSize; mode?: IconMode; spin?: boolean; } export function Icon({ icon, className, mode, size, spin }: Props) { const classes = clsx(className, 'icon inline-flex', { [`icon-${mode}`]: mode, [`icon-${size}`]: size, 'animate-spin-slow': spin, }); if (typeof icon !== 'string') { const Icon = isValidElementType(icon) ? icon : null; if (Icon) { return