<template>
  <div class="chat-panel">
    <div class="panel panel-default">
      <div class="panel-heading timeline-heading">
        <div class="title">
          {{$t('chat.title')}}
        </div>
      </div>
      <div class="chat-window" v-chat-scroll>
        <div class="chat-message" v-for="message in messages" :key="message.id">
          <span class="chat-avatar">
            <img :src="message.author.avatar" />
            {{message.author.username}}:
          </span>
          <span class="chat-text">
            {{message.text}}
          </span>
        </div>
      </div>
      <div class="chat-input">
        <form @submit.prevent="submit(currentMessage)">
          <input v-model="currentMessage" type="text" >
        </form>
      </div>
    </div>
  </div>
</template>

<script src="./chat_panel.js"></script>

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

.chat-window {
  max-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
}

.chat-message {
  padding: 0.2em 0.5em
}

.chat-avatar {
  img {
    height: 32px;
    width: 32px;
    border-radius: $fallback--avatarRadius;
    border-radius: var(--avatarRadius, $fallback--avatarRadius);
    margin-right: 0.5em;
  }
}

.chat-input {
  display: flex;
  form {
    flex: auto;
    input {
      margin: 0.5em;
      width: fill-available;
    }
  }
}
</style>
