File tree 8 files changed +112
-32
lines changed
src/client/theme-default/components
8 files changed +112
-32
lines changed Original file line number Diff line number Diff line change 1
- import { computed } from 'vue'
2
1
import { withBase } from '../utils'
3
- import { useSiteDataByRoute } from 'vitepress'
4
- import NavBarLink from './NavBarLink.vue'
5
- import NavDropdownLink from './NavDropdownLink.vue'
2
+ import NavBarLinks from './NavBarLinks.vue'
6
3
7
4
export default {
8
5
components : {
9
- NavBarLink,
10
- NavDropdownLink
6
+ NavBarLinks
11
7
} ,
12
8
13
9
setup ( ) {
14
10
return {
15
- withBase,
16
- navData :
17
- process . env . NODE_ENV === 'production'
18
- ? // navbar items do not change in production
19
- useSiteDataByRoute ( ) . value . themeConfig . nav
20
- : // use computed in dev for hot reload
21
- computed ( ( ) => useSiteDataByRoute ( ) . value . themeConfig . nav )
11
+ withBase
22
12
}
23
13
}
24
14
}
Original file line number Diff line number Diff line change 12
12
/>
13
13
<span >{{ $site.title }}</span >
14
14
</a >
15
- <nav class =" nav-links" v-if =" navData" >
16
- <template v-for =" item of navData " >
17
- <NavDropdownLink v-if =' item.items' :item =" item" />
18
- <NavBarLink v-else :item =" item" />
19
- </template >
20
- </nav >
15
+ <NavBarLinks class =" hide-mobile" />
21
16
</template >
22
17
23
18
<script src="./NavBar"></script >
35
30
vertical-align : bottom ;
36
31
}
37
32
38
- .nav-links {
39
- display : flex ;
40
- align-items : center ;
41
- height : 35px ;
42
- list-style-type : none ;
43
- transform : translateY (1px );
44
- }
45
-
46
33
@media screen and (max-width : 719px ) {
47
- .nav-links {
34
+ .hide-mobile {
48
35
display : none ;
49
36
}
50
37
}
Original file line number Diff line number Diff line change 25
25
}
26
26
27
27
.nav-link {
28
- display : inline- block ;
28
+ display : block ;
29
29
margin-bottom : -2px ;
30
30
border-bottom : 2px solid transparent ;
31
31
font-size : 0.9rem ;
43
43
.nav-link.external :hover {
44
44
border-bottom-color : transparent ;
45
45
}
46
+
47
+ @media screen and (max-width : 719px ) {
48
+ .nav-item {
49
+ margin-left : 0 ;
50
+ padding : 0.35rem 1.5rem 0.35rem 1.25rem ;
51
+ }
52
+
53
+ .nav-link {
54
+ line-height : 1.7 ;
55
+ font-size : 1em ;
56
+ font-weight : 600 ;
57
+ border-bottom : none ;
58
+ margin-bottom : 0 ;
59
+ }
60
+ .nav-link :hover ,
61
+ .nav-link.active {
62
+ color : var (--accent-color );
63
+ }
64
+ }
46
65
</style >
Original file line number Diff line number Diff line change
1
+ import { computed } from 'vue'
2
+ import { useSiteDataByRoute } from 'vitepress'
3
+ import NavBarLink from './NavBarLink.vue'
4
+ import NavDropdownLink from './NavDropdownLink.vue'
5
+
6
+ export default {
7
+ components : {
8
+ NavBarLink,
9
+ NavDropdownLink
10
+ } ,
11
+
12
+ setup ( ) {
13
+ return {
14
+ navData :
15
+ process . env . NODE_ENV === 'production'
16
+ ? // navbar items do not change in production
17
+ useSiteDataByRoute ( ) . value . themeConfig . nav
18
+ : // use computed in dev for hot reload
19
+ computed ( ( ) => useSiteDataByRoute ( ) . value . themeConfig . nav )
20
+ }
21
+ }
22
+ }
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <nav class =" nav-links" v-if =" navData" >
3
+ <template v-for =" item of navData " >
4
+ <NavDropdownLink v-if =' item.items' :item =" item" />
5
+ <NavBarLink v-else :item =" item" />
6
+ </template >
7
+ </nav >
8
+ </template >
9
+
10
+ <script src="./NavBarLinks"></script >
11
+
12
+ <style >
13
+ .nav-links {
14
+ display : flex ;
15
+ align-items : center ;
16
+ height : 35px ;
17
+ list-style-type : none ;
18
+ transform : translateY (1px );
19
+ }
20
+
21
+ @media screen and (max-width : 719px ) {
22
+ .nav-links {
23
+ display : block ;
24
+ height : auto ;
25
+ padding-bottom : 0.5rem ;
26
+ border-bottom : 1px solid var (--border-color );
27
+ }
28
+ }
29
+ </style >
Original file line number Diff line number Diff line change 10
10
<span class =" arrow" :class =" open ? 'down' : 'right'" />
11
11
</button >
12
12
13
- <ul v-show = " open " class =" nav-dropdown" >
13
+ <ul class =" nav-dropdown" >
14
14
<li v-for =" (subItem, index) in item.items" :key =" subItem.link || index" class =" dropdown-item" >
15
15
<h4 v-if =" subItem.items" >{{ subItem.text }}</h4 >
16
16
<ul v-if =" subItem.items" class =" dropdown-subitem-wrapper" >
46
46
.dropdown-wrapper {
47
47
position : relative ;
48
48
cursor : pointer ;
49
- display : inline- block ;
49
+ display : block ;
50
50
margin-left : 1.5rem ;
51
51
}
52
52
.dropdown-wrapper .dropdown-title {
129
129
}
130
130
.dropdown-wrapper :hover .nav-dropdown ,
131
131
.dropdown-wrapper.open .nav-dropdown {
132
- display : block !important ;
132
+ display : block ;
133
133
}
134
134
.dropdown-wrapper.open :blur {
135
135
display : none ;
158
158
white-space : nowrap ;
159
159
margin : 0 ;
160
160
}
161
+
162
+ @media screen and (max-width : 719px ) {
163
+ .dropdown-wrapper {
164
+ height : auto ;
165
+ margin-left : 1.25rem ;
166
+ }
167
+
168
+ .dropdown-wrapper .nav-dropdown {
169
+ position : relative ;
170
+ top : none ;
171
+ right : none ;
172
+ border : none ;
173
+ background-color : transparent ;
174
+ }
175
+ .dropdown-wrapper :hover .nav-dropdown {
176
+ display : none ;
177
+ }
178
+ .dropdown-wrapper.open .nav-dropdown {
179
+ display : block ;
180
+ }
181
+ }
161
182
</style >
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import { Header } from '../../../../types/shared'
9
9
import { isActive , joinUrl , getPathDirName } from '../utils'
10
10
import { DefaultTheme } from '../config'
11
11
import { useActiveSidebarLinks } from '../composables/activeSidebarLink'
12
+ import NavBarLinks from './NavBarLinks.vue'
12
13
13
14
const SideBarItem : FunctionalComponent < {
14
15
item : ResolvedSidebarItem
@@ -33,6 +34,7 @@ const SideBarItem: FunctionalComponent<{
33
34
34
35
export default {
35
36
components : {
37
+ NavBarLinks,
36
38
SideBarItem
37
39
} ,
38
40
Original file line number Diff line number Diff line change 1
1
<template >
2
+ <NavBarLinks class =" show-mobile" />
2
3
<ul class =" sidebar" >
3
4
<SideBarItem v-for =" item of items" :item =" item" />
4
5
</ul >
7
8
<script src="./SideBar"></script >
8
9
9
10
<style >
11
+ .show-mobile {
12
+ display : none ;
13
+ }
14
+ @media screen and (max-width : 719px ) {
15
+ .show-mobile {
16
+ display : block ;
17
+ }
18
+ }
19
+
10
20
.sidebar ,
11
21
.sidebar-items {
12
22
list-style-type : none ;
You can’t perform that action at this time.
0 commit comments