traxxx/assets/components/icon/icon.vue

61 lines
863 B
Vue
Raw Normal View History

<template>
2020-05-25 00:02:28 +00:00
<div
:class="{ active }"
class="icon"
v-html="svg"
/>
</template>
<script>
export default {
2020-05-25 00:02:28 +00:00
props: {
icon: {
type: String,
default: null,
},
title: {
type: String,
default: null,
},
active: {
type: Boolean,
default: false,
},
},
data() {
return {
svg: null,
};
},
beforeMount() {
2022-03-26 16:40:20 +00:00
this.svg = require(`../../img/icons/${this.icon}.svg`).default; // eslint-disable-line global-require, import/no-dynamic-require
2020-05-25 00:02:28 +00:00
},
};
</script>
<style lang="scss">
@import '../../css/theme';
.icon {
2020-05-25 00:02:28 +00:00
fill: var(--text);
display: inline-block;
flex-shrink: 0;
width: 1rem;
height: 1rem;
svg {
width: 100%;
height: 100%;
}
&.active {
2020-05-25 00:02:28 +00:00
fill: var(--shadow);
&:hover {
2020-05-25 00:02:28 +00:00
fill: var(--text);
cursor: pointer;
}
}
}
</style>