This commit is contained in:
Henry Jameson 2019-06-08 17:15:42 +03:00
parent 8872b4802e
commit 0a778160cc
3 changed files with 78 additions and 63 deletions

View File

@ -806,50 +806,3 @@ nav {
.btn.btn-default { .btn.btn-default {
min-height: 28px; min-height: 28px;
} }
.autocomplete {
&-panel {
&-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);
// this doesn't match original but i don't care, making it uniform.
box-shadow: var(--popupShadow);
min-width: 75%;
background: $fallback--bg;
background: var(--bg, $fallback--bg);
color: $fallback--lightText;
color: var(--lightText, $fallback--lightText);
}
}
&-item {
cursor: pointer;
padding: 0.2em 0.4em 0.2em 0.4em;
border-bottom: 1px solid rgba(0, 0, 0, 0.4);
display: flex;
img {
width: 24px;
height: 24px;
object-fit: contain;
}
span {
line-height: 24px;
margin: 0 0.1em 0 0.2em;
}
small {
margin-left: .5em;
color: $fallback--faint;
color: var(--faint, $fallback--faint);
}
&.highlighted {
background-color: $fallback--fg;
background-color: var(--lightBg, $fallback--fg);
}
}
}

View File

@ -37,9 +37,8 @@ const EmojiInput = {
return false return false
} }
return take(matchedSuggestions, 5) return take(matchedSuggestions, 5)
.map(({ displayText, imageUrl, replacement }, index) => ({ .map(({ imageUrl, ...rest }, index) => ({
displayText, ...rest,
replacement,
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
img: imageUrl || '', img: imageUrl || '',
highlighted: index === this.highlighted highlighted: index === this.highlighted

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="emoji-input"> <div class="emoji-input">
<slot></slot> <slot></slot>
<div ref="panel" class="autocomplete-panel" :class="{ hide: suggestions}"> <div ref="panel" class="autocomplete-panel" :class="{ hide: !showPopup }">
<div class="autocomplete-panel-body"> <div class="autocomplete-panel-body">
<div <div
v-for="(suggestion, index) in suggestions" v-for="(suggestion, index) in suggestions"
@ -10,12 +10,14 @@
class="autocomplete-item" class="autocomplete-item"
:class="{ highlighted: suggestion.highlighted }" :class="{ highlighted: suggestion.highlighted }"
> >
<span v-if="suggestion.img"> <span class="image">
<img :src="suggestion.img" /> <img v-if="suggestion.img":src="suggestion.img" />
</span>
<span v-else>{{suggestion.replacement}}</span> <span v-else>{{suggestion.replacement}}</span>
<span>{{suggestion.displayText}}</span> </span>
<span>{{suggestion.detailText}}</span> <div class="label">
<span class="displayText">{{suggestion.displayText}}</span>
<span class="detailText">{{suggestion.detailText}}</span>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -31,15 +33,76 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
.autocomplete {
&-panel {
position: absolute;
z-index: 9;
margin-top: 2px;
&.hide { &.hide {
display: none display: none
} }
.autocomplete-panel { &-body {
position: absolute; margin: 0 0.5em 0 0.5em;
z-index: 9; border-radius: $fallback--tooltipRadius;
margin-top: 2px; 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 { input, textarea {
flex: 1; flex: 1;