forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMiniSlot.vue
More file actions
131 lines (114 loc) · 3.48 KB
/
MiniSlot.vue
File metadata and controls
131 lines (114 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<template>
<div class="q-pa-md">
<q-layout view="hHh Lpr lff" container style="height: 300px" class="shadow-2 rounded-borders">
<q-header elevated class="bg-black">
<q-toolbar>
<q-btn flat @click="drawer = !drawer" round dense icon="menu" />
<q-toolbar-title>Header</q-toolbar-title>
</q-toolbar>
</q-header>
<q-drawer
v-model="drawer"
show-if-above
:mini="!drawer || miniState"
@click.capture="drawerClick"
:width="200"
:breakpoint="500"
bordered
class="bg-grey-3"
>
<template v-slot:mini>
<q-scroll-area class="fit mini-slot cursor-pointer">
<div class="q-py-lg">
<div class="column items-center">
<q-icon name="inbox" color="blue" class="mini-icon" />
<q-icon name="star" color="orange" class="mini-icon" />
<q-icon name="send" color="purple" class="mini-icon" />
<q-icon name="drafts" color="teal" class="mini-icon" />
</div>
</div>
</q-scroll-area>
</template>
<q-scroll-area class="fit">
<q-list padding>
<q-item clickable v-ripple>
<q-item-section>
Inbox
</q-item-section>
</q-item>
<q-item active clickable v-ripple>
<q-item-section>
Star
</q-item-section>
</q-item>
<q-item clickable v-ripple>
<q-item-section>
Send
</q-item-section>
</q-item>
<q-item clickable v-ripple>
<q-item-section>
Drafts
</q-item-section>
</q-item>
</q-list>
</q-scroll-area>
<!--
in this case, we use a button (can be anything)
so that user can switch back
to mini-mode
-->
<div class="q-mini-drawer-hide absolute" style="top: 15px; right: -17px">
<q-btn
dense
round
unelevated
color="accent"
icon="chevron_left"
@click="miniState = true"
/>
</div>
</q-drawer>
<q-page-container>
<q-page class="q-px-lg q-py-md">
<p v-for="n in 15" :key="n">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Fugit nihil praesentium molestias a adipisci, dolore vitae odit, quidem consequatur optio voluptates asperiores pariatur eos numquam rerum delectus commodi perferendis voluptate?
</p>
</q-page>
</q-page-container>
</q-layout>
</div>
</template>
<script>
import { ref } from 'vue'
export default {
setup () {
const miniState = ref(true)
return {
drawer: ref(false),
miniState,
drawerClick (e) {
// if in "mini" state and user
// click on drawer, we switch it to "normal" mode
if (miniState.value) {
miniState.value = false
// notice we have registered an event with capture flag;
// we need to stop further propagation as this click is
// intended for switching drawer to "normal" mode only
e.stopPropagation()
}
}
}
}
}
</script>
<style lang="sass" scoped>
.mini-slot
transition: background-color .28s
&:hover
background-color: rgba(0, 0, 0, .04)
.mini-icon
font-size: 1.718em
& + &
margin-top: 18px
</style>