7
7
@mouseup =" stopDragging"
8
8
@mouseleave =" stopDragging"
9
9
>
10
- <div class =" left" :style =" { width: getWidth() + '%' }" >
10
+ <div
11
+ class =" left"
12
+ :class =" { open: clicked }"
13
+ :style =" { width: getWidth() + '%' }"
14
+ >
11
15
<slot name =" left" />
12
16
<div class =" split-line" @mousedown.prevent =" startDragging" />
13
17
</div >
14
18
<div class =" right" :style =" { width: 100 - getWidth() + '%' }" >
15
19
<slot name =" right" />
16
20
</div >
17
21
</div >
22
+ <div class =" sidebar" @click =" openSideBar" >
23
+ <div class =" icon" >
24
+ <svg
25
+ xmlns =" http://www.w3.org/2000/svg"
26
+ xmlns:xlink =" http://www.w3.org/1999/xlink"
27
+ aria-hidden =" true"
28
+ role =" img"
29
+ class =" iconify iconify--mdi"
30
+ width =" 2rem"
31
+ height =" 2rem"
32
+ preserveAspectRatio =" xMidYMid meet"
33
+ viewBox =" 0 0 24 24"
34
+ >
35
+ <path
36
+ d =" M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2z"
37
+ fill =" currentColor"
38
+ ></path >
39
+ </svg >
40
+ </div >
41
+ </div >
18
42
</template >
19
43
20
44
<script >
@@ -25,9 +49,13 @@ export default {
25
49
setup () {
26
50
const width = ref (45 )
27
51
const isDragging = ref (false )
52
+ const clicked = ref (false )
28
53
const container = ref ()
29
54
30
55
// functions
56
+ const openSideBar = () => {
57
+ clicked .value = ! clicked .value
58
+ }
31
59
const getWidth = () => {
32
60
return width .value < 20 ? 20 : width .value > 80 ? 80 : width .value
33
61
}
@@ -46,6 +74,8 @@ export default {
46
74
}
47
75
return {
48
76
width,
77
+ clicked,
78
+ openSideBar,
49
79
isDragging,
50
80
container,
51
81
getWidth,
@@ -84,6 +114,9 @@ export default {
84
114
width : 10px ;
85
115
cursor : ew-resize ;
86
116
}
117
+ .sidebar {
118
+ display : none ;
119
+ }
87
120
/* media queries */
88
121
@media (max-width : 768px ) {
89
122
.split-pane {
@@ -92,9 +125,45 @@ export default {
92
125
.left ,
93
126
.right {
94
127
width : 100% !important ;
128
+ padding-top : 0.5rem ;
129
+ margin-top : 51px ;
130
+ border : 0 ;
95
131
}
96
132
.split-line {
97
133
display : none ;
98
134
}
135
+ .sidebar {
136
+ position : absolute ;
137
+ display : block ;
138
+ }
139
+ .sidebar .icon {
140
+ cursor : pointer ;
141
+ display : block ;
142
+ position : fixed ;
143
+ right : 1rem ;
144
+ bottom : 1rem ;
145
+ color : var (--c-brand-red );
146
+ background-color : var (--c-white-light );
147
+ box-shadow : 0 0 5px rgba (0 , 0 , 0 , 0.8 );
148
+ border-radius : 2px ;
149
+ width : 2rem ;
150
+ height : 2rem ;
151
+ z-index : 99999 ;
152
+ }
153
+ .left {
154
+ position : fixed ;
155
+ transform : translateX (-100% );
156
+ transition : transform 0.25s ease-in ;
157
+ z-index : 10 ;
158
+ background-color : var (--c-white );
159
+ top : 0 ;
160
+ bottom : 0 ;
161
+ overflow : auto ;
162
+ height : auto ;
163
+ }
164
+ .left.open {
165
+ transform : translateX (0 );
166
+ transition : transform 0.35s ease-out ;
167
+ }
99
168
}
100
169
</style >
0 commit comments