2018-11-04 20:19:40 -06:00
|
|
|
<template>
|
2018-11-05 04:20:35 -06:00
|
|
|
<img v-if="customEmoji" class="fvgwvorwhxigeolkkrcderjzcawqrscl custom" :src="url" :alt="alt" :title="alt"/>
|
|
|
|
<img v-else-if="char && !useOsDefaultEmojis" class="fvgwvorwhxigeolkkrcderjzcawqrscl" :src="url" :alt="alt" :title="alt"/>
|
|
|
|
<span v-else-if="char && useOsDefaultEmojis">{{ char }}</span>
|
|
|
|
<span v-else>:{{ name }}:</span>
|
2018-11-04 20:19:40 -06:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
import { lib } from 'emojilib';
|
2018-11-05 01:19:10 -06:00
|
|
|
|
2018-11-04 20:19:40 -06:00
|
|
|
export default Vue.extend({
|
2018-11-04 22:23:26 -06:00
|
|
|
props: {
|
2018-11-05 04:20:35 -06:00
|
|
|
name: {
|
2018-11-04 22:23:26 -06:00
|
|
|
type: String,
|
2018-11-05 00:15:30 -06:00
|
|
|
required: false
|
|
|
|
},
|
2018-11-05 04:20:35 -06:00
|
|
|
emoji: {
|
2018-11-05 00:15:30 -06:00
|
|
|
type: String,
|
|
|
|
required: false
|
2018-11-04 22:23:26 -06:00
|
|
|
},
|
|
|
|
customEmojis: {
|
2018-11-05 04:20:35 -06:00
|
|
|
required: false,
|
|
|
|
default: []
|
2018-11-04 22:23:26 -06:00
|
|
|
}
|
|
|
|
},
|
2018-11-05 04:20:35 -06:00
|
|
|
|
2018-11-04 20:19:40 -06:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
url: null,
|
2018-11-05 04:20:35 -06:00
|
|
|
char: null,
|
|
|
|
customEmoji: null
|
2018-11-04 20:19:40 -06:00
|
|
|
}
|
|
|
|
},
|
2018-11-05 04:20:35 -06:00
|
|
|
|
|
|
|
computed: {
|
|
|
|
alt(): string {
|
2018-11-05 04:33:28 -06:00
|
|
|
return this.customEmoji ? `:${this.customEmoji.name}:` : this.char;
|
2018-11-05 04:20:35 -06:00
|
|
|
},
|
|
|
|
|
|
|
|
useOsDefaultEmojis(): boolean {
|
|
|
|
return this.$store.state.device.useOsDefaultEmojis;
|
|
|
|
}
|
2018-11-04 20:19:40 -06:00
|
|
|
},
|
2018-11-05 04:20:35 -06:00
|
|
|
|
|
|
|
created() {
|
|
|
|
if (this.name) {
|
|
|
|
const customEmoji = this.customEmojis.find(x => x.name == this.name);
|
|
|
|
if (customEmoji) {
|
|
|
|
this.customEmoji = customEmoji;
|
|
|
|
this.url = customEmoji.url;
|
|
|
|
} else {
|
|
|
|
const emoji = lib[this.name];
|
|
|
|
if (emoji) {
|
|
|
|
this.char = emoji.char;
|
2018-11-04 20:19:40 -06:00
|
|
|
}
|
|
|
|
}
|
2018-11-05 04:20:35 -06:00
|
|
|
} else {
|
|
|
|
this.char = this.emoji;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.char) {
|
|
|
|
this.url = `https://twemoji.maxcdn.com/2/svg/${this.char.codePointAt(0).toString(16)}.svg`;
|
2018-11-04 20:19:40 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2018-11-05 04:20:35 -06:00
|
|
|
.fvgwvorwhxigeolkkrcderjzcawqrscl
|
2018-11-05 07:42:08 -06:00
|
|
|
height 1.2em
|
2018-11-05 07:45:45 -06:00
|
|
|
vertical-align -0.15em
|
2018-11-05 04:20:35 -06:00
|
|
|
|
|
|
|
&.custom
|
|
|
|
height 2.5em
|
|
|
|
vertical-align middle
|
2018-11-05 06:04:19 -06:00
|
|
|
transition transform 0.2s ease
|
|
|
|
|
|
|
|
&:hover
|
|
|
|
transform scale(1.2)
|
2018-11-05 04:20:35 -06:00
|
|
|
|
2018-11-04 20:19:40 -06:00
|
|
|
</style>
|