2021-09-17 13:39:15 +00:00
|
|
|
<template>
|
2023-01-15 20:35:01 +00:00
|
|
|
<div class="driuhtrh _gaps">
|
|
|
|
<MkButton v-if="$i && ($i.isModerator || $i.policies.canManageCustomEmojis)" primary link to="/custom-emojis-manager">{{ i18n.ts.manageCustomEmojis }}</MkButton>
|
|
|
|
|
2021-09-17 13:39:15 +00:00
|
|
|
<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">
|
2023-01-09 06:50:25 +00:00
|
|
|
<span class="tag _button" v-for="tag in customEmojiTags" :class="{ active: selectedTags.has(tag) }" @click="toggleTag(tag)">{{ tag }}</span>
|
2021-09-17 13:39:15 +00:00
|
|
|
</div>
|
2021-09-25 18:16:30 +00:00
|
|
|
-->
|
2021-09-17 13:39:15 +00:00
|
|
|
</div>
|
|
|
|
|
2023-01-09 00:41:25 +00:00
|
|
|
<MkFoldableSection 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>
|
2023-01-09 00:41:25 +00:00
|
|
|
</MkFoldableSection>
|
2021-09-17 13:39:15 +00:00
|
|
|
|
2023-01-09 00:41:25 +00:00
|
|
|
<MkFoldableSection v-for="category in customEmojiCategories" v-once :key="category" class="emojis">
|
2021-09-17 13:39:15 +00:00
|
|
|
<template #header>{{ category || $ts.other }}</template>
|
|
|
|
<div class="zuvgdzyt">
|
2023-01-09 00:04:35 +00:00
|
|
|
<XEmoji v-for="emoji in customEmojis.filter(e => e.category === category)" :key="emoji.name" class="emoji" :emoji="emoji"/>
|
2021-09-17 13:39:15 +00:00
|
|
|
</div>
|
2023-01-09 00:41:25 +00:00
|
|
|
</MkFoldableSection>
|
2021-09-17 13:39:15 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2023-01-09 06:50:25 +00:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { defineComponent, computed, watch } 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';
|
2023-01-09 00:41:25 +00:00
|
|
|
import MkFoldableSection from '@/components/MkFoldableSection.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';
|
2023-01-16 10:36:29 +00:00
|
|
|
import { customEmojis, customEmojiCategories, getCustomEmojiTags } from '@/custom-emojis';
|
2023-01-15 20:35:01 +00:00
|
|
|
import { i18n } from '@/i18n';
|
2023-01-16 09:39:58 +00:00
|
|
|
import * as Misskey from 'misskey-js';
|
2021-09-17 13:39:15 +00:00
|
|
|
|
2023-01-09 07:45:05 +00:00
|
|
|
const customEmojiTags = getCustomEmojiTags();
|
2023-01-09 06:50:25 +00:00
|
|
|
let q = $ref('');
|
2023-01-16 09:39:58 +00:00
|
|
|
let searchEmojis = $ref<Misskey.entities.CustomEmoji[]>(null);
|
2023-01-09 06:50:25 +00:00
|
|
|
let selectedTags = $ref(new Set());
|
2021-09-17 13:39:15 +00:00
|
|
|
|
2023-01-09 06:50:25 +00:00
|
|
|
function search() {
|
|
|
|
if ((q === '' || q == null) && selectedTags.size === 0) {
|
|
|
|
searchEmojis = null;
|
|
|
|
return;
|
|
|
|
}
|
2021-09-17 13:39:15 +00:00
|
|
|
|
2023-01-09 06:50:25 +00:00
|
|
|
if (selectedTags.size === 0) {
|
2023-01-16 09:39:58 +00:00
|
|
|
searchEmojis = customEmojis.value.filter(emoji => emoji.name.includes(q) || emoji.aliases.includes(q));
|
2023-01-09 06:50:25 +00:00
|
|
|
} else {
|
2023-01-16 09:39:58 +00:00
|
|
|
searchEmojis = customEmojis.value.filter(emoji => (emoji.name.includes(q) || emoji.aliases.includes(q)) && [...selectedTags].every(t => emoji.aliases.includes(t)));
|
2023-01-09 06:50:25 +00:00
|
|
|
}
|
|
|
|
}
|
2021-09-17 13:39:15 +00:00
|
|
|
|
2023-01-09 06:50:25 +00:00
|
|
|
function toggleTag(tag) {
|
|
|
|
if (selectedTags.has(tag)) {
|
|
|
|
selectedTags.delete(tag);
|
|
|
|
} else {
|
|
|
|
selectedTags.add(tag);
|
|
|
|
}
|
|
|
|
}
|
2021-09-17 13:39:15 +00:00
|
|
|
|
2023-01-09 06:50:25 +00:00
|
|
|
watch($$(q), () => {
|
|
|
|
search();
|
2021-09-17 13:39:15 +00:00
|
|
|
});
|
2023-01-09 06:50:25 +00:00
|
|
|
|
|
|
|
watch($$(selectedTags), () => {
|
|
|
|
search();
|
|
|
|
}, { deep: true });
|
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);
|
|
|
|
|
|
|
|
> .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 {
|
|
|
|
.zuvgdzyt {
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
|
|
|
|
grid-gap: 12px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|