From 0e51fac2b24c752513afe65736e98eb5fb5ec3af Mon Sep 17 00:00:00 2001
From: Roger Braun <rbraun@Bobble.local>
Date: Tue, 5 Dec 2017 11:02:41 +0100
Subject: Add missing component code.

---
 src/components/chat/chat.vue | 49 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 src/components/chat/chat.vue

(limited to 'src/components/chat/chat.vue')

diff --git a/src/components/chat/chat.vue b/src/components/chat/chat.vue
new file mode 100644
index 00000000..9d3ab39c
--- /dev/null
+++ b/src/components/chat/chat.vue
@@ -0,0 +1,49 @@
+<template>
+  <div class="chat-panel panel panel-default">
+    <div class="panel-heading timeline-heading base02-background base04">
+      <div class="title">
+        {{$t('chat.title')}}
+      </div>
+    </div>
+    <div class="panel-body base01-background">
+      <div class="chat-window">
+        <div class="chat-message" v-for="message in messages">
+          <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">
+        <input v-model="currentMessage" type="text" @keyup.enter="submit(currentMessage)">
+      </div>
+    </div>
+  </div>
+</template>
+
+<script src="./chat.js"></script>
+
+
+<style lang="scss">
+ .chat-message {
+   padding: 0.2em 0.5em
+ }
+ .chat-avatar {
+     img {
+         height: 32px;
+         width: 32px;
+         border-radius: 5px;
+         margin-right: 0.5em;
+     }
+ }
+ .chat-input {
+     display: flex;
+     input {
+         flex: auto;
+         margin: 0.5em;
+     }
+ }
+</style>
-- 
cgit v1.2.3-70-g09d2


From a03b92e252406a8469a9ffe871a6882b3aedb366 Mon Sep 17 00:00:00 2001
From: Roger Braun <rbraun@Bobble.local>
Date: Tue, 5 Dec 2017 12:09:54 +0100
Subject: Post on submit, not on enter.

---
 src/components/chat/chat.vue | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

(limited to 'src/components/chat/chat.vue')

diff --git a/src/components/chat/chat.vue b/src/components/chat/chat.vue
index 9d3ab39c..0c397472 100644
--- a/src/components/chat/chat.vue
+++ b/src/components/chat/chat.vue
@@ -18,7 +18,9 @@
         </div>
       </div>
       <div class="chat-input">
-        <input v-model="currentMessage" type="text" @keyup.enter="submit(currentMessage)">
+        <form @submit.prevent="submit(currentMessage)">
+          <input v-model="currentMessage" type="text" >
+        </form>
       </div>
     </div>
   </div>
@@ -41,9 +43,12 @@
  }
  .chat-input {
      display: flex;
-     input {
+     form {
          flex: auto;
-         margin: 0.5em;
+         input {
+             margin: 0.5em;
+             width: 100%;
+         }
      }
  }
 </style>
-- 
cgit v1.2.3-70-g09d2


From 6c4e3a509a23a4f683aee02fcd0b186813ae3de0 Mon Sep 17 00:00:00 2001
From: Roger Braun <rbraun@Bobble.local>
Date: Tue, 5 Dec 2017 14:20:34 +0100
Subject: Don't display if we don't have a chat.

---
 src/components/chat/chat.vue           | 2 +-
 src/components/nav_panel/nav_panel.js  | 3 +++
 src/components/nav_panel/nav_panel.vue | 2 +-
 3 files changed, 5 insertions(+), 2 deletions(-)

(limited to 'src/components/chat/chat.vue')

diff --git a/src/components/chat/chat.vue b/src/components/chat/chat.vue
index 0c397472..488faf9a 100644
--- a/src/components/chat/chat.vue
+++ b/src/components/chat/chat.vue
@@ -7,7 +7,7 @@
     </div>
     <div class="panel-body base01-background">
       <div class="chat-window">
-        <div class="chat-message" v-for="message in messages">
+        <div class="chat-message" v-for="message in messages" :key="message.id">
           <span class="chat-avatar">
             <img :src="message.author.avatar" />
             {{message.author.username}}:
diff --git a/src/components/nav_panel/nav_panel.js b/src/components/nav_panel/nav_panel.js
index baeaaede..ea5d7ea4 100644
--- a/src/components/nav_panel/nav_panel.js
+++ b/src/components/nav_panel/nav_panel.js
@@ -2,6 +2,9 @@ const NavPanel = {
   computed: {
     currentUser () {
       return this.$store.state.users.currentUser
+    },
+    chat () {
+      return this.$store.state.chat.channel
     }
   }
 }
diff --git a/src/components/nav_panel/nav_panel.vue b/src/components/nav_panel/nav_panel.vue
index fa4000b0..ccc772a8 100644
--- a/src/components/nav_panel/nav_panel.vue
+++ b/src/components/nav_panel/nav_panel.vue
@@ -7,7 +7,7 @@
             {{ $t("nav.timeline") }}
           </router-link>
         </li>
-        <li v-if='currentUser'>
+        <li v-if='chat && currentUser'>
           <router-link class="base00-background" to='/chat'>
             {{ $t("nav.chat") }}
           </router-link>
-- 
cgit v1.2.3-70-g09d2


From ecb8acb155a77092b0661854b0ca4cf3c19ff56e Mon Sep 17 00:00:00 2001
From: eal <eal@waifu.club>
Date: Thu, 7 Dec 2017 19:03:26 +0200
Subject: Some css fixes.

Scale chat panel size to viewport height, fit message field to width.
---
 src/components/chat/chat.vue | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

(limited to 'src/components/chat/chat.vue')

diff --git a/src/components/chat/chat.vue b/src/components/chat/chat.vue
index 488faf9a..6c1e2c38 100644
--- a/src/components/chat/chat.vue
+++ b/src/components/chat/chat.vue
@@ -30,6 +30,11 @@
 
 
 <style lang="scss">
+ .chat-window {
+   max-height: 80vh;
+   overflow-y: auto;
+   overflow-x: hidden;
+ }
  .chat-message {
    padding: 0.2em 0.5em
  }
@@ -47,7 +52,7 @@
          flex: auto;
          input {
              margin: 0.5em;
-             width: 100%;
+             width: fill-available;
          }
      }
  }
-- 
cgit v1.2.3-70-g09d2

