Feat:emoji folder
This commit is contained in:
parent
a3743a0622
commit
81182b8612
|
@ -6,13 +6,14 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<template>
|
<template>
|
||||||
<!-- このコンポーネントの要素のclassは親から利用されるのでむやみに弄らないこと -->
|
<!-- このコンポーネントの要素のclassは親から利用されるのでむやみに弄らないこと -->
|
||||||
<section>
|
<section>
|
||||||
|
<!-- categoryが定義されてない(Unicodeの絵文字とか) -->
|
||||||
|
|
||||||
<header v-if="!category" class="_acrylic" @click="shown = !shown">
|
<header v-if="!category" class="_acrylic" @click="shown = !shown">
|
||||||
<i class="toggle ti-fw" :class="shown ? 'ti ti-chevron-down' : 'ti ti-chevron-up'"></i>
|
<i class="toggle ti-fw" :class="shown ? 'ti ti-chevron-down' : 'ti ti-chevron-up'"></i>
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
({{ emojis.length }})
|
({{ emojis.length }})
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
<!-- categoryが定義されてるけど中身が1つしかない -->
|
||||||
<header v-else-if="category.length === 1" class="_acrylic" @click="shown = !shown">
|
<header v-else-if="category.length === 1" class="_acrylic" @click="shown = !shown">
|
||||||
<i class="toggle ti-fw" :class="shown ? 'ti ti-chevron-down' : 'ti ti-chevron-up'"></i>
|
<i class="toggle ti-fw" :class="shown ? 'ti ti-chevron-down' : 'ti ti-chevron-up'"></i>
|
||||||
{{ category[0] }}
|
{{ category[0] }}
|
||||||
|
@ -20,6 +21,8 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
emojis.filter(e => category === null ? (e.category === 'null' || !e.category) : e.category === category[0]).length
|
emojis.filter(e => category === null ? (e.category === 'null' || !e.category) : e.category === category[0]).length
|
||||||
}})
|
}})
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
<!-- categoryに1つ以上要素がある(フォルダが有る) -->
|
||||||
<header v-else class="_acrylic" style="top:unset;" @click="toggleShown_fol">
|
<header v-else class="_acrylic" style="top:unset;" @click="toggleShown_fol">
|
||||||
<i class="toggle ti-fw" :class="shown_fol? 'ti ti-chevron-down' : 'ti ti-chevron-up'"></i>
|
<i class="toggle ti-fw" :class="shown_fol? 'ti ti-chevron-down' : 'ti ti-chevron-up'"></i>
|
||||||
{{ category[0] || i18n.ts.other }}
|
{{ category[0] || i18n.ts.other }}
|
||||||
|
@ -29,13 +32,16 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<template v-else>
|
<template v-else>
|
||||||
({{
|
({{
|
||||||
emojis.filter(e => category === null ? (e.category === 'null' || !e.category) : e.category === category[0]).length
|
emojis.filter(e => category === null ? (e.category === 'null' || !e.category) : e.category === category[0]).length
|
||||||
}}) 2
|
}})
|
||||||
</template>
|
</template>
|
||||||
</header>
|
</header>
|
||||||
|
<!-- フォルダが有るときのフォルダと絵文字表示する部分 -->
|
||||||
<template v-for="(n, index) in category" v-if="shown_fol">
|
<template v-for="(n, index) in category" v-if="shown_fol">
|
||||||
|
|
||||||
|
<!-- フォルダの部分 -->
|
||||||
<header
|
<header
|
||||||
v-if="emojis.filter(e => category === null ? (e.category === 'null' || !e.category) : e.category === category[0]).length !== 0 || index!==0"
|
v-if="emojis.filter(e => category === null ? (e.category === 'null' || !e.category) : e.category === category[0]).length !== 0 || index!==0"
|
||||||
style="top:unset;padding-left: 18px;"
|
style="padding-left: 18px;"
|
||||||
class="_acrylic"
|
class="_acrylic"
|
||||||
@click="toggleShown(index)"
|
@click="toggleShown(index)"
|
||||||
>
|
>
|
||||||
|
@ -45,6 +51,8 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
emojis.filter(e => category === null ? (e.category === 'null' || !e.category) : e.category === (index === 0 && category !== undefined ? category[0] : `${category[0]}/${n}`)).length
|
emojis.filter(e => category === null ? (e.category === 'null' || !e.category) : e.category === (index === 0 && category !== undefined ? category[0] : `${category[0]}/${n}`)).length
|
||||||
}})
|
}})
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
<!-- 絵文字の部分 -->
|
||||||
<div v-if="shown_fold[index]" class="body">
|
<div v-if="shown_fold[index]" class="body">
|
||||||
<button
|
<button
|
||||||
v-for="emoji in emojis.filter(e => category === null ? (e.category === 'null' || !e.category) : e.category ===( index === 0 && category !== undefined ? category[0] : `${category[0]}/${n}`)).map(e => `:${e.name}:`)"
|
v-for="emoji in emojis.filter(e => category === null ? (e.category === 'null' || !e.category) : e.category ===( index === 0 && category !== undefined ? category[0] : `${category[0]}/${n}`)).map(e => `:${e.name}:`)"
|
||||||
|
@ -60,6 +68,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<!-- categoryが1つしかないときのフォルダと絵文字表示する部分 -->
|
||||||
<div v-if="shown && category" class="body">
|
<div v-if="shown && category" class="body">
|
||||||
<button
|
<button
|
||||||
v-for="emoji in emojis.filter(e => e.category === category[0]).map(e => `:${e.name}:`)"
|
v-for="emoji in emojis.filter(e => e.category === category[0]).map(e => `:${e.name}:`)"
|
||||||
|
@ -73,6 +82,8 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<MkEmoji v-else class="emoji" :emoji="emoji" :normal="true"/>
|
<MkEmoji v-else class="emoji" :emoji="emoji" :normal="true"/>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Unicodeのやつ -->
|
||||||
<div v-else-if="shown && !category" class="body">
|
<div v-else-if="shown && !category" class="body">
|
||||||
<button
|
<button
|
||||||
v-for="emoji in emojis"
|
v-for="emoji in emojis"
|
||||||
|
@ -107,7 +118,6 @@ const emit = defineEmits<{
|
||||||
|
|
||||||
const toggleShown = (index) => {
|
const toggleShown = (index) => {
|
||||||
shown_fold.value[index] = !shown_fold.value[index];
|
shown_fold.value[index] = !shown_fold.value[index];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const toggleShown_fol = () => {
|
const toggleShown_fol = () => {
|
||||||
|
|
|
@ -153,20 +153,35 @@ const tab = ref<'index' | 'custom' | 'unicode' | 'tags'>('index');
|
||||||
let split_categories = [];
|
let split_categories = [];
|
||||||
customEmojiCategories.value.forEach(e => {
|
customEmojiCategories.value.forEach(e => {
|
||||||
if (e !== null){
|
if (e !== null){
|
||||||
split_categories.push(e.split('/'))
|
split_categories.push(e.split('/',2))
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const groupedData = {};
|
const groupedData = {};
|
||||||
split_categories.forEach((item) => {
|
split_categories.forEach((item) => {
|
||||||
if (!groupedData[item[0]]) {
|
if (!groupedData[item[0]]) {
|
||||||
groupedData[item[0]] = [];
|
groupedData[item[0]] = {};
|
||||||
groupedData[item[0]].push(item[0]);
|
groupedData[item[0]][item[0]] = true;
|
||||||
|
if (item.length > 1) {
|
||||||
|
for (let i = 1; i < item.length; i++) {
|
||||||
|
groupedData[item[0]][item[i]] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
groupedData[item[0]].push(item[1]);
|
if (item.length > 1) {
|
||||||
|
for (let i = 1; i < item.length; i++) {
|
||||||
|
groupedData[item[0]][item[i]] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log(groupedData)
|
|
||||||
|
// 結果を配列に変換
|
||||||
|
for (const key in groupedData) {
|
||||||
|
groupedData[key] = Object.keys(groupedData[key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(split_categories,groupedData)
|
||||||
|
|
||||||
watch(q, () => {
|
watch(q, () => {
|
||||||
if (emojisEl.value) emojisEl.value.scrollTop = 0;
|
if (emojisEl.value) emojisEl.value.scrollTop = 0;
|
||||||
|
|
Loading…
Reference in New Issue