commit: 992d57ef69540f4c63939fbc5abed9b1ea28ed2f
parent ff2242e85dc89aa7479000cf469ca2bce5d60157
Author: Tusooa Zhu <tusooa@kazv.moe>
Date: Sat, 14 Aug 2021 21:50:58 -0400
Display all emoji groups on emoji picker header
Diffstat:
3 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/src/components/emoji_picker/emoji_picker.js b/src/components/emoji_picker/emoji_picker.js
@@ -38,6 +38,8 @@ const filterByKeyword = (list, keyword = '') => {
return orderedEmojiList.flat()
}
+const packOf = emoji => (emoji.tags.filter(k => k.startsWith('pack:'))[0] || '').slice(5)
+
const EmojiPicker = {
props: {
enableStickerPicker: {
@@ -174,9 +176,12 @@ const EmojiPicker = {
}
return 0
},
+ allEmojis () {
+ return this.$store.state.instance.customEmoji || []
+ },
filteredEmoji () {
return filterByKeyword(
- this.$store.state.instance.customEmoji || [],
+ this.allEmojis,
trim(this.keyword)
)
},
@@ -184,7 +189,6 @@ const EmojiPicker = {
return this.filteredEmoji.slice(0, this.customEmojiBufferSlice)
},
groupedCustomEmojis () {
- const packOf = emoji => (emoji.tags.filter(k => k.startsWith('pack:'))[0] || '').slice(5)
return this.customEmojiBuffer.reduce((res, emoji) => {
const pack = packOf(emoji)
if (!res[pack]) {
@@ -201,6 +205,26 @@ const EmojiPicker = {
return res
}, {})
},
+ allEmojiGroups () {
+ return this.allEmojis
+ .reduce((res, emoji) => {
+ const packName = packOf(emoji)
+ const packId = `custom-${packName}`
+ if (res.filter(k => k.id === packId).length === 0) {
+ res.push({
+ id: packId,
+ text: packName,
+ image: emoji.imageUrl
+ })
+ }
+ return res
+ }, [])
+ .concat({
+ id: 'standard',
+ text: this.$t('emoji.unicode'),
+ icon: 'box-open'
+ })
+ },
emojis () {
const standardEmojis = this.$store.state.instance.emoji || []
// const customEmojis = this.customEmojiBuffer
diff --git a/src/components/emoji_picker/emoji_picker.scss b/src/components/emoji_picker/emoji_picker.scss
@@ -52,6 +52,7 @@
display: flex;
height: 32px;
padding: 10px 7px 5px;
+ overflow-x: auto;
}
.content {
@@ -63,6 +64,9 @@
.emoji-tabs {
flex-grow: 1;
+ display: flex;
+ flex-direction: row;
+ flex-wrap: nowrap;
}
.emoji-groups {
@@ -70,6 +74,7 @@
}
.additional-tabs {
+ display: block;
border-left: 1px solid;
border-left-color: $fallback--icon;
border-left-color: var(--icon, $fallback--icon);
@@ -79,7 +84,6 @@
.additional-tabs,
.emoji-tabs {
- display: block;
min-width: 0;
flex-basis: auto;
flex-shrink: 1;
diff --git a/src/components/emoji_picker/emoji_picker.vue b/src/components/emoji_picker/emoji_picker.vue
@@ -3,12 +3,12 @@
<div class="heading">
<span class="emoji-tabs">
<span
- v-for="group in emojis"
+ v-for="group in allEmojiGroups"
:key="group.id"
class="emoji-tabs-item"
:class="{
active: activeGroupView === group.id,
- disabled: group.emojis.length === 0
+ disabled: false
}"
:title="group.text"
@click.prevent="highlight(group.id)"