import classNames from 'classnames'; import { isProduction } from 'flavours/glitch/utils/environment'; import CheckBoxOutlineBlankIcon from 'mastodon/../material-icons/400-24px/check_box_outline_blank.svg?react'; interface SVGPropsWithTitle extends React.SVGProps { title?: string; } export type IconProp = React.FC; interface Props extends React.SVGProps { children?: never; id: string; icon: IconProp; title?: string; } export const Icon: React.FC = ({ id, icon: IconComponent, className, title: titleProp, ...other }) => { // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (!IconComponent) { if (!isProduction()) { throw new Error( ` is missing an "icon" prop.`, ); } IconComponent = CheckBoxOutlineBlankIcon; } const ariaHidden = titleProp ? undefined : true; const role = !ariaHidden ? 'img' : undefined; // Set the title to an empty string to remove the built-in SVG one if any // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const title = titleProp || ''; return ( ); };