2
2
<header class =" navbar" >
3
3
<SidebarButton @toggle-sidebar =" $emit('toggle-sidebar')" />
4
4
5
- <RouterLink
6
- :to =" $localePath"
7
- class =" home-link"
8
- >
5
+ <RouterLink :to =" $localePath" class =" home-link" >
9
6
<img
10
7
v-if =" $site.themeConfig.logo"
11
8
class =" logo"
12
9
:src =" $withBase($site.themeConfig.logo)"
13
10
:alt =" $siteTitle"
14
- >
11
+ / >
15
12
<span
16
13
v-if =" $siteTitle"
17
14
ref =" siteName"
26
23
'max-width': linksWrapMaxWidth + 'px'
27
24
} : {}"
28
25
>
29
- <AlgoliaSearchBox
30
- v-if = " isAlgoliaSearch "
31
- :options = " algolia "
26
+ <AlgoliaSearchBox v-if = " isAlgoliaSearch " :options = " algolia " />
27
+ < SearchBox
28
+ v-else-if = " $site.themeConfig.search !== false && $page.frontmatter.search !== false "
32
29
/>
33
- <SearchBox v-else-if =" $site.themeConfig.search !== false && $page.frontmatter.search !== false" />
34
30
<NavLinks class =" can-hide" />
35
31
</div >
36
32
</header >
@@ -52,39 +48,45 @@ export default {
52
48
AlgoliaSearchBox
53
49
},
54
50
55
- data () {
51
+ data () {
56
52
return {
57
53
linksWrapMaxWidth: null
58
54
}
59
55
},
60
56
61
57
computed: {
62
- algolia () {
63
- return this .$themeLocaleConfig .algolia || this .$site .themeConfig .algolia || {}
58
+ algolia () {
59
+ return (
60
+ this .$themeLocaleConfig .algolia || this .$site .themeConfig .algolia || {}
61
+ )
64
62
},
65
63
66
- isAlgoliaSearch () {
64
+ isAlgoliaSearch () {
67
65
return this .algolia && this .algolia .apiKey && this .algolia .indexName
68
66
}
69
67
},
70
68
71
- mounted () {
69
+ mounted () {
72
70
const MOBILE_DESKTOP_BREAKPOINT = 719 // refer to config.styl
73
- const NAVBAR_VERTICAL_PADDING = parseInt (css (this .$el , ' paddingLeft' )) + parseInt (css (this .$el , ' paddingRight' ))
71
+ const NAVBAR_VERTICAL_PADDING =
72
+ parseInt (css (this .$el , ' paddingLeft' )) +
73
+ parseInt (css (this .$el , ' paddingRight' ))
74
74
const handleLinksWrapWidth = () => {
75
75
if (document .documentElement .clientWidth < MOBILE_DESKTOP_BREAKPOINT ) {
76
76
this .linksWrapMaxWidth = null
77
77
} else {
78
- this .linksWrapMaxWidth = this .$el .offsetWidth - NAVBAR_VERTICAL_PADDING
79
- - (this .$refs .siteName && this .$refs .siteName .offsetWidth || 0 )
78
+ this .linksWrapMaxWidth =
79
+ this .$el .offsetWidth -
80
+ NAVBAR_VERTICAL_PADDING -
81
+ ((this .$refs .siteName && this .$refs .siteName .offsetWidth ) || 0 )
80
82
}
81
83
}
82
84
handleLinksWrapWidth ()
83
85
window .addEventListener (' resize' , handleLinksWrapWidth, false )
84
86
}
85
87
}
86
88
87
- function css (el , property ) {
89
+ function css (el , property ) {
88
90
// NOTE: Known bug, will return 'auto' if style value is 'auto'
89
91
const win = el .ownerDocument .defaultView
90
92
// null means not to return pseudo styles
@@ -93,48 +95,67 @@ function css (el, property) {
93
95
</script >
94
96
95
97
<style lang="stylus">
96
- $navbar-vertical-padding = 0.7rem
97
- $navbar-horizontal-padding = 1.5rem
98
-
99
- .navbar
100
- padding $navbar-vertical-padding $navbar-horizontal-padding
101
- line-height $navbarHeight - 1.4rem
102
- a , span , img
103
- display inline-block
104
- .logo
105
- height $navbarHeight - 1.4rem
106
- min-width $navbarHeight - 1.4rem
107
- margin-right 0.5rem
108
- vertical-align top
109
- .site-name
110
- font-size 1.3rem
111
- font-weight 600
112
- color $textColor
113
- position relative
114
- .links
115
- padding-left 1.5rem
116
- box-sizing border-box
117
- background-color white
118
- white-space nowrap
119
- font-size 0.9rem
120
- position absolute
121
- right $navbar-horizontal-padding
122
- top $navbar-vertical-padding
123
- display flex
124
- .search-box
125
- flex : 0 0 auto
126
- vertical-align top
127
-
128
- @media (max-width : $MQMobile)
129
- .navbar
130
- padding-left 4rem
131
- .can-hide
132
- display none
133
- .links
134
- padding-left 1.5rem
135
- .site-name
136
- width calc (100vw - 9.4rem )
137
- overflow hidden
138
- white-space nowrap
139
- text-overflow ellipsis
98
+ $navbar-vertical-padding = 0.7rem ;
99
+ $navbar-horizontal-padding = 1.5rem ;
100
+
101
+ .navbar {
102
+ padding : $navbar-vertical-padding $navbar-horizontal-padding ;
103
+ line-height : $navbarHeight - 1.4rem ;
104
+
105
+ a , span , img {
106
+ display : inline-block ;
107
+ }
108
+
109
+ .logo {
110
+ height : $navbarHeight - 1.4rem ;
111
+ min-width : $navbarHeight - 1.4rem ;
112
+ margin-right : 0.5rem ;
113
+ vertical-align : top ;
114
+ }
115
+
116
+ .site-name {
117
+ font-size : 1.3rem ;
118
+ font-weight : 500 ;
119
+ color : $textColor ;
120
+ position : relative ;
121
+ }
122
+
123
+ .links {
124
+ padding-left : 1.5rem ;
125
+ box-sizing : border-box ;
126
+ background-color : white ;
127
+ white-space : nowrap ;
128
+ font-size : 0.9rem ;
129
+ position : absolute ;
130
+ right : $navbar-horizontal-padding ;
131
+ top : $navbar-vertical-padding ;
132
+ display : flex ;
133
+
134
+ .search-box {
135
+ flex : 0 0 auto ;
136
+ vertical-align : top ;
137
+ }
138
+ }
139
+ }
140
+
141
+ @media (max-width : $MQMobile) {
142
+ .navbar {
143
+ padding-left : 4rem ;
144
+
145
+ .can-hide {
146
+ display : none ;
147
+ }
148
+
149
+ .links {
150
+ padding-left : 1.5rem ;
151
+ }
152
+
153
+ .site-name {
154
+ width : calc (100vw - 9.4rem );
155
+ overflow : hidden ;
156
+ white-space : nowrap ;
157
+ text-overflow : ellipsis ;
158
+ }
159
+ }
160
+ }
140
161
</style >
0 commit comments