Skip to content

Commit 534d058

Browse files
committed
(demo) improve theme and responsiveness
1 parent bc1294d commit 534d058

File tree

2 files changed

+62
-14
lines changed

2 files changed

+62
-14
lines changed

demo/src/App.vue

Lines changed: 58 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
<template>
22
<div>
3-
<div class="app-container">
3+
<div
4+
class="app-container"
5+
:class="{ 'app-mobile': isDevice, 'app-mobile-dark': theme === 'dark' }"
6+
>
47
<!-- <div>
58
<button @click="resetData">Clear Data</button>
69
<button @click="addData" :disabled="updatingData">Add Data</button>
710
</div> -->
8-
<span class="user-logged" v-if="!isDevice">Logged as</span>
9-
<select v-model="currentUserId" v-if="!isDevice">
11+
<span
12+
class="user-logged"
13+
:class="{ 'user-logged-dark': theme === 'dark' }"
14+
v-if="showOptions"
15+
>
16+
Logged as
17+
</span>
18+
<select v-model="currentUserId" v-if="showOptions">
1019
<option v-for="user in users" :key="user._id" :value="user._id">
1120
{{ user.username }}
1221
</option>
1322
</select>
1423

15-
<div class="button-theme" v-if="!isDevice">
24+
<div class="button-theme" v-if="showOptions">
1625
<button @click="theme = 'light'" class="button-light">Light</button>
1726
<button @click="theme = 'dark'" class="button-dark">Dark</button>
1827
</div>
@@ -21,6 +30,7 @@
2130
:currentUserId="currentUserId"
2231
:theme="theme"
2332
:isDevice="isDevice"
33+
@show-demo-options="showDemoOptions = $event"
2434
v-if="showChat"
2535
/>
2636

@@ -63,10 +73,19 @@ export default {
6373
}
6474
],
6575
currentUserId: '6R0MijpK6M4AIrwaaCY2',
76+
isDevice: false,
77+
showDemoOptions: true,
6678
updatingData: false
6779
}
6880
},
6981
82+
mounted() {
83+
this.isDevice = window.innerWidth < 500
84+
window.addEventListener('resize', ev => {
85+
if (ev.isTrusted) this.isDevice = window.innerWidth < 500
86+
})
87+
},
88+
7089
watch: {
7190
currentUserId() {
7291
this.showChat = false
@@ -75,8 +94,8 @@ export default {
7594
},
7695
7796
computed: {
78-
isDevice() {
79-
return window.innerWidth < 500
97+
showOptions() {
98+
return !this.isDevice || this.showDemoOptions
8099
}
81100
},
82101
@@ -142,28 +161,54 @@ body {
142161
margin: 0;
143162
}
144163
164+
input {
165+
-webkit-appearance: none;
166+
}
167+
145168
.app-container {
146169
font-family: 'Quicksand', sans-serif;
147170
padding: 20px 30px 30px;
171+
}
172+
173+
.app-mobile {
174+
padding: 0;
148175
149-
@media only screen and (max-width: 768px) {
150-
padding: 0;
176+
&.app-mobile-dark {
177+
background: #131415;
178+
}
179+
180+
.user-logged {
181+
margin: 10px 5px 0 10px;
182+
}
183+
184+
select {
185+
margin: 10px 0;
186+
}
187+
188+
.button-theme {
189+
margin: 10px 10px 0 0;
190+
}
191+
}
192+
193+
.user-logged {
194+
font-size: 12px;
195+
margin-right: 5px;
196+
margin-top: 10px;
197+
198+
&.user-logged-dark {
199+
color: #fff;
151200
}
152201
}
153202
154203
select {
155204
height: 20px;
156205
outline: none;
157206
border: 1px solid #e0e2e4;
207+
border-radius: 4px;
158208
background: #fff;
159209
margin-bottom: 20px;
160210
}
161211
162-
.user-logged {
163-
font-size: 12px;
164-
margin-right: 5px;
165-
}
166-
167212
.button-theme {
168213
float: right;
169214

demo/src/ChatContainer.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
@menu-action-handler="menuActionHandler"
6060
@send-message-reaction="sendMessageReaction"
6161
@typing-message="typingMessage"
62+
@toggle-rooms-list="$emit('show-demo-options', $event.opened)"
6263
>
6364
</chat-window>
6465
</div>
@@ -316,6 +317,8 @@ export default {
316317
},
317318
318319
fetchMessages({ room, options = {} }) {
320+
this.$emit('show-demo-options', false)
321+
319322
if (options.reset) this.resetMessages()
320323
321324
if (this.endMessages && !this.startMessages)
@@ -786,7 +789,7 @@ export default {
786789
787790
.window-mobile {
788791
form {
789-
padding: 10px;
792+
padding: 0 10px 10px;
790793
}
791794
}
792795

0 commit comments

Comments
 (0)