feat: close the sidebar when clicking outside of the sidebar (#78)

pull/80/head
Yugo Ogura 4 years ago committed by GitHub
parent c437a4791e
commit e93ee094ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -7,6 +7,7 @@
<aside :class="{ open }">
<SideBar/>
</aside>
<div class="sidebar-mask" :class="{ 'sidebar-open': open }" @click="toggleSidebar(false)" />
<main>
<Page />
</main>
@ -31,12 +32,12 @@ export default {
},
setup() {
let open = ref(false)
const toggleSidebar = () => {
open.value = !open.value
const toggleSidebar = (to) => {
open.value = typeof to === 'boolean' ? to : !open.value
}
return {
open,
toggleSidebar
toggleSidebar,
}
}
}

@ -59,6 +59,17 @@ aside {
}
}
.sidebar-mask {
z-index: 2;
position: fixed;
width: 100vw;
height: 100vh;
display: none;
}
.sidebar-mask.sidebar-open{
display: block;
}
main {
margin-top: var(--header-height);
margin-left: var(--sidebar-width);

Loading…
Cancel
Save