This repository has been archived by the owner on Jan 31, 2023. It is now read-only.
/
Icon.js
106 lines (92 loc) · 1.82 KB
/
Icon.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
const { createElement: h } = require('react')
const { Icon: Reline } = require('reline')
const Geomicon = require('react-geomicons').default
const geomiconsKeys = require('./geomicons-keys')
const relineKeys = require('./reline-keys')
const simplePaths = require('./simple-icons')
const mdPaths = require('./material-design-icons')
const simpleKeys = Object.keys(simplePaths)
const mdKeys = Object.keys(mdPaths)
const Simple = ({
name,
size,
color
}) => {
const d = simplePaths[name]
if (!d) return null
return (
h('svg', {
xmlns: 'http://www.w3.org/2000/svg',
viewBox: '0 0 16 16',
width: size,
height: size,
fill: color,
fillRule: 'evenodd',
clipRule: 'evenodd',
strokeLinejoin: 'round',
strokeMiterlimit: '1.414',
},
h('path', {
fillRule: 'nonzero',
d
})
)
)
}
const MD = ({
name,
size,
color
}) => {
const d = mdPaths[name]
if (!d) return null
return (
h('svg', {
xmlns: 'http://www.w3.org/2000/svg',
viewBox: '0 0 24 24',
width: size,
height: size,
fill: color
},
h('path', { d })
)
)
}
const Icon = (props) => {
const {
name,
color,
size = 16
} = props
if (simpleKeys.includes(name)) {
return h(Simple, Object.assign({}, props, {
name,
size,
color
}))
}
if (relineKeys.includes(name)) {
return h(Reline, Object.assign({}, props, {
name,
size,
color
}))
}
if (mdKeys.includes(name)) {
return h(MD, Object.assign({}, props, {
name,
size,
color
}))
}
if (geomiconsKeys.includes(name)) {
return h(Geomicon, Object.assign({}, props, {
xmlns: 'http://www.w3.org/2000/svg',
name,
size,
fill: color
}))
}
return null
}
module.exports = Icon