aboutsummaryrefslogtreecommitdiff
path: root/src/components/emoji-input/emoji-input.vue
diff options
context:
space:
mode:
authorHenry Jameson <me@hjkos.com>2019-07-28 13:30:29 +0300
committerHenry Jameson <me@hjkos.com>2019-07-28 13:30:29 +0300
commitb3aff9bbae77b2fd34b2267ce9196c0ebd3e4691 (patch)
tree1219e00b6bfe6784add1578a3bc986c1dbb5f34d /src/components/emoji-input/emoji-input.vue
parent7f6f025792dcb3a10c94c8952d0312abd0b46989 (diff)
parent4827e4d972f8ee11e606693e24ae4ca21711c6b1 (diff)
Merge remote-tracking branch 'upstream/develop' into emoji-selector-update
* upstream/develop: (469 commits) Feature/add sticker picker guard more secure routes guard secure routes by redirecting to root closest can returns itself as well find inside status-content div only try to use the closest a tag as target Update es.json Also apply keyword filter to subjects Remove files I accidentally pushed in fix issues caused by merges in usersearch on @ Add user search at fix eslint warnings remove vue-popperjs fix moderation menu partially hidden by usercard boundary migrate popper css rewrite ModerationTools using v-tooltip make popover position for status action dropdow relative to parent node rewrite ExtraButtons using v-tooltip install v-tooltip i18n/Update pedantic Japanese translation ...
Diffstat (limited to 'src/components/emoji-input/emoji-input.vue')
-rw-r--r--src/components/emoji-input/emoji-input.vue138
1 files changed, 93 insertions, 45 deletions
diff --git a/src/components/emoji-input/emoji-input.vue b/src/components/emoji-input/emoji-input.vue
index 151861de..48739ec8 100644
--- a/src/components/emoji-input/emoji-input.vue
+++ b/src/components/emoji-input/emoji-input.vue
@@ -1,53 +1,30 @@
<template>
<div class="emoji-input">
- <input
- v-if="type !== 'textarea'"
- :class="classname"
- :type="type"
- :value="value"
- :placeholder="placeholder"
- @input="onInput"
- @click="setCaret"
- @keyup="setCaret"
- @keydown="onKeydown"
- @keydown.down="cycleForward"
- @keydown.up="cycleBackward"
- @keydown.shift.tab="cycleBackward"
- @keydown.tab="cycleForward"
- @keydown.enter="replaceEmoji"
- ref="input"
- />
- <textarea
- v-else
- :class="classname"
- :value="value"
- :placeholder="placeholder"
- @input="onInput"
- @click="setCaret"
- @keyup="setCaret"
- @keydown="onKeydown"
- @keydown.down="cycleForward"
- @keydown.up="cycleBackward"
- @keydown.shift.tab="cycleBackward"
- @keydown.tab="cycleForward"
- @keydown.enter="replaceEmoji"
- ref="input"
- ></textarea>
- <EmojiSelector @emoji="onEmoji" />
- <div class="autocomplete-panel" v-if="suggestions">
+ <slot />
+ <div
+ ref="panel"
+ class="autocomplete-panel"
+ :class="{ hide: !showPopup }"
+ >
<div class="autocomplete-panel-body">
<div
- v-for="(emoji, index) in suggestions"
+ v-for="(suggestion, index) in suggestions"
:key="index"
- @click="replace(emoji.utf || (emoji.shortcode + ' '))"
class="autocomplete-item"
- :class="{ highlighted: emoji.highlighted }"
+ :class="{ highlighted: suggestion.highlighted }"
+ @click.stop.prevent="onClick($event, suggestion)"
>
- <span v-if="emoji.img">
- <img :src="emoji.img" />
+ <span class="image">
+ <img
+ v-if="suggestion.img"
+ :src="suggestion.img"
+ >
+ <span v-else>{{ suggestion.replacement }}</span>
</span>
- <span v-else>{{emoji.utf}}</span>
- <span>{{emoji.shortcode}}</span>
+ <div class="label">
+ <span class="displayText">{{ suggestion.displayText }}</span>
+ <span class="detailText">{{ suggestion.detailText }}</span>
+ </div>
</div>
</div>
</div>
@@ -60,10 +37,81 @@
@import '../../_variables.scss';
.emoji-input {
- position: relative;
+ display: flex;
+ flex-direction: column;
- .form-control {
- width: 100%;
+ .autocomplete {
+ &-panel {
+ position: absolute;
+ z-index: 9;
+ margin-top: 2px;
+
+ &.hide {
+ display: none
+ }
+
+ &-body {
+ margin: 0 0.5em 0 0.5em;
+ border-radius: $fallback--tooltipRadius;
+ border-radius: var(--tooltipRadius, $fallback--tooltipRadius);
+ box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.5);
+ box-shadow: var(--popupShadow);
+ min-width: 75%;
+ background: $fallback--bg;
+ background: var(--bg, $fallback--bg);
+ color: $fallback--lightText;
+ color: var(--lightText, $fallback--lightText);
+ }
+ }
+
+ &-item {
+ display: flex;
+ cursor: pointer;
+ padding: 0.2em 0.4em;
+ border-bottom: 1px solid rgba(0, 0, 0, 0.4);
+ height: 32px;
+
+ .image {
+ width: 32px;
+ height: 32px;
+ line-height: 32px;
+ text-align: center;
+ font-size: 32px;
+
+ margin-right: 4px;
+
+ img {
+ width: 32px;
+ height: 32px;
+ object-fit: contain;
+ }
+ }
+
+ .label {
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ margin: 0 0.1em 0 0.2em;
+
+ .displayText {
+ line-height: 1.5;
+ }
+
+ .detailText {
+ font-size: 9px;
+ line-height: 9px;
+ }
+ }
+
+ &.highlighted {
+ background-color: $fallback--fg;
+ background-color: var(--lightBg, $fallback--fg);
+ }
+ }
+ }
+
+ input, textarea {
+ flex: 1 0 auto;
}
}
</style>