summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLogan Hunt <loganhunt@simponic.xyz>2022-04-20 17:23:27 -0600
committerLogan Hunt <loganhunt@simponic.xyz>2022-04-20 17:23:27 -0600
commitd9943b201d98a2396d62b9a190659e2e776da019 (patch)
tree2399fe496ba6d4650f9f0c56a2b926a9235104d8
parent763ea5331b1977dd949c776215f2c7719f81ee9a (diff)
downloadaggiedit-d9943b201d98a2396d62b9a190659e2e776da019.tar.gz
aggiedit-d9943b201d98a2396d62b9a190659e2e776da019.zip
UI updates and fix message directioning
-rw-r--r--assets/css/app.css33
-rw-r--r--lib/aggiedit/rooms/comment.ex2
-rw-r--r--lib/aggiedit_web/live/post_live/show.html.heex24
3 files changed, 39 insertions, 20 deletions
diff --git a/assets/css/app.css b/assets/css/app.css
index 907783d..2cc38b4 100644
--- a/assets/css/app.css
+++ b/assets/css/app.css
@@ -128,9 +128,15 @@
/* Chat css from: https://www.bootdey.com/snippets/view/card-chat-list#html */
+.chat-container {
+ height: 300px;
+ overflow-y: scroll;
+}
+
.chat-list {
padding: 0;
font-size: .8rem;
+ padding-bottom: 12px;
}
.chat-list li {
@@ -139,6 +145,18 @@
color: #ffffff;
}
+.chat-list .chat-img {
+ float: left;
+ width: 48px;
+}
+
+.chat-list .chat-img img {
+ -webkit-border-radius: 50px;
+ -moz-border-radius: 50px;
+ border-radius: 50px;
+ width: 100%;
+}
+
.chat-list .chat-message {
-webkit-border-radius: 50px;
-moz-border-radius: 50px;
@@ -170,7 +188,7 @@
padding: 0;
}
-.chat-list .chat-card-body {
+.chat-list .chat-body {
margin-left: 20px;
float: left;
width: 70%;
@@ -202,17 +220,12 @@
border-left: 20px solid #fc6d4c;
}
-.chat-card {
- overflow-y: scroll;
- max-height: 300px;
-}
-
-.chat-card .card-header:first-child {
+.card .card-header:first-child {
-webkit-border-radius: 0.3rem 0.3rem 0 0;
-moz-border-radius: 0.3rem 0.3rem 0 0;
border-radius: 0.3rem 0.3rem 0 0;
}
-.chat-card .card-header {
+.card .card-header {
background: #17202b;
border: 0;
font-size: 1rem;
@@ -220,4 +233,8 @@
position: relative;
font-weight: 600;
color: #ffffff;
+}
+
+.content{
+ margin-top:40px;
} \ No newline at end of file
diff --git a/lib/aggiedit/rooms/comment.ex b/lib/aggiedit/rooms/comment.ex
index 01f411a..2dfa98e 100644
--- a/lib/aggiedit/rooms/comment.ex
+++ b/lib/aggiedit/rooms/comment.ex
@@ -19,6 +19,6 @@ defmodule Aggiedit.Post.Comment do
end
def serialize(c) do
- %{"body" => c.comment, "user" => c.user.username, "id" => c.id, "inserted_at" => c.inserted_at}
+ %{"body" => c.comment, "user" => c.user.username, "user_id" => c.user_id, "id" => c.id, "inserted_at" => c.inserted_at}
end
end
diff --git a/lib/aggiedit_web/live/post_live/show.html.heex b/lib/aggiedit_web/live/post_live/show.html.heex
index 8f91fda..b89999b 100644
--- a/lib/aggiedit_web/live/post_live/show.html.heex
+++ b/lib/aggiedit_web/live/post_live/show.html.heex
@@ -22,14 +22,15 @@
<!-- chat container from https://www.bootdey.com/snippets/view/card-chat-list#html -->
<div class="container content mt-2">
<div class="row">
- <div class="col-xl-6 col-lg-6 col-md-6 col-sm-12 col-12">
- <div class="chat-card">
- <div class="chat-card-body">
- <ul class="chat-list" id="chat" phx-update="ignore">
- </ul>
+ <div class="col-xl-6 col-lg-6 col-md-6 col-sm-12 col-12">
+ <div class="card">
+ <div class="card-header">Chat</div>
+ <div class="card-body chat-container">
+ <ul class="chat-list" id="chat">
+ </ul>
+ </div>
+ </div>
</div>
- </div>
- </div>
</div>
</div>
@@ -52,11 +53,11 @@
element.scrollIntoView({ behavior: 'smooth', block: 'end' });
};
- const appendComment = ({user, body, id, inserted_at}, element) => {
+ const appendComment = ({user, body, id, user_id, inserted_at}, element) => {
const messageElement = document.createElement("div");
messageElement.innerHTML = `
- <li class="in" id=${id}>
- <div class="chat-card-body">
+ <li class="${user_id == <%= @current_user.id %> ? 'out' : 'in'}" id=${id}>
+ <div class="chat-body">
<div class="chat-message">
<h5>${user}</h5>
<p>${body}</p>
@@ -69,10 +70,11 @@
};
+ let channel;
window.addEventListener('phx:initial-post', (e) => {
const chatWindow = document.getElementById("chat");
window.userSocket.connect();
- let channel = window.RoomChat.connect(window.userSocket, e.detail.id);
+ channel = window.RoomChat.connect(window.userSocket, e.detail.id);
channel.on('shout', (comment) => {
appendComment(comment, chatWindow);