2021-09-17 15:39:15 +02:00
|
|
|
<template>
|
2023-04-08 02:01:42 +02:00
|
|
|
<div class="driuhtrh">
|
|
|
|
<div class="query">
|
|
|
|
<MkInput v-model="q" class="" :placeholder="i18n.ts.search">
|
|
|
|
<template #prefix
|
|
|
|
><i class="ph-magnifying-glass ph-bold ph-lg"></i
|
|
|
|
></template>
|
|
|
|
</MkInput>
|
|
|
|
|
|
|
|
<!-- たくさんあると邪魔
|
2021-09-17 15:39:15 +02: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 20:16:30 +02:00
|
|
|
-->
|
2021-09-17 15:39:15 +02:00
|
|
|
</div>
|
2022-11-10 23:12:44 +01:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
<MkFolder v-if="searchEmojis" class="emojis">
|
|
|
|
<template #header>{{ i18n.ts.searchResult }}</template>
|
|
|
|
<div class="zuvgdzyt">
|
|
|
|
<XEmoji
|
|
|
|
v-for="emoji in searchEmojis"
|
|
|
|
:key="emoji.name"
|
|
|
|
class="emoji"
|
|
|
|
:emoji="emoji"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</MkFolder>
|
|
|
|
|
|
|
|
<MkFolder
|
|
|
|
v-for="category in customEmojiCategories"
|
|
|
|
:key="category"
|
|
|
|
class="emojis"
|
|
|
|
>
|
|
|
|
<template #header>{{ category || i18n.ts.other }}</template>
|
|
|
|
<div class="zuvgdzyt">
|
|
|
|
<XEmoji
|
|
|
|
v-for="emoji in customEmojis.filter(
|
2023-07-06 03:28:27 +02:00
|
|
|
(e) => e.category === category,
|
2023-04-08 02:01:42 +02:00
|
|
|
)"
|
|
|
|
:key="emoji.name"
|
|
|
|
class="emoji"
|
|
|
|
:emoji="emoji"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</MkFolder>
|
|
|
|
</div>
|
2021-09-17 15:39:15 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2023-04-08 02:01:42 +02:00
|
|
|
import { defineComponent, computed } from "vue";
|
|
|
|
import XEmoji from "./emojis.emoji.vue";
|
|
|
|
import MkButton from "@/components/MkButton.vue";
|
|
|
|
import MkInput from "@/components/form/input.vue";
|
|
|
|
import MkSelect from "@/components/form/select.vue";
|
|
|
|
import MkFolder from "@/components/MkFolder.vue";
|
|
|
|
import MkTab from "@/components/MkTab.vue";
|
|
|
|
import * as os from "@/os";
|
|
|
|
import { emojiCategories, emojiTags } from "@/instance";
|
|
|
|
import { i18n } from "@/i18n";
|
2021-09-17 15:39:15 +02:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
|
|
|
MkButton,
|
|
|
|
MkInput,
|
|
|
|
MkSelect,
|
|
|
|
MkFolder,
|
|
|
|
MkTab,
|
|
|
|
XEmoji,
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2023-04-08 02:01:42 +02:00
|
|
|
q: "",
|
2021-09-17 15:39:15 +02:00
|
|
|
customEmojiCategories: emojiCategories,
|
|
|
|
customEmojis: this.$instance.emojis,
|
|
|
|
tags: emojiTags,
|
|
|
|
selectedTags: new Set(),
|
|
|
|
searchEmojis: null,
|
2022-11-11 09:41:34 +01:00
|
|
|
i18n,
|
2022-06-10 07:36:55 +02:00
|
|
|
};
|
2021-09-17 15:39:15 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
2023-04-08 02:01:42 +02:00
|
|
|
q() {
|
|
|
|
this.search();
|
|
|
|
},
|
2021-09-17 15:39:15 +02:00
|
|
|
selectedTags: {
|
|
|
|
handler() {
|
|
|
|
this.search();
|
|
|
|
},
|
2022-09-06 11:21:49 +02:00
|
|
|
deep: true,
|
2021-09-17 15:39:15 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
search() {
|
2023-04-08 02:01:42 +02:00
|
|
|
if (
|
|
|
|
(this.q === "" || this.q == null) &&
|
|
|
|
this.selectedTags.size === 0
|
|
|
|
) {
|
2021-09-17 15:39:15 +02:00
|
|
|
this.searchEmojis = null;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.selectedTags.size === 0) {
|
2023-04-08 02:01:42 +02:00
|
|
|
this.searchEmojis = this.customEmojis.filter(
|
|
|
|
(emoji) =>
|
|
|
|
emoji.name.includes(this.q) ||
|
2023-07-06 03:28:27 +02:00
|
|
|
emoji.aliases.includes(this.q),
|
2023-04-08 02:01:42 +02:00
|
|
|
);
|
2021-09-17 15:39:15 +02:00
|
|
|
} else {
|
2023-04-08 02:01:42 +02:00
|
|
|
this.searchEmojis = this.customEmojis.filter(
|
|
|
|
(emoji) =>
|
|
|
|
(emoji.name.includes(this.q) ||
|
|
|
|
emoji.aliases.includes(this.q)) &&
|
|
|
|
[...this.selectedTags].every((t) =>
|
2023-07-06 03:28:27 +02:00
|
|
|
emoji.aliases.includes(t),
|
|
|
|
),
|
2023-04-08 02:01:42 +02:00
|
|
|
);
|
2021-09-17 15:39:15 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
toggleTag(tag) {
|
|
|
|
if (this.selectedTags.has(tag)) {
|
|
|
|
this.selectedTags.delete(tag);
|
|
|
|
} else {
|
|
|
|
this.selectedTags.add(tag);
|
|
|
|
}
|
2022-09-06 11:21:49 +02:00
|
|
|
},
|
|
|
|
},
|
2021-09-17 15:39:15 +02:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.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 21:09:28 +02:00
|
|
|
background: var(--accentedBg);
|
2021-09-17 15:39:15 +02:00
|
|
|
border-radius: 5px;
|
|
|
|
|
|
|
|
&.active {
|
2021-09-20 21:09:28 +02:00
|
|
|
background: var(--accent);
|
|
|
|
color: var(--fgOnAccent);
|
2021-09-17 15:39:15 +02: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>
|