Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(frontend): 絵文字ピッカーのカテゴリを多階層フォルダで分類できるように #12132

Merged
merged 57 commits into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
7c9330a
Release: 13.7.3
tamaina Feb 23, 2023
40de144
Release: 13.7.4
tamaina Feb 23, 2023
1ba49b6
Merge pull request #10058 from misskey-dev/develop
syuilo Feb 24, 2023
02c8fd9
Merge pull request #10108 from misskey-dev/develop
syuilo Feb 26, 2023
647ce17
Merge pull request #10112 from misskey-dev/develop
syuilo Feb 26, 2023
5bd68aa
Merge pull request #10177 from misskey-dev/develop
syuilo Mar 3, 2023
b23a9b1
Merge pull request #10181 from misskey-dev/develop
syuilo Mar 3, 2023
ae517a9
Merge pull request #10218 from misskey-dev/develop
syuilo Mar 6, 2023
1e67e9c
Merge pull request #10342 from misskey-dev/develop
syuilo Mar 22, 2023
59768bd
Merge pull request #10383 from misskey-dev/develop
syuilo Mar 22, 2023
a52bbc7
Merge pull request #10388 from misskey-dev/develop
syuilo Mar 22, 2023
f54a954
Merge pull request #10402 from misskey-dev/develop
syuilo Mar 24, 2023
a096f62
Merge pull request #10506 from misskey-dev/develop
syuilo Apr 8, 2023
8b1362a
Merge pull request #10543 from misskey-dev/develop
syuilo Apr 9, 2023
75b28d6
Merge pull request #10578 from misskey-dev/develop
syuilo Apr 11, 2023
d429f81
Update CHANGELOG.md
EbiseLutica Apr 12, 2023
272e0c8
Merge pull request #10606 from misskey-dev/EbiseLutica-patch-1
syuilo Apr 12, 2023
c5d2dba
Merge pull request #10608 from misskey-dev/develop
syuilo Apr 13, 2023
94690c8
Merge pull request #10774 from misskey-dev/develop
syuilo May 9, 2023
9ad5732
Merge pull request #10814 from misskey-dev/develop
syuilo May 9, 2023
de6348e
Merge pull request #10833 from misskey-dev/develop
syuilo May 12, 2023
407a965
Merge pull request #10932 from misskey-dev/develop
syuilo Jun 5, 2023
32c7411
Merge pull request #10961 from misskey-dev/develop
syuilo Jun 6, 2023
7093662
Merge pull request #10990 from misskey-dev/develop
syuilo Jun 13, 2023
e64a81a
Merge pull request #11301 from misskey-dev/develop
syuilo Jul 21, 2023
4e24aff
Merge pull request #11338 from misskey-dev/develop
syuilo Jul 21, 2023
a8d45d4
Merge pull request #11384 from misskey-dev/develop
syuilo Jul 27, 2023
f32915b
Merge pull request #11874 from misskey-dev/develop
syuilo Sep 24, 2023
e57b536
Merge pull request #11898 from misskey-dev/develop
syuilo Sep 25, 2023
7adc8fc
Merge pull request #11920 from misskey-dev/develop
syuilo Sep 29, 2023
0e6cd57
Merge pull request #11926 from misskey-dev/develop
syuilo Sep 30, 2023
f964ef1
Merge pull request #11963 from misskey-dev/develop
syuilo Oct 10, 2023
7e7138c
Merge pull request #12011 from misskey-dev/develop
syuilo Oct 12, 2023
3043b52
Merge pull request #12060 from misskey-dev/develop
syuilo Oct 21, 2023
e1b45bd
Feat:emoji picker folder select
meronmks Oct 21, 2023
808602c
Fix: lint error
meronmks Oct 22, 2023
e88c0ed
Fix: lint error 2
meronmks Oct 22, 2023
01af8c2
Fix: lint error 3
meronmks Oct 22, 2023
bf3ca78
カスタム絵文字のカテゴリ表示部分が長かったので短くした
meronmks Oct 22, 2023
0b59236
エフェクトが壊れて出ないのを修正
meronmks Oct 24, 2023
0637591
padding 18px -> 9px
meronmks Oct 24, 2023
9b14644
Update CHANGELOG.md
meronmks Oct 24, 2023
059c11f
Revert: en-US.yml
meronmks Oct 25, 2023
6b3171f
chg: Folder -> folder
meronmks Oct 25, 2023
563bd78
chg: isChildrenExits -> isChildren
meronmks Oct 25, 2023
0ae2d13
chg: isChildren -> categoryFolderFlag
meronmks Oct 26, 2023
2e05560
カテゴリ末尾が / の場合ピッカーから消失するので「その他」と扱い対応
meronmks Oct 28, 2023
d0f9626
特定のパターンのカテゴリ名でピッカーに出てこないのを修正
meronmks Oct 28, 2023
d09481d
chg: categoryFolderFlag -> hasChildSection
meronmks Oct 29, 2023
3f42764
code format
meronmks Oct 29, 2023
45e39bd
Del: ti-fw
meronmks Oct 30, 2023
84ed25a
fix
meronmks Oct 30, 2023
b47b620
絵文字とフォルダの表示順序入れ替え
meronmks Oct 30, 2023
b19602d
ネストした場合にパネルでどこまでがどのフォルダのものかをわかりやすくした
meronmks Oct 30, 2023
74cefab
fix lint
meronmks Oct 30, 2023
47309b6
カテゴリの名前が長いと表示がおかしくなる問題を修正
meronmks Oct 30, 2023
ac8be5c
Merge branch 'develop' into pr/12132
syuilo Dec 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
### Client
- Enhance: TLの返信表示オプションを記憶するように
- Enhance: 投稿されてから時間が経過しているノートであることを視覚的に分かりやすく
- Feat: 絵文字ピッカーのカテゴリに「/」を入れることでフォルダ分け表示できるように

