pleroma-fe/src/components/emoji_input/emoji_input.vue

165 lines
3.6 KiB
Vue
Raw Normal View History

2019-03-26 13:38:15 +11:00
<template>
2019-07-29 07:10:43 +10:00
<div
v-click-outside="onClickOutside"
class="emoji-input"
>
2019-07-05 17:17:44 +10:00
<slot />
2019-09-13 03:36:43 +10:00
<template v-if="enableEmojiPicker">
<div
2019-09-13 03:36:43 +10:00
v-if="!hideEmojiButton"
class="emoji-picker-icon"
2019-07-29 07:10:43 +10:00
@click.prevent="togglePicker"
>
<i class="icon-smile" />
</div>
<EmojiPicker
2019-09-13 03:36:43 +10:00
v-if="enableEmojiPicker"
ref="picker"
2019-07-29 07:10:43 +10:00
:class="{ hide: !showPicker }"
2019-09-13 03:36:43 +10:00
:enable-sticker-picker="enableStickerPicker"
class="emoji-picker-panel"
@emoji="insert"
@sticker-uploaded="onStickerUploaded"
@sticker-upload-failed="onStickerUploadFailed"
2019-07-29 07:10:43 +10:00
/>
</template>
2019-07-05 17:17:44 +10:00
<div
ref="panel"
class="autocomplete-panel"
:class="{ hide: !showSuggestions }"
2019-07-05 17:17:44 +10:00
>
<div class="autocomplete-panel-body">
<div
v-for="(suggestion, index) in suggestions"
:key="index"
class="autocomplete-item"
:class="{ highlighted: suggestion.highlighted }"
@click.stop.prevent="onClick($event, suggestion)"
2019-03-26 13:38:15 +11:00
>
2019-07-05 17:17:44 +10:00
<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>
2019-03-26 13:38:15 +11:00
</div>
2019-06-09 00:15:42 +10:00
</div>
2019-03-26 13:38:15 +11:00
</div>
</div>
</template>
2019-08-12 20:18:37 +10:00
<script src="./emoji_input.js"></script>
2019-03-26 13:38:15 +11:00
<style lang="scss">
@import '../../_variables.scss';
.emoji-input {
display: flex;
flex-direction: column;
position: relative;
.emoji-picker-icon {
position: absolute;
top: 0;
right: 0;
margin: .2em .25em;
font-size: 16px;
cursor: pointer;
line-height: 24px;
&:hover i {
color: $fallback--text;
color: var(--text, $fallback--text);
}
}
.emoji-picker-panel {
position: absolute;
z-index: 20;
margin-top: 2px;
&.hide {
display: none
}
}
2019-06-09 00:15:42 +10:00
.autocomplete {
&-panel {
position: absolute;
z-index: 20;
2019-06-09 00:15:42 +10:00
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;
2019-06-09 00:15:42 +10:00
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 {
2019-06-10 04:23:56 +10:00
flex: 1 0 auto;
2019-03-26 13:38:15 +11:00
}
}
</style>