2021-09-17 13:39:15 +00:00
|
|
|
<template>
|
|
|
|
<div class="driuhtrh">
|
|
|
|
<div class="query">
|
2021-09-29 15:50:45 +00:00
|
|
|
<MkInput v-model="q" class="" :placeholder="$ts.search">
|
2022-12-19 10:01:30 +00:00
|
|
|
<template #prefix><i class="ti ti-search"></i></template>
|
2021-09-17 13:39:15 +00:00
|
|
|
</MkInput>
|
|
|
|
|
2021-09-25 18:17:16 +00:00
|
|
|
<!-- たくさんあると邪魔
|
2021-09-17 13:39:15 +00:00
|
|
|
<div class="tags">
|
|
|
|
<span class="tag _button" v-for="tag in tags" :class="{ active: selectedTags.has(tag) }" @click="toggleTag(tag)">{{ tag }}</span>
|
|
|
|
</div>
|
2021-09-25 18:16:30 +00:00
|
|
|
-->
|
2021-09-17 13:39:15 +00:00
|
|
|
</div>
|
|
|
|
|
2021-11-19 10:36:12 +00:00
|
|
|
<MkFolder v-if="searchEmojis" class="emojis">
|
2021-09-17 13:39:15 +00:00
|
|
|
<template #header>{{ $ts.searchResult }}</template>
|
|
|
|
<div class="zuvgdzyt">
|
|
|
|
<XEmoji v-for="emoji in searchEmojis" :key="emoji.name" class="emoji" :emoji="emoji"/>
|
|
|
|
</div>
|
|
|
|
</MkFolder>
|
|
|
|
|
2021-11-19 10:36:12 +00:00
|
|
|
<MkFolder v-for="category in customEmojiCategories" :key="category" class="emojis">
|
2021-09-17 13:39:15 +00:00
|
|
|
<template #header>{{ category || $ts.other }}</template>
|
|
|
|
<div class="zuvgdzyt">
|
|
|
|
<XEmoji v-for="emoji in customEmojis.filter(e => e.category === category)" :key="emoji.name" class="emoji" :emoji="emoji"/>
|
|
|
|
</div>
|
|
|
|
</MkFolder>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent, computed } from 'vue';
|
2022-09-06 09:21:49 +00:00
|
|
|
import XEmoji from './emojis.emoji.vue';
|
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2023-01-07 06:09:46 +00:00
|
|
|
import MkInput from '@/components/MkInput.vue';
|
|
|
|
import MkSelect from '@/components/MkSelect.vue';
|
2022-09-06 09:21:49 +00:00
|
|
|
import MkFolder from '@/components/MkFolder.vue';
|
2022-08-30 15:24:33 +00:00
|
|
|
import MkTab from '@/components/MkTab.vue';
|
2021-11-11 17:02:25 +00:00
|
|
|
import * as os from '@/os';
|
|
|
|
import { emojiCategories, emojiTags } from '@/instance';
|
2021-09-17 13:39:15 +00:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
|
|
|
MkButton,
|
|
|
|
MkInput,
|
|
|
|
MkSelect,
|
|
|
|
MkFolder,
|
|
|
|
MkTab,
|
|
|
|
XEmoji,
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
q: '',
|
|
|
|
customEmojiCategories: emojiCategories,
|
|
|
|
customEmojis: this.$instance.emojis,
|
|
|
|
tags: emojiTags,
|
|
|
|
selectedTags: new Set(),
|
|
|
|
searchEmojis: null,
|
2022-06-10 05:36:55 +00:00
|
|
|
};
|
2021-09-17 13:39:15 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
q() { this.search(); },
|
|
|
|
selectedTags: {
|
|
|
|
handler() {
|
|
|
|
this.search();
|
|
|
|
},
|
2022-09-06 09:21:49 +00:00
|
|
|
deep: true,
|
2021-09-17 13:39:15 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
search() {
|
|
|
|
if ((this.q === '' || this.q == null) && this.selectedTags.size === 0) {
|
|
|
|
this.searchEmojis = null;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.selectedTags.size === 0) {
|
2022-05-26 13:53:09 +00:00
|
|
|
this.searchEmojis = this.customEmojis.filter(emoji => emoji.name.includes(this.q) || emoji.aliases.includes(this.q));
|
2021-09-17 13:39:15 +00:00
|
|
|
} else {
|
2022-05-26 13:53:09 +00:00
|
|
|
this.searchEmojis = this.customEmojis.filter(emoji => (emoji.name.includes(this.q) || emoji.aliases.includes(this.q)) && [...this.selectedTags].every(t => emoji.aliases.includes(t)));
|
2021-09-17 13:39:15 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
toggleTag(tag) {
|
|
|
|
if (this.selectedTags.has(tag)) {
|
|
|
|
this.selectedTags.delete(tag);
|
|
|
|
} else {
|
|
|
|
this.selectedTags.add(tag);
|
|
|
|
}
|
2022-09-06 09:21:49 +00:00
|
|
|
},
|
|
|
|
},
|
2021-09-17 13:39:15 +00:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2022-12-27 09:29:39 +00:00
|
|
|
<style lang="scss" scoped>
|
2021-09-17 13:39:15 +00:00
|
|
|
.driuhtrh {
|
|
|
|
background: var(--bg);
|
|
|
|
|
|
|
|
> .query {
|
|
|
|
background: var(--bg);
|
|
|
|
padding: 16px;
|
|
|
|
|
|
|
|
> .tags {
|
|
|
|
> .tag {
|
|
|
|
display: inline-block;
|
|
|
|
margin: 8px 8px 0 0;
|
|
|
|
padding: 4px 8px;
|
|
|
|
font-size: 0.9em;
|
2021-09-20 19:09:28 +00:00
|
|
|
background: var(--accentedBg);
|
2021-09-17 13:39:15 +00:00
|
|
|
border-radius: 5px;
|
|
|
|
|
|
|
|
&.active {
|
2021-09-20 19:09:28 +00:00
|
|
|
background: var(--accent);
|
|
|
|
color: var(--fgOnAccent);
|
2021-09-17 13:39:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .emojis {
|
|
|
|
--x-padding: 0 16px;
|
|
|
|
|
|
|
|
.zuvgdzyt {
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
|
|
|
|
grid-gap: 12px;
|
|
|
|
margin: 0 var(--margin) var(--margin) var(--margin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|