This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Zaimki/components/Icon.vue

35 lines
1.0 KiB
Vue
Raw Normal View History

2020-07-22 13:19:23 -07:00
<template>
2021-06-27 03:16:14 -07:00
<img v-if="iconSource" :src="iconSource" :style="`height: ${size}em; width: ${size}em; display: inline;`" alt="" class="icon"/>
2021-04-06 06:15:59 -07:00
<span v-else :class="['fa' + iconSet, 'fa-' + icon, 'fa-fw']" :style="`font-size: ${size}em`"></span>
2020-07-22 13:19:23 -07:00
</template>
<script>
export default {
props: {
v: { required: true },
2020-07-26 07:41:46 -07:00
set: { default: 'l' },
2020-09-25 03:17:02 -07:00
size: { default: 1 },
2021-04-06 06:15:59 -07:00
},
computed: {
valueParts() {
return this.v.split(':');
},
icon() {
return this.valueParts[this.valueParts.length - 1];
},
iconSet() {
return this.valueParts.length > 1 ? this.valueParts[0] : this.set;
},
2021-06-27 03:16:14 -07:00
iconSource() {
if (this.v.endsWith('.svg')) {
return `/img/${this.v}`;
}
if (this.v.startsWith('https://')) {
return this.v;
}
return null;
},
2021-04-06 06:15:59 -07:00
},
2020-07-22 13:19:23 -07:00
}
</script>