2020-01-29 11:37:25 -08:00
|
|
|
<template>
|
2020-10-17 04:12:00 -07:00
|
|
|
<MkModal ref="modal" :src="src" @click="$refs.modal.close()" @closed="$emit('closed')">
|
|
|
|
<div class="omfetrab _popup">
|
2020-01-29 11:37:25 -08:00
|
|
|
<header>
|
2020-03-21 18:51:40 -07:00
|
|
|
<button v-for="(category, i) in categories"
|
2020-01-29 11:37:25 -08:00
|
|
|
class="_button"
|
|
|
|
@click="go(category)"
|
|
|
|
:class="{ active: category.isActive }"
|
2020-03-21 18:51:40 -07:00
|
|
|
:key="i"
|
2020-01-29 11:37:25 -08:00
|
|
|
>
|
2020-10-17 04:12:00 -07:00
|
|
|
<Fa :icon="category.icon" fixed-width/>
|
2020-01-29 11:37:25 -08:00
|
|
|
</button>
|
|
|
|
</header>
|
|
|
|
|
|
|
|
<div class="emojis">
|
|
|
|
<template v-if="categories[0].isActive">
|
2020-10-17 04:12:00 -07:00
|
|
|
<header class="category"><Fa :icon="faHistory" fixed-width/> {{ $t('recentUsed') }}</header>
|
2020-01-29 11:37:25 -08:00
|
|
|
<div class="list">
|
2020-10-17 04:12:00 -07:00
|
|
|
<button v-for="emoji in ($store.state.device.recentEmojis || [])"
|
2020-01-29 11:37:25 -08:00
|
|
|
class="_button"
|
|
|
|
:title="emoji.name"
|
|
|
|
@click="chosen(emoji)"
|
2020-10-17 04:12:00 -07:00
|
|
|
:key="emoji"
|
2020-01-29 11:37:25 -08:00
|
|
|
>
|
2020-10-17 04:12:00 -07:00
|
|
|
<MkEmoji v-if="emoji.char != null" :emoji="emoji.char"/>
|
2020-01-29 11:37:25 -08:00
|
|
|
<img v-else :src="$store.state.device.disableShowingAnimatedImages ? getStaticImageUrl(emoji.url) : emoji.url"/>
|
|
|
|
</button>
|
|
|
|
</div>
|
2020-03-21 18:51:40 -07:00
|
|
|
|
2020-10-17 04:12:00 -07:00
|
|
|
<header class="category"><Fa :icon="faAsterisk" fixed-width/> {{ $t('customEmojis') }}</header>
|
2020-01-29 11:37:25 -08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<template v-if="categories.find(x => x.isActive).name">
|
|
|
|
<div class="list">
|
|
|
|
<button v-for="emoji in emojilist.filter(e => e.category === categories.find(x => x.isActive).name)"
|
|
|
|
class="_button"
|
|
|
|
:title="emoji.name"
|
|
|
|
@click="chosen(emoji)"
|
|
|
|
:key="emoji.name"
|
|
|
|
>
|
2020-10-17 04:12:00 -07:00
|
|
|
<MkEmoji :emoji="emoji.char"/>
|
2020-01-29 11:37:25 -08:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
<div v-for="(key, i) in Object.keys(customEmojis)" :key="i">
|
|
|
|
<header class="sub" v-if="key">{{ key }}</header>
|
|
|
|
<div class="list">
|
|
|
|
<button v-for="emoji in customEmojis[key]"
|
|
|
|
class="_button"
|
|
|
|
:title="emoji.name"
|
|
|
|
@click="chosen(emoji)"
|
|
|
|
:key="emoji.name"
|
|
|
|
>
|
|
|
|
<img :src="$store.state.device.disableShowingAnimatedImages ? getStaticImageUrl(emoji.url) : emoji.url"/>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-10-17 04:12:00 -07:00
|
|
|
</MkModal>
|
2020-01-29 11:37:25 -08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-11-02 22:49:31 -08:00
|
|
|
import { defineComponent, markRaw } from 'vue';
|
2020-01-29 11:37:25 -08:00
|
|
|
import { emojilist } from '../../misc/emojilist';
|
2020-10-17 04:12:00 -07:00
|
|
|
import { getStaticImageUrl } from '@/scripts/get-static-image-url';
|
2020-05-15 04:49:01 -07:00
|
|
|
import { faAsterisk, faLeaf, faUtensils, faFutbol, faCity, faDice, faGlobe, faHistory, faUser } from '@fortawesome/free-solid-svg-icons';
|
2020-01-29 11:37:25 -08:00
|
|
|
import { faHeart, faFlag, faLaugh } from '@fortawesome/free-regular-svg-icons';
|
|
|
|
import { groupByX } from '../../prelude/array';
|
2020-10-17 04:12:00 -07:00
|
|
|
import MkModal from '@/components/ui/modal.vue';
|
2020-01-29 11:37:25 -08:00
|
|
|
|
2020-10-17 04:12:00 -07:00
|
|
|
export default defineComponent({
|
2020-01-29 11:37:25 -08:00
|
|
|
components: {
|
2020-10-17 04:12:00 -07:00
|
|
|
MkModal,
|
2020-01-29 11:37:25 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
2020-10-17 04:12:00 -07:00
|
|
|
src: {
|
|
|
|
required: false
|
2020-01-29 11:37:25 -08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2020-10-17 04:12:00 -07:00
|
|
|
emits: ['done', 'closed'],
|
|
|
|
|
2020-01-29 11:37:25 -08:00
|
|
|
data() {
|
|
|
|
return {
|
2020-11-02 22:49:31 -08:00
|
|
|
emojilist: markRaw(emojilist),
|
2020-01-29 11:37:25 -08:00
|
|
|
getStaticImageUrl,
|
|
|
|
customEmojis: {},
|
|
|
|
faGlobe, faHistory,
|
|
|
|
categories: [{
|
|
|
|
icon: faAsterisk,
|
|
|
|
isActive: true
|
|
|
|
}, {
|
2020-05-15 04:49:01 -07:00
|
|
|
name: 'face',
|
2020-01-29 11:37:25 -08:00
|
|
|
icon: faLaugh,
|
|
|
|
isActive: false
|
2020-05-15 04:49:01 -07:00
|
|
|
}, {
|
|
|
|
name: 'people',
|
|
|
|
icon: faUser,
|
|
|
|
isActive: false
|
2020-01-29 11:37:25 -08:00
|
|
|
}, {
|
|
|
|
name: 'animals_and_nature',
|
|
|
|
icon: faLeaf,
|
|
|
|
isActive: false
|
|
|
|
}, {
|
|
|
|
name: 'food_and_drink',
|
|
|
|
icon: faUtensils,
|
|
|
|
isActive: false
|
|
|
|
}, {
|
|
|
|
name: 'activity',
|
|
|
|
icon: faFutbol,
|
|
|
|
isActive: false
|
|
|
|
}, {
|
|
|
|
name: 'travel_and_places',
|
|
|
|
icon: faCity,
|
|
|
|
isActive: false
|
|
|
|
}, {
|
|
|
|
name: 'objects',
|
|
|
|
icon: faDice,
|
|
|
|
isActive: false
|
|
|
|
}, {
|
|
|
|
name: 'symbols',
|
|
|
|
icon: faHeart,
|
|
|
|
isActive: false
|
|
|
|
}, {
|
|
|
|
name: 'flags',
|
|
|
|
icon: faFlag,
|
|
|
|
isActive: false
|
2020-05-05 22:46:45 -07:00
|
|
|
}],
|
|
|
|
faAsterisk
|
2020-01-29 11:37:25 -08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
2020-02-10 06:17:42 -08:00
|
|
|
let local = this.$store.state.instance.meta.emojis;
|
2020-01-29 11:37:25 -08:00
|
|
|
local = groupByX(local, (x: any) => x.category || '');
|
2020-11-02 22:49:31 -08:00
|
|
|
this.customEmojis = markRaw(local);
|
2020-01-29 11:37:25 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
go(category: any) {
|
|
|
|
this.goCategory(category.name);
|
|
|
|
},
|
|
|
|
|
|
|
|
goCategory(name: string) {
|
|
|
|
let matched = false;
|
|
|
|
for (const c of this.categories) {
|
|
|
|
c.isActive = c.name === name;
|
|
|
|
if (c.isActive) {
|
|
|
|
matched = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!matched) {
|
|
|
|
this.categories[0].isActive = true;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
chosen(emoji: any) {
|
|
|
|
const getKey = (emoji: any) => emoji.char || `:${emoji.name}:`;
|
|
|
|
let recents = this.$store.state.device.recentEmojis || [];
|
|
|
|
recents = recents.filter((e: any) => getKey(e) !== getKey(emoji));
|
|
|
|
recents.unshift(emoji)
|
|
|
|
this.$store.commit('device/set', { key: 'recentEmojis', value: recents.splice(0, 16) });
|
2020-10-17 04:12:00 -07:00
|
|
|
this.$emit('done', getKey(emoji));
|
|
|
|
this.$refs.modal.close();
|
2020-01-29 11:37:25 -08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.omfetrab {
|
|
|
|
width: 350px;
|
|
|
|
|
|
|
|
> header {
|
|
|
|
display: flex;
|
|
|
|
|
|
|
|
> button {
|
|
|
|
flex: 1;
|
|
|
|
padding: 10px 0;
|
|
|
|
font-size: 16px;
|
|
|
|
transition: color 0.2s ease;
|
|
|
|
|
|
|
|
&:hover {
|
2020-10-27 02:11:41 -07:00
|
|
|
color: var(--fgHighlighted);
|
2020-01-29 11:37:25 -08:00
|
|
|
transition: color 0s;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.active {
|
|
|
|
color: var(--accent);
|
|
|
|
transition: color 0s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .emojis {
|
|
|
|
height: 300px;
|
|
|
|
overflow-y: auto;
|
|
|
|
overflow-x: hidden;
|
|
|
|
|
|
|
|
> header.category {
|
|
|
|
position: sticky;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
z-index: 1;
|
|
|
|
padding: 8px;
|
|
|
|
background: var(--panel);
|
|
|
|
font-size: 12px;
|
|
|
|
}
|
|
|
|
|
|
|
|
header.sub {
|
|
|
|
padding: 4px 8px;
|
|
|
|
font-size: 12px;
|
|
|
|
}
|
|
|
|
|
|
|
|
div.list {
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
|
|
|
|
gap: 4px;
|
|
|
|
padding: 8px;
|
|
|
|
|
|
|
|
> button {
|
|
|
|
position: relative;
|
|
|
|
padding: 0;
|
|
|
|
width: 100%;
|
|
|
|
|
|
|
|
&:before {
|
|
|
|
content: '';
|
|
|
|
display: block;
|
|
|
|
width: 1px;
|
|
|
|
height: 0;
|
|
|
|
padding-bottom: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
> * {
|
|
|
|
transform: scale(1.2);
|
|
|
|
transition: transform 0s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> * {
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
object-fit: contain;
|
|
|
|
font-size: 28px;
|
|
|
|
transition: transform 0.2s ease;
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|