Skip to content

Commit

Permalink
feat: close the sidebar when clicking outside of the sidebar (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
Spice-Z authored Sep 5, 2020
1 parent c437a47 commit e93ee09
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/client/theme-default/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<aside :class="{ open }">
<SideBar/>
</aside>
<div class="sidebar-mask" :class="{ 'sidebar-open': open }" @click="toggleSidebar(false)" />
<main>
<Page />
</main>
Expand All @@ -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,
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/client/theme-default/styles/layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e93ee09

Please sign in to comment.