aboutsummaryrefslogtreecommitdiff
path: root/src/components/emoji_input/emoji_input.vue
blob: e9ac09c348c06d5f097ab67d741235dbdcf51d7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<template>
  <div
    v-click-outside="onClickOutside"
    class="emoji-input"
    :class="{ 'with-picker': !hideEmojiButton }"
  >
    <slot />
    <template v-if="enableEmojiPicker">
      <div
        v-if="!hideEmojiButton"
        class="emoji-picker-icon"
        @click.prevent="togglePicker"
      >
        <i class="icon-smile" />
      </div>
      <EmojiPicker
        v-if="enableEmojiPicker"
        ref="picker"
        :class="{ hide: !showPicker }"
        :enable-sticker-picker="enableStickerPicker"
        class="emoji-picker-panel"
        @emoji="insert"
        @sticker-uploaded="onStickerUploaded"
        @sticker-upload-failed="onStickerUploadFailed"
      />
    </template>
    <div
      ref="panel"
      class="autocomplete-panel"
      :class="{ hide: !showSuggestions }"
    >
      <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)"
        >
          <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>

<style lang="scss">
@import '../../_variables.scss';

.emoji-input {
  display: flex;
  flex-direction: column;
  position: relative;

  &.with-picker input {
    padding-right: 30px;
  }

  .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
    }
  }

  .autocomplete {
    &-panel {
      position: absolute;
      z-index: 20;
      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-color: $fallback--bg;
        background-color: var(--popover, $fallback--bg);
        color: $fallback--link;
        color: var(--popoverText, $fallback--link);
        --faint: var(--popoverFaintText, $fallback--faint);
        --faintLink: var(--popoverFaintLink, $fallback--faint);
        --lightText: var(--popoverLightText, $fallback--lightText);
        --postLink: var(--popoverPostLink, $fallback--link);
        --postFaintLink: var(--popoverPostFaintLink, $fallback--link);
        --icon: var(--popoverIcon, $fallback--icon);
      }
    }

    &-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(--selectedMenuPopover, $fallback--fg);
        color: var(--selectedMenuPopoverText, $fallback--text);
        --faint: var(--selectedMenuPopoverFaintText, $fallback--faint);
        --faintLink: var(--selectedMenuPopoverFaintLink, $fallback--faint);
        --lightText: var(--selectedMenuPopoverLightText, $fallback--lightText);
        --icon: var(--selectedMenuPopoverIcon, $fallback--icon);
      }
    }
  }

  input, textarea {
    flex: 1 0 auto;
  }
}
</style>