-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathSimpleLineIcons.js
66 lines (64 loc) · 1.43 KB
/
SimpleLineIcons.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
import 'simple-line-icons/css/simple-line-icons.css'
import './style.css'
import svgIcon from './svgSLIcons.js'
const camelCased = (string) => string.replace(/-([a-z])/g, (g) => g[1].toUpperCase())
export default {
name: 'SimpleLineIcons',
props: {
icon: {
type: String,
required: true
},
size: {
type: String,
validator: function (value) {
return value === 'small' || value === 'large'
}
},
rotate: {
type: Number,
validator: function (value) {
return value >= 0 && value <= 360
}
},
color: String,
noSvg: {
type: Boolean,
default: false
}
},
computed: {
classes () {
return {
[`sli-${this.noSvg ? 'font icon-' : 'svg '}${this.icon}`]: true,
[this.size]: !!this.size
}
}
},
render (h) {
return this.noSvg
? h('i', {
class: this.classes,
style: {
transform: `rotate(${this.rotate}deg)`,
color: this.color
}
})
: h('svg', {
class: this.classes,
attrs: {
xmlns: 'http://www.w3.org/2000/svg',
'xmlns:xlink': 'http://www.w3.org/1999/xlink',
viewBox: '0 0 32 32',
fill: this.color
},
style: { transform: `rotate(${this.rotate}deg)` }
}, [
h('path', {
attrs: {
d: svgIcon[camelCased(this.icon)]
}
})
])
}
}