Skip to content

Commit b238b16

Browse files
committed
feat: add sidebar for left pane for mobile (#108)
* feat: add sidebar for left pane on mobile * feat: add box shadow for white bg
1 parent eb7a6b1 commit b238b16

File tree

4 files changed

+78
-2
lines changed

4 files changed

+78
-2
lines changed

src/App.vue

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ body {
8080
.tab {
8181
--left-pane-margin-x: 1.5rem;
8282
margin: 0 var(--left-pane-margin-x);
83+
padding-bottom: 2rem;
8384
}
8485
/* overriding prismjs defaults */
8586
pre,

src/components/NavBar.vue

+6
Original file line numberDiff line numberDiff line change
@@ -135,5 +135,11 @@ h1 img {
135135
.version {
136136
display: none;
137137
}
138+
.nav-bar {
139+
position: fixed;
140+
z-index: 11;
141+
width: 100%;
142+
background-color: var(--c-white);
143+
}
138144
}
139145
</style>

src/components/PaneLeft.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export default {
7777
.left-pane-contexts {
7878
height: 100%;
7979
padding: 0;
80-
margin-bottom: 1rem;
80+
margin-bottom: 2.5rem;
8181
}
8282
}
8383
</style>

src/components/PaneSplit.vue

+70-1
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,38 @@
77
@mouseup="stopDragging"
88
@mouseleave="stopDragging"
99
>
10-
<div class="left" :style="{ width: getWidth() + '%' }">
10+
<div
11+
class="left"
12+
:class="{ open: clicked }"
13+
:style="{ width: getWidth() + '%' }"
14+
>
1115
<slot name="left" />
1216
<div class="split-line" @mousedown.prevent="startDragging" />
1317
</div>
1418
<div class="right" :style="{ width: 100 - getWidth() + '%' }">
1519
<slot name="right" />
1620
</div>
1721
</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>
1842
</template>
1943

2044
<script>
@@ -25,9 +49,13 @@ export default {
2549
setup() {
2650
const width = ref(45)
2751
const isDragging = ref(false)
52+
const clicked = ref(false)
2853
const container = ref()
2954
3055
// functions
56+
const openSideBar = () => {
57+
clicked.value = !clicked.value
58+
}
3159
const getWidth = () => {
3260
return width.value < 20 ? 20 : width.value > 80 ? 80 : width.value
3361
}
@@ -46,6 +74,8 @@ export default {
4674
}
4775
return {
4876
width,
77+
clicked,
78+
openSideBar,
4979
isDragging,
5080
container,
5181
getWidth,
@@ -84,6 +114,9 @@ export default {
84114
width: 10px;
85115
cursor: ew-resize;
86116
}
117+
.sidebar {
118+
display: none;
119+
}
87120
/* media queries */
88121
@media (max-width: 768px) {
89122
.split-pane {
@@ -92,9 +125,45 @@ export default {
92125
.left,
93126
.right {
94127
width: 100% !important;
128+
padding-top: 0.5rem;
129+
margin-top: 51px;
130+
border: 0;
95131
}
96132
.split-line {
97133
display: none;
98134
}
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+
}
99168
}
100169
</style>

0 commit comments

Comments
 (0)