Feature: Support an Emoji selector in the chat widget (#773)

* Adds emoji widget to web widget
* Style fixes for the send button
* Adds cursor to emoji widget action buttons
This commit is contained in:
Nithin David Thomas
2020-04-29 13:54:56 +05:30
committed by GitHub
parent fde4f9271b
commit 168042f9a4
6 changed files with 135 additions and 48 deletions

View File

@@ -9,7 +9,6 @@
@import 'widgets/conv-header';
@import 'widgets/conversation-card';
@import 'widgets/conversation-view';
@import 'widgets/emojiinput';
@import 'widgets/forms';
@import 'widgets/login';
@import 'widgets/modal';

View File

@@ -1,3 +1,6 @@
@import '../variables';
@import '../mixins';
.emoji-dialog {
@include elegant-card;
background: $color-white;
@@ -15,15 +18,15 @@
}
.emojione {
@include margin($zero);
font-size: $font-size-medium;
font-size: $font-size-default;
margin: $zero;
}
.emoji-row {
@include padding($space-small);
box-sizing: border-box;
height: 180px;
overflow-y: auto;
padding: $space-small;
.emoji {
border-radius: 4px;
@@ -52,27 +55,33 @@
}
.emoji-dialog-header {
@include padding($zero $space-smaller);
background-color: $light-gray;
background-color: $color-body;
border-top-left-radius: $space-small;
border-top-right-radius: $space-small;
padding: $zero $space-smaller;
ul {
display: flex;
list-style: none;
margin: 0;
padding: $space-smaller 0 0;
> li {
@include padding($space-smaller $space-small);
box-sizing: border-box;
>li {
align-items: center;
cursor: pointer;
display: inline-block;
height: 3.4rem;
text-align: center;
display: flex;
height: $space-medium;
justify-content: center;
padding: $space-smaller $space-small;
}
> .active {
background: $white;
.emojione {
height: $space-two;
width: $space-normal;
}
>.active {
background: $color-white;
border-top-left-radius: $space-small;
border-top-right-radius: $space-small;
}
@@ -84,13 +93,14 @@
}
.active {
img,
svg {
filter: grayscale(0);
}
}
> * {
>* {
display: table-cell;
vertical-align: middle;
}

View File

@@ -3,37 +3,39 @@
<header class="emoji-dialog-header" role="menu">
<ul>
<li
v-bind:class="{ 'active': selectedKey === category.key }"
v-for="category in categoryList"
:key="category.key"
:class="{ active: selectedKey === category.key }"
@click="changeCategory(category)"
>
<div
@click="changeCategory(category)"
role="menuitem"
class="emojione"
v-html="getEmojiUnicode(`:${category.emoji}:`)"
>
</div>
@click="changeCategory(category)"
v-html="` ${getEmojiUnicode(`:${category.emoji}:`)}`"
></div>
</li>
</ul>
</header>
<div class="emoji-row">
<h5 class="emoji-category-title">{{selectedKey}}</h5>
<h5 class="emoji-category-title">
{{ selectedKey }}
</h5>
<div
v-for="(emoji, key) in selectedEmojis"
v-for="emoji in filteredSelectedEmojis"
:key="emoji.shortname"
role="menuitem"
:class="`emojione`"
v-html="getEmojiUnicode(emoji[emoji.length - 1].shortname)"
v-if="filterEmoji(emoji[emoji.length - 1].shortname)"
class="emojione"
track-by="$index"
@click="onClick(emoji[emoji.length - 1])"
@click="onClick(emoji)"
v-html="getEmojiUnicode(emoji.shortname)"
/>
</div>
</div>
</div>
</template>
<script>
/* eslint-disable no-restricted-syntax */
import strategy from 'emojione/emoji.json';
import categoryList from './categories';
import { getEmojiUnicode } from './utils';
@@ -44,7 +46,7 @@ export default {
return {
selectedKey: 'people',
categoryList,
selectedEmojis: [],
selectedEmojis: {},
};
},
computed: {
@@ -76,13 +78,29 @@ export default {
}
return emojiArr;
},
filteredSelectedEmojis() {
const emojis = this.selectedEmojis;
const filteredEmojis = Object.keys(emojis)
.map(key => {
const emoji = emojis[key];
const [lastEmoji] = emoji.slice(-1);
return { ...lastEmoji, key };
})
.filter(emoji => {
const { shortname } = emoji;
if (shortname) {
return this.filterEmoji(shortname);
}
return false;
});
return filteredEmojis;
},
},
// On mount render initial emoji
mounted() {
this.getInitialEmoji();
},
methods: {
// Change category and associated emojis
changeCategory(category) {
this.selectedKey = category.key;
@@ -101,3 +119,6 @@ export default {
},
};
</script>
<style lang="scss" scoped>
@import '~dashboard/assets/scss/widgets/emojiinput';
</style>