aboutsummaryrefslogtreecommitdiff
path: root/src/components/emoji-input/emoji-input.vue
diff options
context:
space:
mode:
authorHJ <30-hj@users.noreply.git.pleroma.social>2019-06-18 19:17:37 +0000
committerHJ <30-hj@users.noreply.git.pleroma.social>2019-06-18 19:17:37 +0000
commit69eff65130170c0cd8fffda45b952d3bec49c218 (patch)
treec389a9fb5de43649e46335783f5c244d04100a5c /src/components/emoji-input/emoji-input.vue
parentc0c012ccf9114fb5740dbaf41baa09c0d0c41ebc (diff)
parent46e012206732f331a901eb1c4b90bab14d68d095 (diff)
Merge branch 'refactor-emoji-input' into 'develop'
EmojiInput refactoring Closes #565 See merge request pleroma/pleroma-fe!824
Diffstat (limited to 'src/components/emoji-input/emoji-input.vue')
-rw-r--r--src/components/emoji-input/emoji-input.vue141
1 files changed, 94 insertions, 47 deletions
diff --git a/src/components/emoji-input/emoji-input.vue b/src/components/emoji-input/emoji-input.vue
index 338b77cd..8437a495 100644
--- a/src/components/emoji-input/emoji-input.vue
+++ b/src/components/emoji-input/emoji-input.vue
@@ -1,54 +1,27 @@
<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"
- />
- <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"
- ></textarea>
- <div class="autocomplete-panel" v-if="suggestions">
- <div class="autocomplete-panel-body">
- <div
- v-for="(emoji, index) in suggestions"
- :key="index"
- @click="replace(emoji.utf || (emoji.shortcode + ' '))"
- class="autocomplete-item"
- :class="{ highlighted: emoji.highlighted }"
+<div class="emoji-input">
+ <slot></slot>
+ <div ref="panel" class="autocomplete-panel" :class="{ hide: !showPopup }">
+ <div class="autocomplete-panel-body">
+ <div
+ v-for="(suggestion, index) in suggestions"
+ :key="index"
+ @click.stop.prevent="replaceText"
+ class="autocomplete-item"
+ :class="{ highlighted: suggestion.highlighted }"
>
- <span v-if="emoji.img">
- <img :src="emoji.img" />
- </span>
- <span v-else>{{emoji.utf}}</span>
- <span>{{emoji.shortcode}}</span>
+ <span class="image">
+ <img v-if="suggestion.img":src="suggestion.img" />
+ <span v-else>{{suggestion.replacement}}</span>
+ </span>
+ <div class="label">
+ <span class="displayText">{{suggestion.displayText}}</span>
+ <span class="detailText">{{suggestion.detailText}}</span>
</div>
</div>
</div>
</div>
+</div>
</template>
<script src="./emoji-input.js"></script>
@@ -57,8 +30,82 @@
@import '../../_variables.scss';
.emoji-input {
- .form-control {
- width: 100%;
+ display: flex;
+ flex-direction: column;
+
+ .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>