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
|
<template>
<span :class="iconName"
:title="getTitle"
@click="fireEvent($event)"
@dblclick="fireEvent($event)"
@dragstart="fireEvent($event)"
v-on:mouseenter="hoverOn()"
v-on:mouseleave="hoverOff()">
</span>
</template>
<script>
import LocalisationService from '@js/Services/LocalisationService';
export default {
props: {
icon : {
type: String
},
font : {
type : String,
default: 'regular'
},
hoverIcon: {
type : String,
default: null
},
hoverFont: {
type : String,
default: null
},
spin : {
type : Boolean,
default: false
},
title : {
type : String,
default: null
}
},
data() {
return {
hover: false
};
},
computed: {
iconName() {
let icon = this.hover && this.hoverIcon !== null ? this.hoverIcon:this.icon,
font = this.hover && this.hoverFont !== null ? this.hoverFont:this.font,
style = font === 'solid' ? 'fas':'far';
if(this.spin) style += ' fa-spin';
return `icon icon-${icon} font-${font} ${style} fa-${icon}`;
},
getTitle() {
if(!this.title) return;
return LocalisationService.translate(this.title);
}
},
methods: {
hoverOn() {
this.hover = true;
},
hoverOff() {
this.hover = false;
},
fireEvent($event) {
this.$emit($event.type, $event);
}
}
};
</script>
<style lang="scss">
$fa-font-path : "~@fortawesome/fontawesome-free/webfonts";
@import "~@fortawesome/fontawesome-free/scss/regular";
@import "~@fortawesome/fontawesome-free/scss/solid";
@import "~@fortawesome/fontawesome-free/scss/icons";
@import "~@fortawesome/fontawesome-free/scss/animated";
.icon {
min-width : 1em;
box-sizing : content-box;
}
</style>
|