chat_panel.vue 2.43 KB
Newer Older
Roger Braun's avatar
Roger Braun committed
1
<template>
2
  <div class="chat-panel" v-if="!this.collapsed || !this.floating">
3
    <div class="panel panel-default">
4
      <div class="panel-heading timeline-heading" :class="{ 'chat-heading': floating }" @click.stop.prevent="togglePanel">
lain's avatar
lain committed
5
        <div class="title">
6 7
          <span>{{$t('chat.title')}}</span>
          <i class="icon-cancel" v-if="floating"></i>
lain's avatar
lain committed
8
        </div>
Roger Braun's avatar
Roger Braun committed
9
      </div>
lain's avatar
lain committed
10
      <div class="chat-window" v-chat-scroll>
11
        <div class="chat-message" v-for="message in messages" :key="message.id">
Roger Braun's avatar
Roger Braun committed
12 13 14
          <span class="chat-avatar">
            <img :src="message.author.avatar" />
          </span>
15
          <div class="chat-content">
16 17 18 19
            <router-link
              class="chat-name"
              :to="userProfileLink(message.author)">
                {{message.author.username}}
20 21 22 23 24 25
            </router-link>
            <br>
            <span class="chat-text">
              {{message.text}}
            </span>
          </div>
Roger Braun's avatar
Roger Braun committed
26 27 28
        </div>
      </div>
      <div class="chat-input">
Shpuld Shpludson's avatar
cleanup  
Shpuld Shpludson committed
29
        <textarea @keyup.enter="submit(currentMessage)" v-model="currentMessage" class="chat-input-textarea" rows="1"></textarea>
Roger Braun's avatar
Roger Braun committed
30 31 32
      </div>
    </div>
  </div>
33 34
  <div v-else class="chat-panel">
    <div class="panel panel-default">
35
      <div class="panel-heading stub timeline-heading chat-heading" @click.stop.prevent="togglePanel">
36
        <div class="title">
37
          <i class="icon-comment-empty"></i>
38 39 40 41 42
          {{$t('chat.title')}}
        </div>
      </div>
    </div>
  </div>
Roger Braun's avatar
Roger Braun committed
43 44
</template>

lain's avatar
lain committed
45
<script src="./chat_panel.js"></script>
Roger Braun's avatar
Roger Braun committed
46 47

<style lang="scss">
48
@import '../../_variables.scss';
49 50 51 52 53 54

.floating-chat {
  position: fixed;
  right: 0px;
  bottom: 0px;
  z-index: 1000;
55
  max-width: 25em;
56 57
}

58 59
.chat-heading {
  cursor: pointer;
60
  .icon-comment-empty {
HJ's avatar
HJ committed
61 62
    color: $fallback--text;
    color: var(--text, $fallback--text);
63
  }
64
}
65 66

.chat-window {
HJ's avatar
indents  
HJ committed
67 68
  overflow-y: auto;
  overflow-x: hidden;
69 70 71 72 73
  max-height: 20em;
}

.chat-window-container {
  height: 100%;
74 75 76
}

.chat-message {
77
  display: flex;
HJ's avatar
indents  
HJ committed
78
  padding: 0.2em 0.5em
79 80 81
}

.chat-avatar {
HJ's avatar
indents  
HJ committed
82
  img {
83 84
    height: 24px;
    width: 24px;
HJ's avatar
indents  
HJ committed
85 86 87
    border-radius: $fallback--avatarRadius;
    border-radius: var(--avatarRadius, $fallback--avatarRadius);
    margin-right: 0.5em;
88
    margin-top: 0.25em;
HJ's avatar
indents  
HJ committed
89
  }
90 91 92
}

.chat-input {
HJ's avatar
indents  
HJ committed
93
  display: flex;
Shpuld Shpludson's avatar
cleanup  
Shpuld Shpludson committed
94 95 96 97 98
  textarea {
    flex: 1;
    margin: 0.6em;
    min-height: 3.5em;
    resize: none;
HJ's avatar
indents  
HJ committed
99
  }
100
}
101 102 103 104 105 106 107

.chat-panel {
  .title {
    display: flex;
    justify-content: space-between;
  }
}
Roger Braun's avatar
Roger Braun committed
108
</style>