misskey/packages/frontend/src/pages/about.emojis.vue

114 lines
3.0 KiB
Vue
Raw Normal View History

<template>
<div class="driuhtrh _gaps">
<MkButton v-if="$i && ($i.isModerator || $i.policies.canManageCustomEmojis)" primary link to="/custom-emojis-manager">{{ i18n.ts.manageCustomEmojis }}</MkButton>
<div class="query">
2021-09-30 00:50:45 +09:00
<MkInput v-model="q" class="" :placeholder="$ts.search">
<template #prefix><i class="ti ti-search"></i></template>
</MkInput>
2021-09-26 03:17:16 +09:00
<!-- たくさんあると邪魔
<div class="tags">
<span class="tag _button" v-for="tag in customEmojiTags" :class="{ active: selectedTags.has(tag) }" @click="toggleTag(tag)">{{ tag }}</span>
</div>
-->
</div>
2023-01-09 09:41:25 +09:00
<MkFoldableSection v-if="searchEmojis" class="emojis">
<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 09:41:25 +09:00
</MkFoldableSection>
2023-01-09 09:41:25 +09:00
<MkFoldableSection v-for="category in customEmojiCategories" v-once :key="category" class="emojis">
<template #header>{{ category || $ts.other }}</template>
<div class="zuvgdzyt">
2023-01-09 09:04:35 +09:00
<XEmoji v-for="emoji in customEmojis.filter(e => e.category === category)" :key="emoji.name" class="emoji" :emoji="emoji"/>
</div>
2023-01-09 09:41:25 +09:00
</MkFoldableSection>
</div>
</template>
<script lang="ts" setup>
import { defineComponent, computed, watch } from 'vue';
import XEmoji from './emojis.emoji.vue';
import MkButton from '@/components/MkButton.vue';
2023-01-07 15:09:46 +09:00
import MkInput from '@/components/MkInput.vue';
import MkSelect from '@/components/MkSelect.vue';
2023-01-09 09:41:25 +09:00
import MkFoldableSection from '@/components/MkFoldableSection.vue';
import MkTab from '@/components/MkTab.vue';
2021-11-12 02:02:25 +09:00
import * as os from '@/os';
2023-01-09 16:45:05 +09:00
import { customEmojis, getCustomEmojiCategories, getCustomEmojiTags } from '@/custom-emojis';
import { i18n } from '@/i18n';
2023-01-09 16:45:05 +09:00
const customEmojiCategories = getCustomEmojiCategories();
const customEmojiTags = getCustomEmojiTags();
let q = $ref('');
let searchEmojis = $ref(null);
let selectedTags = $ref(new Set());
function search() {
if ((q === '' || q == null) && selectedTags.size === 0) {
searchEmojis = null;
return;
}
if (selectedTags.size === 0) {
searchEmojis = customEmojis.filter(emoji => emoji.name.includes(q) || emoji.aliases.includes(q));
} else {
searchEmojis = customEmojis.filter(emoji => (emoji.name.includes(q) || emoji.aliases.includes(q)) && [...selectedTags].every(t => emoji.aliases.includes(t)));
}
}
function toggleTag(tag) {
if (selectedTags.has(tag)) {
selectedTags.delete(tag);
} else {
selectedTags.add(tag);
}
}
watch($$(q), () => {
search();
});
watch($$(selectedTags), () => {
search();
}, { deep: true });
</script>
<style lang="scss" scoped>
.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-21 04:09:28 +09:00
background: var(--accentedBg);
border-radius: 5px;
&.active {
2021-09-21 04:09:28 +09:00
background: var(--accent);
color: var(--fgOnAccent);
}
}
}
}
> .emojis {
.zuvgdzyt {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
grid-gap: 12px;
}
}
}
</style>