Skip to content

Commit c6c71af

Browse files
ulivzyyx990803
authored andcommitted
feat(sidebar): support click the part outside sidebar to close the sidebar. (#132)
1 parent fd447ae commit c6c71af

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

lib/default-theme/Layout.vue

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
@touchstart="onTouchStart"
55
@touchend="onTouchEnd">
66
<Navbar v-if="shouldShowNavbar" @toggle-sidebar="toggleSidebar"/>
7+
<div class="sidebar-mask" @click="toggleSidebar(false)"></div>
78
<Sidebar :items="sidebarItems" @toggle-sidebar="toggleSidebar"/>
89
<div class="custom-layout" v-if="$page.frontmatter.layout">
910
<component :is="$page.frontmatter.layout"/>

lib/default-theme/styles/theme.styl

+19-5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ body
2929
box-sizing border-box
3030
border-bottom 1px solid $borderColor
3131

32+
.sidebar-mask
33+
position fixed
34+
z-index 9
35+
top 0
36+
left 0
37+
width 100vw
38+
height 100vh
39+
display none
40+
3241
.sidebar
3342
font-size 15px
3443
background-color #fff
@@ -153,11 +162,16 @@ th, td
153162
.custom-layout
154163
padding-top $navbarHeight
155164

156-
.theme-container.no-navbar
157-
.content:not(.custom)
158-
h1, h2, h3, h4, h5, h6
159-
margin-top 1.5rem
160-
padding-top 0
165+
.theme-container
166+
&.sidebar-open
167+
.sidebar-mask
168+
display: block
169+
&.no-navbar
170+
.content:not(.custom)
171+
h1, h2, h3, h4, h5, h6
172+
margin-top 1.5rem
173+
padding-top 0
174+
161175

162176
@media (min-width: ($MQMobile + 1px))
163177
.theme-container.no-sidebar

0 commit comments

Comments
 (0)