Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | 1417x 3x 3x 3x 3x 1414x 1414x 15554x 15554x 1414x | import { IconDefinition } from '@fortawesome/fontawesome-common-types'; export type FontAwesomeIconStandalone = { iconName?: string; width?: number; height?: number; svgPathData?: string; }; export type ParsedIcon = | IconDefinition | { viewBoxHeight: number; viewBoxWidth: number; paths: Array<string>; }; export type ParsedIcons = { [key: string]: ParsedIcon }; export type Opts = { prefix?: string; type?: 'font-awesome' | 'font-awesome-standalone'; }; export type Icons = IconDefinition[] | FontAwesomeIconStandalone[]; export function parseIcons(icons: Icons, { prefix, type }: Opts = {}): ParsedIcons { if (type === 'font-awesome') { const parsedIcons = (icons as IconDefinition[]).reduce((newIcons, { iconName, icon: iconDetails }) => { Iif (!iconDetails) return newIcons; return { ...newIcons, [`${prefix || ''}${iconName}`]: { viewBoxWidth: iconDetails[0], viewBoxHeight: iconDetails[1], paths: [iconDetails[4]] } }; }, {}); return parsedIcons as ParsedIcons; } Eif (type === 'font-awesome-standalone') { const parsedIcons = (icons as FontAwesomeIconStandalone[]).reduce( (newIcons, { iconName, height, width, svgPathData }) => { Iif (!iconName) return newIcons; return { ...newIcons, [`${prefix || ''}${iconName}`]: { viewBoxWidth: width, viewBoxHeight: height, paths: [svgPathData] } }; }, {} ); return parsedIcons as ParsedIcons; } return {}; } |