### Server
- Enhance: タイムライン取得時のパフォーマンスを向上
Expand Down
1 change: 1 addition & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ export interface Locale {
"createFolder": string;
"renameFolder": string;
"deleteFolder": string;
"folder": string;
"addFile": string;
"emptyDrive": string;
"emptyFolder": string;
Expand Down
1 change: 1 addition & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ folderName: "フォルダー名"
createFolder: "フォルダーを作成"
renameFolder: "フォルダー名を変更"
deleteFolder: "フォルダーを削除"
folder: "フォルダー"
addFile: "ファイルを追加"
emptyDrive: "ドライブは空です"
emptyFolder: "フォルダーは空です"
Expand Down
47 changes: 44 additions & 3 deletions packages/frontend/src/components/MkEmojiPicker.section.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ SPDX-License-Identifier: AGPL-3.0-only

<template>
<!-- このコンポーネントの要素のclassは親から利用されるのでむやみに弄らないこと -->
<section>
<!-- フォルダの中にはカスタム絵文字だけ(Unicode絵文字もこっち) -->
<section v-if="!categoryFolderFlag">
<header class="_acrylic" @click="shown = !shown">
<i class="toggle ti-fw" :class="shown ? 'ti ti-chevron-down' : 'ti ti-chevron-up'"></i> <slot></slot> ({{ emojis.length }})
<i class="toggle ti-fw" :class="shown ? 'ti ti-chevron-down' : 'ti ti-chevron-up'"></i> <slot></slot> (<i class="ti ti-icons ti-fw"></i>:{{emojis.length}})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ti-icons は必要かしら?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

数字だけだとフォルダの数なのか、絵文字の数なのか初見だとわかんなくなりそうだなってことで追加してます。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

あ、ti-icons というクラスは必要?という意味

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

使いたいアイコンがti-icons https://tabler-icons.io/i/icons なのでどっちかというとti-fwが不要かも

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ですです、アイコンとして使いたいのがti-iconsなのでti-fwの方が不要なのではというのはそうかもです。
(他でti-iconsを利用している場所の記述ほぼそのままパクってるだけなのでもしかしたらこの場合では不要なクラスが混ざってしまってるかも)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<i class="toggle ti-fw" :class="shown ? 'ti ti-chevron-down' : 'ti ti-chevron-up'"></i> <slot></slot> (<i class="ti ti-icons ti-fw"></i>:{{emojis.length}})
<i class="toggle ti-fw" :class="shown ? 'ti ti-chevron-down' : 'ti ti-chevron-up'"></i> <slot></slot> (<i class="ti ti-icons ti-fw"></i>:{{ emojis.length }})

</header>
<div v-if="shown" class="body">
<button
Expand All @@ -23,15 +24,52 @@ SPDX-License-Identifier: AGPL-3.0-only
</button>
</div>
</section>
<!-- フォルダの中にはカスタム絵文字やフォルダがある -->
<section v-else>
<header class="_acrylic" @click="shown = !shown">
<i class="toggle ti-fw" :class="shown ? 'ti ti-chevron-down' : 'ti ti-chevron-up'"></i> <slot></slot> (<i class="ti ti-folder ti-fw"></i>:{{customEmojiTree.length}} <i class="ti ti-icons ti-fw"></i>:{{emojis.length}})
</header>
<div v-if="shown" class="body">
<button
v-for="emoji in emojis"
:key="emoji"
:data-emoji="emoji"
class="_button item"
@pointerenter="computeButtonTitle"
@click="emit('chosen', emoji, $event)"
>
<MkCustomEmoji v-if="emoji[0] === ':'" class="emoji" :name="emoji" :normal="true"/>
<MkEmoji v-else class="emoji" :emoji="emoji" :normal="true"/>
</button>
</div>
<div v-if="shown" style="padding-left: 9px;">
<MkEmojiPickerSection
v-for="child in customEmojiTree"
:key="`custom:${child.value}`"
:initialShown="initialShown"
:emojis="computed(() => customEmojis.filter(e => e.category === child.category).map(e => `:${e.name}:`))"
:categoryFolderFlag="child.children.length!==0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:categoryFolderFlag="child.children.length!==0"
:categoryFolderFlag="child.children.length !== 0"

:customEmojiTree="child.children"
@chosen="nestedChosen"
>
{{ child.value }}
</MkEmojiPickerSection>
</div>
</section>
</template>

<script lang="ts" setup>
import { ref, computed, Ref } from 'vue';
import { getEmojiName } from '@/scripts/emojilist.js';
import { CustomEmojiFolderTree, getEmojiName } from '@/scripts/emojilist.js';
import { i18n } from "../i18n.js";
import { customEmojis } from "@/custom-emojis.js";
import MkEmojiPickerSection from "@/components/MkEmojiPicker.section.vue";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

シングルクォートで統一お願いします


const props = defineProps<{
emojis: string[] | Ref<string[]>;
initialShown?: boolean;
categoryFolderFlag?: boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

〇〇Flagという命名は得てして意味が分かりづらいから、hasChildSectionとかどうかしら

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

承知ですhasChildSectionにリネームします

customEmojiTree?: CustomEmojiFolderTree[];
}>();

const emit = defineEmits<{
Expand All @@ -49,4 +87,7 @@ function computeButtonTitle(ev: MouseEvent): void {
elm.title = getEmojiName(emoji) ?? emoji;
}

function nestedChosen(emoji: any, ev?: MouseEvent) {
emit('chosen', emoji, ev);
}
</script>
59 changes: 53 additions & 6 deletions packages/frontend/src/components/MkEmojiPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,20 @@
<div v-once class="group">
<header class="_acrylic">{{ i18n.ts.customEmojis }}</header>
<XSection
v-for="category in customEmojiCategories"
:key="`custom:${category}`"
v-for="child in customEmojiFolderRoot.children"
:key="`custom:${child.value}`"
:initialShown="false"
:emojis="computed(() => customEmojis.filter(e => category === null ? (e.category === 'null' || !e.category) : e.category === category).filter(filterAvailable).map(e => `:${e.name}:`))"
:emojis="computed(() => customEmojis.filter(e => child.value === i18n.ts.other ? (e.category === 'null' || !e.category) : e.category === child.value).filter(filterAvailable).map(e => `:${e.name}:`))"
:categoryFolderFlag="child.children.length!==0"
:customEmojiTree="child.children"
@chosen="chosen"
>
{{ category || i18n.ts.other }}
{{ child.value }}
</XSection>
</div>
<div v-once class="group">
<header class="_acrylic">{{ i18n.ts.emoji }}</header>
<XSection v-for="category in categories" :key="category" :emojis="emojiCharByCategory.get(category) ?? []" @chosen="chosen">{{ category }}</XSection>
<XSection v-for="category in categories" :key="category" :emojis="emojiCharByCategory.get(category) ?? []" :categoryFolderFlag="false" @chosen="chosen">{{ category }}</XSection>
</div>
</div>
<div class="tabs">
Expand All @@ -100,7 +102,14 @@
import { ref, shallowRef, computed, watch, onMounted } from 'vue';
import * as Misskey from 'misskey-js';
import XSection from '@/components/MkEmojiPicker.section.vue';
import { emojilist, emojiCharByCategory, UnicodeEmojiDef, unicodeEmojiCategories as categories, getEmojiName } from '@/scripts/emojilist.js';
import {
emojilist,
emojiCharByCategory,
UnicodeEmojiDef,
unicodeEmojiCategories as categories,
getEmojiName,
CustomEmojiFolderTree
} from '@/scripts/emojilist.js';
import MkRippleEffect from '@/components/MkRippleEffect.vue';
import * as os from '@/os.js';
import { isTouchUsing } from '@/scripts/touch.js';
Expand Down Expand Up @@ -144,6 +153,44 @@
const searchResultUnicode = ref<UnicodeEmojiDef[]>([]);
const tab = ref<'index' | 'custom' | 'unicode' | 'tags'>('index');

const customEmojiFolderRoot: CustomEmojiFolderTree = { value: "", category: "", children: [] };

function parseAndMergeCategories(input: string, root: CustomEmojiFolderTree): CustomEmojiFolderTree {
const parts = input.split('/');
let category = "";
let currentNode: CustomEmojiFolderTree = root;

for (let part of parts) {
if (part) {
category += `/${part}`;
} else {
part = i18n.ts.other

Check failure on line 167 in packages/frontend/src/components/MkEmojiPicker.vue

View workflow job for this annotation

GitHub Actions / lint (frontend)

Missing semicolon
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
part = i18n.ts.other
part = i18n.ts.other;

Lint落ちてるのでここ修正お願いします🙏

category += `/`;
}

category = category.replace(/^\//, '');
let existingNode = currentNode.children.find((node) => node.value === part);

if (!existingNode) {
const newNode: CustomEmojiFolderTree = { value: part, category, children: [] };
currentNode.children.push(newNode);
existingNode = newNode;
}

currentNode = existingNode;
}

return currentNode;
}

customEmojiCategories.value.forEach(ec => {
if (ec !== null) {
parseAndMergeCategories(ec, customEmojiFolderRoot);
}
});

parseAndMergeCategories(i18n.ts.other, customEmojiFolderRoot);

watch(q, () => {
if (emojisEl.value) emojisEl.value.scrollTop = 0;

Expand Down
6 changes: 6 additions & 0 deletions packages/frontend/src/scripts/emojilist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,9 @@ export function getEmojiName(char: string): string | null {
return emojilist[idx].name;
}
}

export interface CustomEmojiFolderTree {
value: string;
category: string;
children: CustomEmojiFolderTree[];
}
Loading