diff options
Diffstat (limited to 'assets')
-rw-r--r-- | assets/css/app.css | 100 | ||||
-rw-r--r-- | assets/js/chat.js | 43 |
2 files changed, 104 insertions, 39 deletions
diff --git a/assets/css/app.css b/assets/css/app.css index 882a0bb..907783d 100644 --- a/assets/css/app.css +++ b/assets/css/app.css @@ -120,4 +120,104 @@ .thumbnail { max-width: 100px; max-height: 100px; +} + +.post-body { + white-space: pre-line; +} + + +/* Chat css from: https://www.bootdey.com/snippets/view/card-chat-list#html */ +.chat-list { + padding: 0; + font-size: .8rem; +} + +.chat-list li { + margin-bottom: 10px; + overflow: auto; + color: #ffffff; +} + +.chat-list .chat-message { + -webkit-border-radius: 50px; + -moz-border-radius: 50px; + border-radius: 50px; + background: #5a99ee; + display: inline-block; + padding: 10px 20px; + position: relative; +} + +.chat-list .chat-message:before { + content: ""; + position: absolute; + top: 15px; + width: 0; + height: 0; +} + +.chat-list .chat-message h5 { + margin: 0 0 5px 0; + font-weight: 600; + line-height: 100%; + font-size: .9rem; +} + +.chat-list .chat-message p { + line-height: 18px; + margin: 0; + padding: 0; +} + +.chat-list .chat-card-body { + margin-left: 20px; + float: left; + width: 70%; +} + +.chat-list .in .chat-message:before { + left: -12px; + border-bottom: 20px solid transparent; + border-right: 20px solid #5a99ee; +} + +.chat-list .out .chat-img { + float: right; +} + +.chat-list .out .chat-body { + float: right; + margin-right: 20px; + text-align: right; +} + +.chat-list .out .chat-message { + background: #fc6d4c; +} + +.chat-list .out .chat-message:before { + right: -12px; + border-bottom: 20px solid transparent; + border-left: 20px solid #fc6d4c; +} + +.chat-card { + overflow-y: scroll; + max-height: 300px; +} + +.chat-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 { + background: #17202b; + border: 0; + font-size: 1rem; + padding: .65rem 1rem; + position: relative; + font-weight: 600; + color: #ffffff; }
\ No newline at end of file diff --git a/assets/js/chat.js b/assets/js/chat.js index aa32aba..4183531 100644 --- a/assets/js/chat.js +++ b/assets/js/chat.js @@ -1,46 +1,11 @@ let RoomChat = { - init(socket, postId) { - console.log(postId); - console.log(socket); + connect(socket, postId) { let channel = socket.channel(`post:${postId}`) channel.join() - .receive("ok", resp => { console.log("Joined successfully", resp) }) - .receive("error", resp => { console.log("Unable to join", resp) }) - this.listenForChats(channel) + .receive("ok", resp => { console.log("Joined successfully: ", resp) }) + .receive("error", resp => { console.log("Unable to join: ", resp) }) + return channel; }, - addMessage(user, message) { -// let body = `<span class="username"><b>${user}</b></span>: ${message}<br>` -// if (message.match(new RegExp(`@${window.userName}`, "ig"))) { -// $("#chat-box").append('<p class="chat-entry"><span class="mentioned">' + body + '</span></p>') -// } else { -// $("#chat-box").append('<p class="chat-entry">' + body + '</p>') -// } - }, - scrollBottom() { -// $("#chat-box").animate({ scrollTop: $('#chat-box').prop("scrollHeight")}, 200) - }, - listenForChats(channel) { - channel.push('send', { body: "HELLO"}); -// $(() => { -// $("#chat-form").on("submit", function(ev) { -// ev.preventDefault() -// -// let userMsg = $('#user-msg').val() -// channel.push('send', {body: userMsg}) -// -// $("#user-msg").val("") -// }) - -// channel.on('shout', function(payload) { -// console.log(payload) -// RoomChat.addMessage(payload.name, payload.body) -// RoomChat.scrollBottom() -// }) - // }) - channel.on('shout', function(payload) { - console.log(payload) - }); - } } export default RoomChat;
\ No newline at end of file |