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
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<file-upload :size="4096 * 2048" @input-file="onFileUpload">
|
||||
<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" />
|
||||
</span>
|
||||
</file-upload>
|
||||
|
@ -52,18 +52,16 @@ export default {
|
|||
cursor: pointer;
|
||||
position: relative;
|
||||
padding-right: $space-smaller;
|
||||
display: block;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
|
||||
i {
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
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");
|
||||
font-size: $font-size-large;
|
||||
color: $color-gray;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<style lang="scss">
|
||||
.file-uploads .attachment-button + label {
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -1,20 +1,38 @@
|
|||
<template>
|
||||
<div class="chat-message--input">
|
||||
<chat-attachment-button :on-attach="onSendAttachment" />
|
||||
<ChatInputArea v-model="userInput" :placeholder="placeholder" />
|
||||
<ChatSendButton
|
||||
:on-click="handleButtonClick"
|
||||
:disabled="!userInput.length"
|
||||
:color="widgetColor"
|
||||
/>
|
||||
<chat-input-area v-model="userInput" :placeholder="placeholder" />
|
||||
<div class="button-wrap">
|
||||
<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"
|
||||
:color="widgetColor"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex';
|
||||
import emojione from 'emojione';
|
||||
import { mixin as clickaway } from 'vue-clickaway';
|
||||
import ChatSendButton from 'widget/components/ChatSendButton.vue';
|
||||
import ChatAttachmentButton from 'widget/components/ChatAttachment.vue';
|
||||
import ChatInputArea from 'widget/components/ChatInputArea.vue';
|
||||
import EmojiInput from 'dashboard/components/widgets/emoji/EmojiInput';
|
||||
|
||||
export default {
|
||||
name: 'ChatInputWrap',
|
||||
|
@ -22,8 +40,9 @@ export default {
|
|||
ChatAttachmentButton,
|
||||
ChatSendButton,
|
||||
ChatInputArea,
|
||||
EmojiInput,
|
||||
},
|
||||
|
||||
mixins: [clickaway],
|
||||
props: {
|
||||
placeholder: {
|
||||
type: String,
|
||||
|
@ -42,6 +61,7 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
userInput: '',
|
||||
showEmojiPicker: false,
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -49,6 +69,12 @@ export default {
|
|||
...mapGetters({
|
||||
widgetColor: 'appConfig/getWidgetColor',
|
||||
}),
|
||||
showAttachment() {
|
||||
return this.userInput.length === 0;
|
||||
},
|
||||
showSendButton() {
|
||||
return this.userInput.length > 0;
|
||||
},
|
||||
},
|
||||
|
||||
destroyed() {
|
||||
|
@ -71,6 +97,19 @@ export default {
|
|||
this.handleButtonClick();
|
||||
}
|
||||
},
|
||||
toggleEmojiPicker() {
|
||||
this.showEmojiPicker = !this.showEmojiPicker;
|
||||
},
|
||||
hideEmojiPicker() {
|
||||
if (this.showEmojiPicker) {
|
||||
this.toggleEmojiPicker();
|
||||
}
|
||||
},
|
||||
emojiOnClick(emoji) {
|
||||
this.userInput = emojione.shortnameToUnicode(
|
||||
`${this.userInput}${emoji.shortname} `
|
||||
);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
@ -82,4 +121,24 @@ export default {
|
|||
align-items: center;
|
||||
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>
|
||||
|
|
|
@ -57,7 +57,7 @@ export default {
|
|||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: $font-size-large;
|
||||
font-size: $font-size-big;
|
||||
font-weight: $font-weight-medium;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue