From 4ad9d1ad4fd12a2ffa54bdf751905fef4bfce3ff Mon Sep 17 00:00:00 2001 From: f0x Date: Tue, 22 Jan 2019 01:50:56 +0100 Subject: [PATCH] sticky avatars --- components/chat.js | 9 ++++++++- public/scss/style.scss | 13 ++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/components/chat.js b/components/chat.js index cffed28..0787f42 100644 --- a/components/chat.js +++ b/components/chat.js @@ -3,9 +3,11 @@ const React = require('react') const ReactDOM = require('react-dom') const create = require('create-react-class') const Promise = require('bluebird') +const debounce = require('debounce') let chat = create({ displayName: "Chat", + render: function() { let tmpEvents = [ {sender: "Foks", content: "Hello"}, @@ -13,7 +15,9 @@ let chat = create({ {sender: "Foks", content: "Here is one test event\nWith\n Multiple\nLines\n:)"}, {sender: "Different Foks", content: "Look at these nice colors"}, {sender: "Different Foks", content: "And the font"}, - {sender: "Lain", content: "A single message"}, + {sender: "Lain", content: "image"}, + {sender: "Lain", content: "image"}, + {sender: "Lain", content: "image"}, {sender: "Different Foks", content: "And the avatars"}, {sender: "Foks", content: "Every line has it's own message"}, {sender: "Foks", content: "But if the sender is the same, we don't repeat the name+image"}, @@ -83,6 +87,9 @@ let Event = create({ render: function() { //TODO: HTML Sanitize let parsedBody = this.props.event.content.split("\n").map((line, id) => { + if (line.startsWith("image")) { + return + } return {line}
}) return
diff --git a/public/scss/style.scss b/public/scss/style.scss index b39c1d5..40196d9 100644 --- a/public/scss/style.scss +++ b/public/scss/style.scss @@ -155,6 +155,7 @@ body { .chat { padding: $spacing; background: $bg0; + position: relative; .events { display: flex; @@ -182,7 +183,11 @@ body { box-sizing: border-box; object-fit: cover; - border: 3px solid lighten($bg0, 10); + border: 0.2rem solid lighten($bg0, 10); + align-self: flex-end; + + position: sticky; + bottom: $spacing/4 - 0.2rem; } .col { @@ -193,6 +198,12 @@ body { /* debug */ //border: 1px solid $red; padding: $spacing/4; + + img { + max-height: 40vh; + max-width: 90%; + object-fit: contain; + } } .body:hover {