|
1 | 1 | <template> |
2 | | - <div class="col position-relative whatsapp-container bg-grey-4"> |
3 | | - <q-layout view="lHh Lpr lFf" class="shadow-3" container |
4 | | - :style="{ |
5 | | - height: (this.$q.screen.height - (this.$q.screen.gt.md ? 40 : 0)) + 'px', |
6 | | - width: (this.$q.screen.width - (this.$q.screen.gt.md ? 350 : 0)) + 'px', |
7 | | - top: this.$q.screen.gt.md ? '20px' : 0 |
8 | | - }" |
9 | | - > |
| 2 | + <div class="WAL position-relative bg-grey-4"> |
| 3 | + <q-layout view="lHh Lpr lFf" class="WAL__layout shadow-3" container> |
10 | 4 | <q-header elevated> |
11 | 5 | <q-toolbar class="bg-grey-3 text-black"> |
| 6 | + <q-btn |
| 7 | + round |
| 8 | + flat |
| 9 | + icon="keyboard_arrow_left" |
| 10 | + class="WAL__drawer-open q-mr-sm" |
| 11 | + @click="leftDrawerOpen = true" |
| 12 | + /> |
| 13 | + |
12 | 14 | <q-btn round flat> |
13 | 15 | <q-avatar> |
14 | 16 | <img :src="currentConversation.avatar"> |
15 | 17 | </q-avatar> |
16 | 18 | </q-btn> |
| 19 | + |
17 | 20 | <span class="q-subtitle-1 q-pl-md"> |
18 | 21 | {{ currentConversation.person }} |
19 | 22 | </span> |
| 23 | + |
20 | 24 | <q-space/> |
21 | | - <q-btn round flat icon="search"/> |
22 | | - <q-btn round flat icon="attachment" class="rotate-135"/> |
| 25 | + |
| 26 | + <q-btn round flat icon="search" /> |
| 27 | + <q-btn round flat> |
| 28 | + <q-icon name="attachment" class="rotate-135" /> |
| 29 | + </q-btn> |
23 | 30 | <q-btn round flat icon="more_vert"> |
24 | 31 | <q-menu auto-close :offset="[110, 0]"> |
25 | 32 | <q-list style="min-width: 150px"> |
|
49 | 56 |
|
50 | 57 | <q-drawer |
51 | 58 | v-model="leftDrawerOpen" |
52 | | - bordered :breakpoint="0" |
53 | | - :width="350" |
| 59 | + bordered |
| 60 | + show-if-above |
| 61 | + :breakpoint="690" |
54 | 62 | > |
55 | 63 | <q-toolbar class="bg-grey-3"> |
56 | 64 | <q-avatar class="cursor-pointer"> |
57 | 65 | <img src="https://cdn.quasar.dev/app-icons/icon-128x128.png" /> |
58 | 66 | </q-avatar> |
| 67 | + |
59 | 68 | <q-space /> |
| 69 | + |
60 | 70 | <q-btn round flat icon="message" /> |
61 | 71 | <q-btn round flat icon="more_vert"> |
62 | 72 | <q-menu auto-close :offset="[110, 8]"> |
|
82 | 92 | </q-list> |
83 | 93 | </q-menu> |
84 | 94 | </q-btn> |
| 95 | + |
| 96 | + <q-btn |
| 97 | + round |
| 98 | + flat |
| 99 | + icon="close" |
| 100 | + class="WAL__drawer-close" |
| 101 | + @click="leftDrawerOpen = false" |
| 102 | + /> |
85 | 103 | </q-toolbar> |
86 | 104 |
|
87 | 105 | <q-toolbar class="bg-grey-2"> |
88 | | - <q-input rounded outlined dense class="full-width" bg-color="white" v-model="search" placeholder="Search or start a new conversation"> |
| 106 | + <q-input rounded outlined dense class="WAL__field full-width" bg-color="white" v-model="search" placeholder="Search or start a new conversation"> |
89 | 107 | <template slot="prepend"> |
90 | 108 | <q-icon name="search" /> |
91 | 109 | </template> |
|
94 | 112 |
|
95 | 113 | <q-scroll-area style="height: calc(100% - 100px)"> |
96 | 114 | <q-list> |
97 | | - <q-item v-for="(conversation, index) in conversations" :key="conversation.id" clickable ripple @click="currentConversationIndex = index"> |
| 115 | + <q-item |
| 116 | + v-for="(conversation, index) in conversations" |
| 117 | + :key="conversation.id" |
| 118 | + clickable |
| 119 | + v-ripple |
| 120 | + @click="currentConversationIndex = index" |
| 121 | + > |
98 | 122 | <q-item-section avatar> |
99 | 123 | <q-avatar> |
100 | 124 | <img :src="conversation.avatar"> |
101 | | - </q-avatar>{{ }} |
102 | | - </q-item-section>{{ }} |
| 125 | + </q-avatar> |
| 126 | + </q-item-section> |
| 127 | + |
103 | 128 | <q-item-section> |
104 | | - <div class="row justify-between items-center"> |
105 | | - <q-item-label> |
106 | | - {{ conversation.person }} |
107 | | - </q-item-label> |
108 | | - <q-item-label caption> |
109 | | - {{ conversation.time }} |
110 | | - </q-item-label> |
111 | | - </div> |
112 | | - <div class="row justify-between items-center"> |
113 | | - <q-item-label class="conversation__summary" caption> |
114 | | - <q-icon name="check" v-if="conversation.sent"/> |
115 | | - <q-icon name="fas fa-ban" v-if="conversation.deleted"/> |
116 | | - {{ conversation.caption }} |
117 | | - </q-item-label> |
118 | | - <q-item-label class="conversation__more" caption> |
119 | | - <q-icon name="keyboard_arrow_down"/> |
120 | | - </q-item-label> |
121 | | - </div> |
| 129 | + <q-item-label lines="1"> |
| 130 | + {{ conversation.person }} |
| 131 | + </q-item-label> |
| 132 | + <q-item-label class="conversation__summary" caption> |
| 133 | + <q-icon name="check" v-if="conversation.sent" /> |
| 134 | + <q-icon name="fas fa-ban" v-if="conversation.deleted" /> |
| 135 | + {{ conversation.caption }} |
| 136 | + </q-item-label> |
| 137 | + </q-item-section> |
| 138 | + |
| 139 | + <q-item-section side> |
| 140 | + <q-item-label caption> |
| 141 | + {{ conversation.time }} |
| 142 | + </q-item-label> |
| 143 | + <q-icon name="keyboard_arrow_down" /> |
122 | 144 | </q-item-section> |
123 | 145 | </q-item> |
124 | 146 | </q-list> |
125 | 147 | </q-scroll-area> |
126 | 148 | </q-drawer> |
127 | 149 |
|
| 150 | + <q-page-container class="bg-grey-2"> |
| 151 | + <router-view /> |
| 152 | + </q-page-container> |
| 153 | + |
128 | 154 | <q-footer> |
129 | 155 | <q-toolbar class="bg-grey-3 text-black row"> |
130 | | - <q-btn round flat icon="insert_emoticon"/> |
131 | | - <q-input rounded outlined dense class="col-grow" bg-color="white" v-model="message" placeholder="Type a message"/> |
132 | | - <q-btn round flat icon="mic"/> |
| 156 | + <q-btn round flat icon="insert_emoticon" class="q-mr-sm" /> |
| 157 | + <q-input rounded outlined dense class="WAL__field col-grow q-mr-sm" bg-color="white" v-model="message" placeholder="Type a message" /> |
| 158 | + <q-btn round flat icon="mic" /> |
133 | 159 | </q-toolbar> |
134 | 160 | </q-footer> |
135 | | - |
136 | | - <q-page-container class="bg-grey-2"> |
137 | | - <router-view /> |
138 | | - </q-page-container> |
139 | 161 | </q-layout> |
140 | 162 | </div> |
141 | 163 | </template> |
142 | 164 |
|
143 | 165 | <script> |
144 | 166 | export default { |
145 | | - name: 'MyLayout', |
| 167 | + name: 'WhatsappLayout', |
146 | 168 |
|
147 | 169 | data () { |
148 | 170 | return { |
149 | | - leftDrawerOpen: true, |
| 171 | + leftDrawerOpen: false, |
150 | 172 | search: '', |
151 | 173 | message: '', |
152 | 174 | currentConversationIndex: 0, |
@@ -186,34 +208,69 @@ export default { |
186 | 208 | ] |
187 | 209 | } |
188 | 210 | }, |
| 211 | +
|
189 | 212 | computed: { |
190 | 213 | currentConversation () { |
191 | 214 | return this.conversations[this.currentConversationIndex] |
192 | 215 | } |
| 216 | + }, |
| 217 | +
|
| 218 | + watch: { |
| 219 | + leftDrawerOpen (val) { |
| 220 | + // if user opens drawer in mobile mode |
| 221 | + // then widens the window and closes drawer, |
| 222 | + // we should still show drawer on page in standard mode |
| 223 | + if (val === false && this.$q.screen.width >= 690) { |
| 224 | + this.$nextTick(() => { |
| 225 | + this.leftDrawerOpen = true |
| 226 | + }) |
| 227 | + } |
| 228 | + } |
193 | 229 | } |
194 | 230 | } |
195 | 231 | </script> |
196 | 232 |
|
197 | 233 | <style lang="stylus"> |
198 | | -.q-layout-container |
199 | | - margin 0 auto |
200 | | - z-index 4000 |
201 | | -
|
202 | | -.whatsapp-container |
203 | | - height 100vh |
204 | | - &::after |
205 | | - content "" |
| 234 | +.WAL |
| 235 | + width 100% |
| 236 | + height 100% |
| 237 | + padding-top 20px |
| 238 | + padding-bottom 20px |
| 239 | +
|
| 240 | + &:before |
| 241 | + content '' |
206 | 242 | height 127px |
207 | 243 | position fixed |
208 | 244 | top 0 |
209 | 245 | width 100% |
210 | 246 | background-color #009688 |
211 | 247 |
|
212 | | -.q-field--outlined .q-field__control:before |
213 | | - border none |
| 248 | + &__layout |
| 249 | + margin 0 auto |
| 250 | + z-index 4000 |
| 251 | + height 100% |
| 252 | + width 90% |
| 253 | + max-width 950px |
| 254 | + border-radius 5px |
| 255 | +
|
| 256 | + &__field.q-field--outlined .q-field__control:before |
| 257 | + border none |
| 258 | +
|
| 259 | + .q-drawer--standard |
| 260 | + .WAL__drawer-close |
| 261 | + display none |
| 262 | +
|
| 263 | +@media (max-width 850px) |
| 264 | + .WAL |
| 265 | + padding 0 |
| 266 | + &__layout |
| 267 | + width 100% |
| 268 | + border-radius 0 |
214 | 269 |
|
215 | | -.q-icon |
216 | | - opacity .45 |
| 270 | +@media (min-width 691px) |
| 271 | + .WAL |
| 272 | + &__drawer-open |
| 273 | + display none |
217 | 274 |
|
218 | 275 | .conversation__summary |
219 | 276 | margin-top 4px |
|
0 commit comments