import { IconPathData } from "@fortawesome/fontawesome-svg-core"; import { IconDefinition } from "@fortawesome/free-solid-svg-icons"; import { forwardRef, FunctionComponent, SVGProps } from "react"; export const FontAwesomeIconPath: FunctionComponent<{ svgPathData: IconPathData; fill?: string; }> = ({ svgPathData, fill }) => { return typeof svgPathData === "string" ? ( ) : ( <> { /** * A multi-path Font Awesome icon seems to imply a duotune icon. The 0th path seems to * be the faded element (referred to as the "secondary" path in the Font Awesome docs) * of a duotone icon. 40% is the default opacity. * * @see https://fontawesome.com/how-to-use/on-the-web/styling/duotone-icons#changing-opacity */ svgPathData.map((pathData: string, i: number) => ( )) } ); }; export type FontAwesomeIconProps = { icon: IconDefinition; } & SVGProps; // gotten from https://mui.com/components/icons/#font-awesome export const FontAwesomeIcon = forwardRef< SVGSVGElement, FontAwesomeIconProps // https://github.com/prettier/prettier/issues/11923 >((props, ref) => { const { children, icon, ...otherProps } = props; const { icon: [width, height, , , svgPathData], } = icon; return ( {children} ); });