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

39 lines
1.3 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-10-26 11:13:42 -07:00
inverse: { type: Boolean }
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() {
2022-01-02 11:45:06 -08:00
if (this.v.startsWith('https://')) {
return this.v;
}
2021-06-27 03:16:14 -07:00
if (this.v.endsWith('.svg')) {
2021-10-26 11:13:42 -07:00
return `/img/${this.inverse ? this.v.replace('.svg', '-inverse.svg') : this.v}`;
2021-06-27 03:16:14 -07:00
}
2021-12-29 06:04:26 -08:00
if (this.v.endsWith('.png')) {
return `/img/${this.inverse ? this.v.replace('.png', '-inverse.png') : this.v}`;
}
2021-06-27 03:16:14 -07:00
return null;
},
2021-04-06 06:15:59 -07:00
},
2020-07-22 13:19:23 -07:00
}
</script>