Skip to content

Commit 8411746

Browse files
committed
(UI) improve rooms list
1 parent 7f1442a commit 8411746

File tree

3 files changed

+33
-32
lines changed

3 files changed

+33
-32
lines changed

demo/src/ChatContainer.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ export default {
257257
const date = new Date(message.timestamp.seconds * 1000)
258258
const timestampFormat = isSameDay(date, new Date())
259259
? 'HH:mm'
260-
: 'DD MMMM YYYY'
260+
: 'DD/MM/YY'
261261
262262
let timestamp = parseTimestamp(message.timestamp, timestampFormat)
263263
if (timestampFormat === 'HH:mm') timestamp = 'Today, ' + timestamp

demo/src/utils/dates.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ export const parseTimestamp = (timestamp, format = '') => {
1010
} else if (format === 'DD MMMM YYYY') {
1111
const options = { month: 'long', year: 'numeric', day: 'numeric' }
1212
return `${new Intl.DateTimeFormat('en-GB', options).format(date)}`
13+
} else if (format === 'DD/MM/YY') {
14+
const options = { month: 'numeric', year: 'numeric', day: 'numeric' }
15+
return `${new Intl.DateTimeFormat('en-GB', options).format(date)}`
1316
}
1417
return date
1518
}

src/ChatWindow/RoomsList.vue

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,18 @@
3636
:style="{ background: `url(${room.avatar})` }"
3737
></div>
3838
<div class="name-container">
39-
<div class="room-name">{{ room.roomName }}</div>
39+
<div class="title-container">
40+
<div class="room-name">{{ room.roomName }}</div>
41+
<div class="room-name text-date" v-if="room.lastMessage">
42+
{{ room.lastMessage.timestamp }}
43+
</div>
44+
</div>
4045
<div class="room-name text-last" v-if="room.lastMessage">
4146
<span v-if="room.lastMessage.seen">
4247
<svg-icon name="checkmark" class="icon-check" />
4348
</span>
4449
<span>{{ room.lastMessage.content }}</span>
4550
</div>
46-
<div class="room-name text-date" v-if="room.lastMessage">
47-
{{ room.lastMessage.timestamp }}
48-
</div>
4951
</div>
5052
</div>
5153
</div>
@@ -175,61 +177,57 @@ input {
175177
padding: 0 16px;
176178
position: relative;
177179
min-height: 71px;
178-
}
179180
180-
.room-item:hover {
181-
background: var(--chat-sidemenu-bg-color-hover);
182-
-webkit-transition: background-color 0.3s cubic-bezier(0.25, 0.8, 0.5, 1);
183-
transition: background-color 0.3s cubic-bezier(0.25, 0.8, 0.5, 1);
184-
}
181+
&:hover {
182+
background: var(--chat-sidemenu-bg-color-hover);
183+
-webkit-transition: background-color 0.3s cubic-bezier(0.25, 0.8, 0.5, 1);
184+
transition: background-color 0.3s cubic-bezier(0.25, 0.8, 0.5, 1);
185+
}
185186
186-
.room-item:not(:hover) {
187-
-webkit-transition: background-color 0.3s cubic-bezier(0.25, 0.8, 0.5, 1);
188-
transition: background-color 0.3s cubic-bezier(0.25, 0.8, 0.5, 1);
187+
&:not(:hover) {
188+
-webkit-transition: background-color 0.3s cubic-bezier(0.25, 0.8, 0.5, 1);
189+
transition: background-color 0.3s cubic-bezier(0.25, 0.8, 0.5, 1);
190+
}
189191
}
190192
191193
.room-selected {
192194
color: var(--chat-sidemenu-color-active) !important;
193195
background: var(--chat-sidemenu-bg-color-active) !important;
194196
195-
:hover {
196-
background: var(--chat-sidemenu-bg-color-active);
197+
&:hover {
198+
background: var(--chat-sidemenu-bg-color-active) !important;
197199
}
198200
}
199201
200202
.name-container {
201-
-webkit-box-align: center;
202-
align-items: center;
203-
align-self: center;
204-
display: -webkit-box;
205-
display: flex;
206-
flex-wrap: wrap;
207-
-webkit-box-flex: 1;
208203
flex: 1 1;
209-
overflow: hidden;
210-
padding: 8px 0;
204+
}
205+
206+
.title-container {
207+
display: flex;
208+
align-items: center;
211209
}
212210
213211
.room-name {
214-
-webkit-box-flex: 1;
215-
flex: 1 1 100%;
212+
white-space: nowrap;
216213
overflow: hidden;
217214
text-overflow: ellipsis;
215+
flex: 1;
218216
white-space: nowrap;
219-
line-height: 22px;
217+
overflow: hidden;
218+
text-overflow: ellipsis;
220219
color: var(--chat-room-color-username);
221220
}
222221
223222
.text-last {
224-
color: var(--chat-room-color-message) !important;
223+
color: var(--chat-room-color-message);
225224
font-size: 12px;
226-
line-height: 16px;
227225
}
228226
229227
.text-date {
230-
color: var(--chat-room-color-timestamp) !important;
228+
color: var(--chat-room-color-timestamp);
231229
font-size: 11px;
232-
line-height: 16px;
230+
text-align: right;
233231
}
234232
235233
.room-disabled {

0 commit comments

Comments
 (0)