Adds character count to reply box 😳 (#1634)
* Added characters remaining to reply box * Changed warning text for character length * Decreased font size of message
This commit is contained in:
parent
fd181f18a1
commit
dad737021f
3 changed files with 47 additions and 6 deletions
|
@ -19,12 +19,18 @@
|
||||||
{{ $t('CONVERSATION.REPLYBOX.PRIVATE_NOTE') }}
|
{{ $t('CONVERSATION.REPLYBOX.PRIVATE_NOTE') }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="action-wrap"></div>
|
<div class="action-wrap">
|
||||||
|
<div v-if="isMessageLengthReachingThreshold" class="tabs-title">
|
||||||
|
<span :class="charLengthClass">
|
||||||
|
{{ characterLengthWarning }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { REPLY_EDITOR_MODES } from './constants';
|
import { REPLY_EDITOR_MODES, CHAR_LENGTH_WARNING } from './constants';
|
||||||
import EmojiOrIcon from 'shared/components/EmojiOrIcon';
|
import EmojiOrIcon from 'shared/components/EmojiOrIcon';
|
||||||
export default {
|
export default {
|
||||||
name: 'ReplyTopPanel',
|
name: 'ReplyTopPanel',
|
||||||
|
@ -40,6 +46,14 @@ export default {
|
||||||
type: Function,
|
type: Function,
|
||||||
default: () => {},
|
default: () => {},
|
||||||
},
|
},
|
||||||
|
isMessageLengthReachingThreshold: {
|
||||||
|
type: Boolean,
|
||||||
|
default: () => false,
|
||||||
|
},
|
||||||
|
charactersRemaining: {
|
||||||
|
type: Number,
|
||||||
|
default: () => 0,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
replyButtonClass() {
|
replyButtonClass() {
|
||||||
|
@ -52,6 +66,14 @@ export default {
|
||||||
'is-active': this.mode === REPLY_EDITOR_MODES.NOTE,
|
'is-active': this.mode === REPLY_EDITOR_MODES.NOTE,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
charLengthClass() {
|
||||||
|
return this.charactersRemaining < 0 ? 'message-error' : 'message-length';
|
||||||
|
},
|
||||||
|
characterLengthWarning() {
|
||||||
|
return this.charactersRemaining < 0
|
||||||
|
? `${-this.charactersRemaining} ${CHAR_LENGTH_WARNING.NEGATIVE}`
|
||||||
|
: `${this.charactersRemaining} ${CHAR_LENGTH_WARNING.UNDER_50}`;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleReplyClick() {
|
handleReplyClick() {
|
||||||
|
@ -113,5 +135,14 @@ export default {
|
||||||
.action-wrap {
|
.action-wrap {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
margin: 0 var(--space-normal);
|
||||||
|
font-size: var(--font-size-mini);
|
||||||
|
|
||||||
|
.message-error {
|
||||||
|
color: var(--r-600);
|
||||||
|
}
|
||||||
|
.message-length {
|
||||||
|
color: var(--s-600);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -2,3 +2,8 @@ export const REPLY_EDITOR_MODES = {
|
||||||
REPLY: 'REPLY',
|
REPLY: 'REPLY',
|
||||||
NOTE: 'NOTE',
|
NOTE: 'NOTE',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const CHAR_LENGTH_WARNING = {
|
||||||
|
UNDER_50: 'characters remaining',
|
||||||
|
NEGATIVE: 'characters over',
|
||||||
|
};
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="reply-box" :class="replyBoxClass">
|
<div class="reply-box" :class="replyBoxClass">
|
||||||
<reply-top-panel :mode="replyType" :set-reply-mode="setReplyMode" />
|
<reply-top-panel
|
||||||
|
:mode="replyType"
|
||||||
|
:set-reply-mode="setReplyMode"
|
||||||
|
:is-message-length-reaching-threshold="isMessageLengthReachingThreshold"
|
||||||
|
:characters-remaining="charactersRemaining"
|
||||||
|
/>
|
||||||
<div class="reply-box__top">
|
<div class="reply-box__top">
|
||||||
<canned-response
|
<canned-response
|
||||||
v-if="showCannedResponsesList"
|
v-if="showCannedResponsesList"
|
||||||
|
@ -111,10 +116,10 @@ export default {
|
||||||
: this.$t('CONVERSATION.FOOTER.MSG_INPUT');
|
: this.$t('CONVERSATION.FOOTER.MSG_INPUT');
|
||||||
},
|
},
|
||||||
isMessageLengthReachingThreshold() {
|
isMessageLengthReachingThreshold() {
|
||||||
return this.message.length > this.maxLength - 40;
|
return this.message.length > this.maxLength - 50;
|
||||||
},
|
},
|
||||||
characterCountIndicator() {
|
charactersRemaining() {
|
||||||
return `${this.message.length} / ${this.maxLength}`;
|
return this.maxLength - this.message.length;
|
||||||
},
|
},
|
||||||
isReplyButtonDisabled() {
|
isReplyButtonDisabled() {
|
||||||
const isMessageEmpty = !this.message.trim().replace(/\n/g, '').length;
|
const isMessageEmpty = !this.message.trim().replace(/\n/g, '').length;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue