UNPKG

1.83 kBJavaScriptView Raw
1import createMultiStyleIconSet from './createMultiStyleIconSet';
2export const FA5Style = {
3 regular: 'regular',
4 light: 'light',
5 solid: 'solid',
6 brand: 'brand',
7};
8export function createFA5iconSet(glyphMap, metadata = {}, fonts, pro = false) {
9 const metadataKeys = Object.keys(metadata);
10 const fontFamily = `FontAwesome5${pro ? 'Pro' : 'Free'}`;
11 function fallbackFamily(glyph) {
12 for (let i = 0; i < metadataKeys.length; i += 1) {
13 const family = metadataKeys[i];
14 if (metadata[family].indexOf(glyph) !== -1) {
15 return family === 'brands' ? 'brand' : family;
16 }
17 }
18 return 'regular';
19 }
20 function glyphValidator(glyph, style) {
21 const family = style === 'brand' ? 'brands' : style;
22 if (metadataKeys.indexOf(family) === -1)
23 return false;
24 return metadata[family].indexOf(glyph) !== -1;
25 }
26 function createFontAwesomeStyle(styleName, fontWeight, family = fontFamily) {
27 let fontFile = fonts[styleName];
28 return {
29 fontFamily: `${family}-${styleName}`,
30 fontFile,
31 fontStyle: {
32 fontWeight,
33 },
34 glyphMap,
35 };
36 }
37 const brandIcons = createFontAwesomeStyle('Brand', '400');
38 const lightIcons = createFontAwesomeStyle('Light', '100');
39 const regularIcons = createFontAwesomeStyle('Regular', '400');
40 const solidIcons = createFontAwesomeStyle('Solid', '700');
41 const Icon = createMultiStyleIconSet({
42 brand: brandIcons,
43 light: lightIcons,
44 regular: regularIcons,
45 solid: solidIcons,
46 }, {
47 defaultStyle: 'regular',
48 fallbackFamily,
49 glyphValidator,
50 });
51 return Icon;
52}
53//# sourceMappingURL=createIconSetFromFontAwesome5.js.map
\No newline at end of file