Skip to content

Commit 1f72f0b

Browse files
committed
Updated chat window message styles
1 parent 7f7e010 commit 1f72f0b

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

index.scss

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,22 @@
3434
}
3535

3636
.chat-message {
37-
padding: 1em;
38-
margin: 1em;
37+
padding: 0.5em;
3938
box-sizing: border-box;
40-
background-color: #fafafa;
4139

42-
& > .chat-message-date {
43-
font-size: 80%;
44-
opacity: 0.5;
40+
&__header {
41+
display: flex;
42+
white-space: nowrap;
43+
overflow: hidden;
44+
text-overflow: ellipsis;
45+
46+
&--username {
47+
font-weight: bold;
48+
}
4549
}
4650

47-
& > .chat-message-from {
48-
font-weight: bold;
49-
margin-top: 1em;
50-
margin-bottom: 1em;
51+
&__body {
52+
margin-top: 0.5em;
5153
}
5254
}
5355
}

src/chat-window.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,15 @@ import {getUsername, getMessageText, createMessage} from './utils.js';
4141
const ChatMessage = ({self, from, body, date}) => h('div', {
4242
class: ['chat-message', self ? 'chat-message-self' : 'chat-message-other'].join(' ')
4343
}, [
44-
h('div', {class: 'chat-message-date'}, date),
45-
h('div', {class: 'chat-message-from'}, getUsername(from)),
46-
h('div', {class: 'chat-message-body'}, body)
44+
h('div', {
45+
class: 'chat-message__header'
46+
}, [
47+
h('div', {class: 'chat-message__header--date'}, `${date} - `),
48+
h('div', {class: 'chat-message__header--username'}, `${getUsername(from)}:`)
49+
]),
50+
h('div', {
51+
class: 'chat-message__body'
52+
}, body)
4753
]);
4854

4955
export const createChatWindow = (core, proc, parent, bus, options) => {
@@ -60,7 +66,7 @@ export const createChatWindow = (core, proc, parent, bus, options) => {
6066

6167
const messages = (state, actions) => state.messages.map(({date, msg}) => {
6268
return h(ChatMessage, {
63-
date: format(date, 'fullDate'),
69+
date: format(date, 'longTime'),
6470
self: getUsername(msg.getAttribute('from')) !== getUsername(options.user),
6571
to: msg.getAttribute('to'),
6672
from: msg.getAttribute('from'),

0 commit comments

Comments
 (0)