From 4c6c06c80afd3e2309b305f40c2e67e48863bf31 Mon Sep 17 00:00:00 2001
From: MeiMei <30769358+mei23@users.noreply.github.com>
Date: Mon, 21 Oct 2019 00:43:39 +0900
Subject: Improve emoji-picker (#5515)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* Improve emoji-picker
* remove unimplanted translation
* カテゴリのサジェスト
* use unique
---
.../app/common/views/components/emoji-picker.vue | 112 +++++++++++++++------
1 file changed, 84 insertions(+), 28 deletions(-)
(limited to 'src/client/app/common')
diff --git a/src/client/app/common/views/components/emoji-picker.vue b/src/client/app/common/views/components/emoji-picker.vue
index 88761ae933..abae69e28a 100644
--- a/src/client/app/common/views/components/emoji-picker.vue
+++ b/src/client/app/common/views/components/emoji-picker.vue
@@ -11,25 +11,46 @@
-
{{ categories.find(x => x.isActive).text }}
-
-
-
-
-
-
+
+
+
+
+
+
+
+
{{ categories.find(x => x.isActive).text }}
+
+
+
+
+
+
+
+
{{ key || $t('no-category') }}
+
+
+
+
+
@@ -38,8 +59,10 @@
import Vue from 'vue';
import i18n from '../../../i18n';
import { emojilist } from '../../../../../misc/emojilist';
-import { faAsterisk, faLeaf, faUtensils, faFutbol, faCity, faDice } from '@fortawesome/free-solid-svg-icons';
+import { getStaticImageUrl } from '../../../common/scripts/get-static-image-url';
+import { faAsterisk, faLeaf, faUtensils, faFutbol, faCity, faDice, faGlobe, faHistory } from '@fortawesome/free-solid-svg-icons';
import { faHeart, faFlag } from '@fortawesome/free-regular-svg-icons';
+import { groupByX } from '../../../../../prelude/array';
export default Vue.extend({
i18n: i18n('common/views/components/emoji-picker.vue'),
@@ -47,7 +70,9 @@ export default Vue.extend({
data() {
return {
emojilist,
- customEmojis: [],
+ getStaticImageUrl,
+ customEmojis: {},
+ faGlobe, faHistory,
categories: [{
text: this.$t('custom-emoji'),
icon: faAsterisk,
@@ -97,18 +122,43 @@ export default Vue.extend({
},
created() {
- this.customEmojis = (this.$root.getMetaSync() || { emojis: [] }).emojis || [];
+ let local = (this.$root.getMetaSync() || { emojis: [] }).emojis || [];
+ local = groupByX(local, (x: any) => x.category || '');
+ this.customEmojis = local;
+
+ if (this.$store.state.device.activeEmojiCategoryName) {
+ this.goCategory(this.$store.state.device.activeEmojiCategoryName);
+ }
},
methods: {
- go(category) {
+ go(category: any) {
+ this.goCategory(category.name);
+ },
+
+ goCategory(name: string) {
+ let matched = false;
for (const c of this.categories) {
- c.isActive = c.name === category.name;
+ c.isActive = c.name === name;
+ if (c.isActive) {
+ matched = true;
+ this.$store.commit('device/set', { key: 'activeEmojiCategoryName', value: c.name });
+ }
+ }
+ if (!matched) {
+ this.categories[0].isActive = true;
}
},
- chosen(emoji) {
- this.$emit('chosen', emoji);
+ chosen(emoji: any) {
+ const getKey = (emoji: any) => emoji.char || `:${emoji.name}:`;
+
+ let recents = this.$store.state.device.recentEmojis || [];
+ recents = recents.filter((e: any) => getKey(e) !== getKey(emoji));
+ recents.unshift(emoji)
+ this.$store.commit('device/set', { key: 'recentEmojis', value: recents.splice(0, 16) });
+
+ this.$emit('chosen', getKey(emoji));
}
}
});
@@ -142,7 +192,7 @@ export default Vue.extend({
overflow-y auto
overflow-x hidden
- > header
+ > header.category
position sticky
top 0
left 0
@@ -152,7 +202,12 @@ export default Vue.extend({
color var(--text)
font-size 12px
- > div
+ >>> header.sub
+ padding 4px 8px
+ color var(--text)
+ font-size 12px
+
+ >>> div.list
display grid
grid-template-columns 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr
gap 4px
@@ -180,6 +235,7 @@ export default Vue.extend({
left 0
width 100%
height 100%
+ object-fit contain
font-size 28px
transition transform 0.2s ease
pointer-events none
--
cgit v1.2.3-freya