2020-01-29 21:37:25 +02:00
|
|
|
<template>
|
|
|
|
<x-popup :source="source" ref="popup" @closed="() => { $emit('closed'); destroyDom(); }">
|
|
|
|
<div class="omfetrab">
|
|
|
|
<header>
|
2020-03-22 03:51:40 +02:00
|
|
|
<button v-for="(category, i) in categories"
|
2020-01-29 21:37:25 +02:00
|
|
|
class="_button"
|
|
|
|
@click="go(category)"
|
|
|
|
:class="{ active: category.isActive }"
|
2020-03-22 03:51:40 +02:00
|
|
|
:key="i"
|
2020-01-29 21:37:25 +02:00
|
|
|
>
|
|
|
|
<fa :icon="category.icon" fixed-width/>
|
|
|
|
</button>
|
|
|
|
</header>
|
|
|
|
|
|
|
|
<div class="emojis">
|
|
|
|
<template v-if="categories[0].isActive">
|
2020-03-22 03:51:40 +02:00
|
|
|
<header class="category"><fa :icon="faHistory" fixed-width/> {{ $t('recentUsed') }}</header>
|
2020-01-29 21:37:25 +02:00
|
|
|
<div class="list">
|
|
|
|
<button v-for="(emoji, i) in ($store.state.device.recentEmojis || [])"
|
|
|
|
class="_button"
|
|
|
|
:title="emoji.name"
|
|
|
|
@click="chosen(emoji)"
|
|
|
|
:key="i"
|
|
|
|
>
|
|
|
|
<mk-emoji v-if="emoji.char != null" :emoji="emoji.char"/>
|
|
|
|
<img v-else :src="$store.state.device.disableShowingAnimatedImages ? getStaticImageUrl(emoji.url) : emoji.url"/>
|
|
|
|
</button>
|
|
|
|
</div>
|
2020-03-22 03:51:40 +02:00
|
|
|
|
|
|
|
<header class="category"><fa :icon="faAsterisk" fixed-width/> {{ $t('customEmojis') }}</header>
|
2020-01-29 21:37:25 +02: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"
|
|
|
|
>
|
|
|
|
<mk-emoji :emoji="emoji.char"/>
|
|
|
|
</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>
|
|
|
|
</x-popup>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
import { emojilist } from '../../misc/emojilist';
|
|
|
|
import { getStaticImageUrl } from '../scripts/get-static-image-url';
|
2020-05-15 14:49:01 +03:00
|
|
|
import { faAsterisk, faLeaf, faUtensils, faFutbol, faCity, faDice, faGlobe, faHistory, faUser } from '@fortawesome/free-solid-svg-icons';
|
2020-01-29 21:37:25 +02:00
|
|
|
import { faHeart, faFlag, faLaugh } from '@fortawesome/free-regular-svg-icons';
|
|
|
|
import { groupByX } from '../../prelude/array';
|
|
|
|
import XPopup from './popup.vue';
|
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
components: {
|
|
|
|
XPopup,
|
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
source: {
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
emojilist,
|
|
|
|
getStaticImageUrl,
|
|
|
|
customEmojis: {},
|
|
|
|
faGlobe, faHistory,
|
|
|
|
categories: [{
|
|
|
|
icon: faAsterisk,
|
|
|
|
isActive: true
|
|
|
|
}, {
|
2020-05-15 14:49:01 +03:00
|
|
|
name: 'face',
|
2020-01-29 21:37:25 +02:00
|
|
|
icon: faLaugh,
|
|
|
|
isActive: false
|
2020-05-15 14:49:01 +03:00
|
|
|
}, {
|
|
|
|
name: 'people',
|
|
|
|
icon: faUser,
|
|
|
|
isActive: false
|
2020-01-29 21:37:25 +02: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-06 08:46:45 +03:00
|
|
|
}],
|
|
|
|
faAsterisk
|
2020-01-29 21:37:25 +02:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
2020-02-10 16:17:42 +02:00
|
|
|
let local = this.$store.state.instance.meta.emojis;
|
2020-01-29 21:37:25 +02:00
|
|
|
local = groupByX(local, (x: any) => x.category || '');
|
|
|
|
this.customEmojis = local;
|
|
|
|
},
|
|
|
|
|
|
|
|
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) });
|
|
|
|
this.$emit('chosen', getKey(emoji));
|
|
|
|
},
|
|
|
|
|
|
|
|
close() {
|
|
|
|
this.$refs.popup.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</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 {
|
|
|
|
color: var(--textHighlighted);
|
|
|
|
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>
|