Skip to content

Commit 29bdd95

Browse files
committed
feat($sidebar): support click the part outside sidebar to close the sidebar.
1 parent c4772f4 commit 29bdd95

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

lib/default-theme/Layout.vue

Lines changed: 1 addition & 0 deletions
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

Lines changed: 19 additions & 5 deletions
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
@@ -149,11 +158,16 @@ th, td
149158
.custom-layout
150159
padding-top $navbarHeight
151160

152-
.theme-container.no-navbar
153-
.content:not(.custom)
154-
h1, h2, h3, h4, h5, h6
155-
margin-top 1.5rem
156-
padding-top 0
161+
.theme-container
162+
&.sidebar-open
163+
.sidebar-mask
164+
display: block
165+
&.no-navbar
166+
.content:not(.custom)
167+
h1, h2, h3, h4, h5, h6
168+
margin-top 1.5rem
169+
padding-top 0
170+
157171

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

0 commit comments

Comments
 (0)