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
+
+
    +
+
+
-
-
@@ -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 = ` -
  • -
    +
  • +
    ${user}

    ${body}

    @@ -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);