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:
parent
fde4f9271b
commit
168042f9a4
6 changed files with 135 additions and 48 deletions
|
@ -9,7 +9,6 @@
|
||||||
@import 'widgets/conv-header';
|
@import 'widgets/conv-header';
|
||||||
@import 'widgets/conversation-card';
|
@import 'widgets/conversation-card';
|
||||||
@import 'widgets/conversation-view';
|
@import 'widgets/conversation-view';
|
||||||
@import 'widgets/emojiinput';
|
|
||||||
@import 'widgets/forms';
|
@import 'widgets/forms';
|
||||||
@import 'widgets/login';
|
@import 'widgets/login';
|
||||||
@import 'widgets/modal';
|
@import 'widgets/modal';
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
@import '../variables';
|
||||||
|
@import '../mixins';
|
||||||
|
|
||||||
.emoji-dialog {
|
.emoji-dialog {
|
||||||
@include elegant-card;
|
@include elegant-card;
|
||||||
background: $color-white;
|
background: $color-white;
|
||||||
|
@ -15,15 +18,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.emojione {
|
.emojione {
|
||||||
@include margin($zero);
|
font-size: $font-size-default;
|
||||||
font-size: $font-size-medium;
|
margin: $zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
.emoji-row {
|
.emoji-row {
|
||||||
@include padding($space-small);
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
height: 180px;
|
height: 180px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
padding: $space-small;
|
||||||
|
|
||||||
.emoji {
|
.emoji {
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
|
@ -52,27 +55,33 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.emoji-dialog-header {
|
.emoji-dialog-header {
|
||||||
@include padding($zero $space-smaller);
|
background-color: $color-body;
|
||||||
background-color: $light-gray;
|
|
||||||
border-top-left-radius: $space-small;
|
border-top-left-radius: $space-small;
|
||||||
border-top-right-radius: $space-small;
|
border-top-right-radius: $space-small;
|
||||||
|
padding: $zero $space-smaller;
|
||||||
|
|
||||||
ul {
|
ul {
|
||||||
|
display: flex;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: $space-smaller 0 0;
|
padding: $space-smaller 0 0;
|
||||||
|
|
||||||
>li {
|
>li {
|
||||||
@include padding($space-smaller $space-small);
|
align-items: center;
|
||||||
box-sizing: border-box;
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
display: inline-block;
|
display: flex;
|
||||||
height: 3.4rem;
|
height: $space-medium;
|
||||||
text-align: center;
|
justify-content: center;
|
||||||
|
padding: $space-smaller $space-small;
|
||||||
|
}
|
||||||
|
|
||||||
|
.emojione {
|
||||||
|
height: $space-two;
|
||||||
|
width: $space-normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
>.active {
|
>.active {
|
||||||
background: $white;
|
background: $color-white;
|
||||||
border-top-left-radius: $space-small;
|
border-top-left-radius: $space-small;
|
||||||
border-top-right-radius: $space-small;
|
border-top-right-radius: $space-small;
|
||||||
}
|
}
|
||||||
|
@ -84,6 +93,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.active {
|
.active {
|
||||||
|
|
||||||
img,
|
img,
|
||||||
svg {
|
svg {
|
||||||
filter: grayscale(0);
|
filter: grayscale(0);
|
||||||
|
|
|
@ -3,37 +3,39 @@
|
||||||
<header class="emoji-dialog-header" role="menu">
|
<header class="emoji-dialog-header" role="menu">
|
||||||
<ul>
|
<ul>
|
||||||
<li
|
<li
|
||||||
v-bind:class="{ 'active': selectedKey === category.key }"
|
|
||||||
v-for="category in categoryList"
|
v-for="category in categoryList"
|
||||||
|
:key="category.key"
|
||||||
|
:class="{ active: selectedKey === category.key }"
|
||||||
@click="changeCategory(category)"
|
@click="changeCategory(category)"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
@click="changeCategory(category)"
|
|
||||||
role="menuitem"
|
role="menuitem"
|
||||||
class="emojione"
|
class="emojione"
|
||||||
v-html="getEmojiUnicode(`:${category.emoji}:`)"
|
@click="changeCategory(category)"
|
||||||
>
|
v-html="` ${getEmojiUnicode(`:${category.emoji}:`)}`"
|
||||||
</div>
|
></div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</header>
|
</header>
|
||||||
<div class="emoji-row">
|
<div class="emoji-row">
|
||||||
<h5 class="emoji-category-title">{{selectedKey}}</h5>
|
<h5 class="emoji-category-title">
|
||||||
|
{{ selectedKey }}
|
||||||
|
</h5>
|
||||||
<div
|
<div
|
||||||
v-for="(emoji, key) in selectedEmojis"
|
v-for="emoji in filteredSelectedEmojis"
|
||||||
|
:key="emoji.shortname"
|
||||||
role="menuitem"
|
role="menuitem"
|
||||||
:class="`emojione`"
|
class="emojione"
|
||||||
v-html="getEmojiUnicode(emoji[emoji.length - 1].shortname)"
|
|
||||||
v-if="filterEmoji(emoji[emoji.length - 1].shortname)"
|
|
||||||
track-by="$index"
|
track-by="$index"
|
||||||
@click="onClick(emoji[emoji.length - 1])"
|
@click="onClick(emoji)"
|
||||||
|
v-html="getEmojiUnicode(emoji.shortname)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
/* eslint-disable no-restricted-syntax */
|
||||||
import strategy from 'emojione/emoji.json';
|
import strategy from 'emojione/emoji.json';
|
||||||
import categoryList from './categories';
|
import categoryList from './categories';
|
||||||
import { getEmojiUnicode } from './utils';
|
import { getEmojiUnicode } from './utils';
|
||||||
|
@ -44,7 +46,7 @@ export default {
|
||||||
return {
|
return {
|
||||||
selectedKey: 'people',
|
selectedKey: 'people',
|
||||||
categoryList,
|
categoryList,
|
||||||
selectedEmojis: [],
|
selectedEmojis: {},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -76,13 +78,29 @@ export default {
|
||||||
}
|
}
|
||||||
return emojiArr;
|
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
|
// On mount render initial emoji
|
||||||
mounted() {
|
mounted() {
|
||||||
this.getInitialEmoji();
|
this.getInitialEmoji();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
// Change category and associated emojis
|
// Change category and associated emojis
|
||||||
changeCategory(category) {
|
changeCategory(category) {
|
||||||
this.selectedKey = category.key;
|
this.selectedKey = category.key;
|
||||||
|
@ -101,3 +119,6 @@ export default {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
@import '~dashboard/assets/scss/widgets/emojiinput';
|
||||||
|
</style>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<file-upload :size="4096 * 2048" @input-file="onFileUpload">
|
<file-upload :size="4096 * 2048" @input-file="onFileUpload">
|
||||||
<span class="attachment-button ">
|
<span class="attachment-button ">
|
||||||
<i v-if="!isUploading.image"></i>
|
<i v-if="!isUploading.image" class="ion-android-attach" />
|
||||||
<spinner v-if="isUploading" size="small" />
|
<spinner v-if="isUploading" size="small" />
|
||||||
</span>
|
</span>
|
||||||
</file-upload>
|
</file-upload>
|
||||||
|
@ -52,18 +52,16 @@ export default {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
position: relative;
|
position: relative;
|
||||||
padding-right: $space-smaller;
|
padding-right: $space-smaller;
|
||||||
display: block;
|
|
||||||
width: 20px;
|
width: 20px;
|
||||||
height: 20px;
|
|
||||||
|
|
||||||
i {
|
i {
|
||||||
padding: 0;
|
font-size: $font-size-large;
|
||||||
width: 100%;
|
color: $color-gray;
|
||||||
height: 100%;
|
|
||||||
display: block;
|
|
||||||
background: white center center no-repeat;
|
|
||||||
background-size: contain;
|
|
||||||
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none' stroke='%23999a9b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-paperclip'%3E%3Cpath d='M21 11l-9 9a6 6 0 01-8-8l9-9a4 4 0 016 5L9 17a2 2 0 01-2-2l8-9' /%3E%3C/svg%3E");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
<style lang="scss">
|
||||||
|
.file-uploads .attachment-button + label {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
|
@ -1,20 +1,38 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="chat-message--input">
|
<div class="chat-message--input">
|
||||||
<chat-attachment-button :on-attach="onSendAttachment" />
|
<chat-input-area v-model="userInput" :placeholder="placeholder" />
|
||||||
<ChatInputArea v-model="userInput" :placeholder="placeholder" />
|
<div class="button-wrap">
|
||||||
<ChatSendButton
|
<chat-attachment-button
|
||||||
|
v-if="showAttachment"
|
||||||
|
:on-attach="onSendAttachment"
|
||||||
|
/>
|
||||||
|
<emoji-input
|
||||||
|
v-if="showEmojiPicker"
|
||||||
|
v-on-clickaway="hideEmojiPicker"
|
||||||
|
:on-click="emojiOnClick"
|
||||||
|
/>
|
||||||
|
<i
|
||||||
|
class="emoji-toggle icon ion-happy-outline"
|
||||||
|
:class="{ active: showEmojiPicker }"
|
||||||
|
@click="toggleEmojiPicker()"
|
||||||
|
/>
|
||||||
|
<chat-send-button
|
||||||
|
v-if="showSendButton"
|
||||||
:on-click="handleButtonClick"
|
:on-click="handleButtonClick"
|
||||||
:disabled="!userInput.length"
|
|
||||||
:color="widgetColor"
|
:color="widgetColor"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapGetters } from 'vuex';
|
import { mapGetters } from 'vuex';
|
||||||
|
import emojione from 'emojione';
|
||||||
|
import { mixin as clickaway } from 'vue-clickaway';
|
||||||
import ChatSendButton from 'widget/components/ChatSendButton.vue';
|
import ChatSendButton from 'widget/components/ChatSendButton.vue';
|
||||||
import ChatAttachmentButton from 'widget/components/ChatAttachment.vue';
|
import ChatAttachmentButton from 'widget/components/ChatAttachment.vue';
|
||||||
import ChatInputArea from 'widget/components/ChatInputArea.vue';
|
import ChatInputArea from 'widget/components/ChatInputArea.vue';
|
||||||
|
import EmojiInput from 'dashboard/components/widgets/emoji/EmojiInput';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ChatInputWrap',
|
name: 'ChatInputWrap',
|
||||||
|
@ -22,8 +40,9 @@ export default {
|
||||||
ChatAttachmentButton,
|
ChatAttachmentButton,
|
||||||
ChatSendButton,
|
ChatSendButton,
|
||||||
ChatInputArea,
|
ChatInputArea,
|
||||||
|
EmojiInput,
|
||||||
},
|
},
|
||||||
|
mixins: [clickaway],
|
||||||
props: {
|
props: {
|
||||||
placeholder: {
|
placeholder: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -42,6 +61,7 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
userInput: '',
|
userInput: '',
|
||||||
|
showEmojiPicker: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -49,6 +69,12 @@ export default {
|
||||||
...mapGetters({
|
...mapGetters({
|
||||||
widgetColor: 'appConfig/getWidgetColor',
|
widgetColor: 'appConfig/getWidgetColor',
|
||||||
}),
|
}),
|
||||||
|
showAttachment() {
|
||||||
|
return this.userInput.length === 0;
|
||||||
|
},
|
||||||
|
showSendButton() {
|
||||||
|
return this.userInput.length > 0;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
destroyed() {
|
destroyed() {
|
||||||
|
@ -71,6 +97,19 @@ export default {
|
||||||
this.handleButtonClick();
|
this.handleButtonClick();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
toggleEmojiPicker() {
|
||||||
|
this.showEmojiPicker = !this.showEmojiPicker;
|
||||||
|
},
|
||||||
|
hideEmojiPicker() {
|
||||||
|
if (this.showEmojiPicker) {
|
||||||
|
this.toggleEmojiPicker();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
emojiOnClick(emoji) {
|
||||||
|
this.userInput = emojione.shortnameToUnicode(
|
||||||
|
`${this.userInput}${emoji.shortname} `
|
||||||
|
);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -82,4 +121,24 @@ export default {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.emoji-toggle {
|
||||||
|
font-size: $font-size-large;
|
||||||
|
color: $color-gray;
|
||||||
|
padding-right: $space-smaller;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.emoji-dialog {
|
||||||
|
right: $space-one;
|
||||||
|
}
|
||||||
|
|
||||||
|
.file-uploads {
|
||||||
|
margin-right: $space-small;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-wrap {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -57,7 +57,7 @@ export default {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
font-size: $font-size-large;
|
font-size: $font-size-big;
|
||||||
font-weight: $font-weight-medium;
|
font-weight: $font-weight-medium;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue