/
index.js
39 lines (35 loc) · 1.07 KB
/
index.js
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
// @flowIgnore
import * as React from "react";
import { library } from "@fortawesome/fontawesome-svg-core";
import type { PluginType } from "webiny-plugins/types";
import { fab } from "@fortawesome/free-brands-svg-icons";
import { fas } from "@fortawesome/free-solid-svg-icons";
import { far } from "@fortawesome/free-regular-svg-icons";
const createSvg = (icon: Object) => {
return (
<svg width={24} viewBox={`0 0 ${icon[0]} ${icon[1]}`}>
<path d={icon[4]} fill="currentColor" />
</svg>
);
};
const icons = [];
export default ({
name: "cms-icons-fontawesome",
type: "cms-icons",
init() {
library.add(fab, fas, far);
Object.keys(library.definitions).forEach(pack => {
const defs = library.definitions[pack];
Object.keys(defs).forEach(icon => {
icons.push({
id: [pack, icon],
name: icon,
svg: createSvg(defs[icon])
});
});
});
},
getIcons() {
return icons;
}
}: PluginType);