index.vue
2.17 KB
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
<style lang="scss" scoped>
.menu-icons-container {
padding: 1px 0;
overflow: hidden;
.icon-item {
width: 45px;
height: 45px;
border: 1px solid #efefef;
margin-right: -1px;
margin-top: -1px;
padding: 10px;
text-align: center;
float: left;
font-size: 20px;
line-height: 1;
color: #24292e;
cursor: pointer;
&.selected {
background-color: $primary;
border-color: $primary;
color: #fff;
&:hover {
color: #fff;
}
}
&:hover {
color: $primary;
}
}
span {
display: block;
font-size: 16px;
margin-top: 10px;
}
.disabled {
pointer-events: none;
}
}
</style>
<template>
<div class="menu-icons-container">
<div
v-for="item of svgIcons"
:key="item"
:class="`icon-item${value === item?' selected':''}`"
@click="handleClick(item,$event)"
>
<svg-icon :icon-class="item" class-name="disabled"/>
</div>
</div>
</template>
<script>
import svgIcons from './svg-icons';
import elementIcons from './element-icons';
export default {
name: 'MenuIcons',
props: {
value: {
type: String,
default: ''
}
},
data() {
return {
svgIcons,
elementIcons
};
},
methods: {
generateIconCode(symbol) {
return `<svg-icon icon-class="${symbol}" />`;
},
generateElementIconCode(symbol) {
return `<i class="el-icon-${symbol}" />`;
},
handleClick(item, event) {
if (this.value === item) {
this.$emit('input', '');
return;
}
this.$emit('input', item);
}
}
};
</script>