diff --git a/components/chat.js b/components/chat.js index d9d66c3..79fc981 100644 --- a/components/chat.js +++ b/components/chat.js @@ -11,12 +11,24 @@ let chat = create({ {sender: "Foks", content: "Hello"}, {sender: "Foks", content: "This is Neo v4"}, {sender: "Foks", content: "Here are a bunch of test messages\nWithout Multiple\nLines\n:("}, - {sender: "Foks", content: "Look at these nice colors"}, - {sender: "Foks", content: "And the font"}, - {sender: "Foks", content: "And the avatars"} + {sender: "Different Foks", content: "Look at these nice colors"}, + {sender: "Different Foks", content: "And the font"}, + {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"}, + {sender: "Foks", content: "Isn't message grouping great?"} ] + let lastSender = "" + let groupCount = 0 + let events = tmpEvents.map((event, id) => { - return + if (event.sender == lastSender) { + groupCount++ + } else { + groupCount = 0 + lastSender = event.sender; + } + return }) //TODO: replace with something that only renders events in view return
@@ -42,10 +54,21 @@ let Event = create({ }, render: function() { - return
- + let className = "event" + if (this.props.groupCount > 0) { + className += " grouped" + if (this.props.groupCount == 1) { + className += " first" + } + } + return
+ {this.props.groupCount == false && + + }
-
{this.props.event.sender}
+ {this.props.groupCount == false && +
{this.props.event.sender}
+ }
{this.state.parsedBody}
diff --git a/public/scss/style.scss b/public/scss/style.scss index 1fa5bc3..425edc8 100644 --- a/public/scss/style.scss +++ b/public/scss/style.scss @@ -169,12 +169,13 @@ body { .body { padding: $spacing; padding-top: 0; + padding-bottom: 0; } #name { font-weight: bold; font-family: "Roboto Bold"; - margin-bottom: $spacing/2; + margin-bottom: 0.3 * $spacing; } #avatar { @@ -190,6 +191,16 @@ body { } } +.event.grouped .body { + padding-bottom: $spacing; + margin-left: 3rem; +} + +.event.grouped.first .body { + margin-top: -1.2 * $spacing; + padding-bottom: 0.3*$spacing; +} + .input { background: $bg1; display: flex;