Skip to content

Commit 41021bb

Browse files
committed
docs: add responsive support for the Layout component
1 parent 38c68a2 commit 41021bb

File tree

3 files changed

+137
-20
lines changed

3 files changed

+137
-20
lines changed

docs/.vuepress/theme/Layout.vue

Lines changed: 123 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
@touchend="onTouchEnd"
77
>
88
<router-link :to="$localePath" id="logo"></router-link>
9-
<h1 v-text="$siteTitle"></h1>
9+
<router-link :to="$localePath" v-text="$siteTitle" tag="h1"></router-link>
1010

1111
<Navbar
1212
v-if="shouldShowNavbar"
@@ -85,8 +85,29 @@ export default {
8585
</script>
8686

8787
<style lang="stylus">
88-
@require './styles/button';
89-
@require './styles/config';
88+
@require './styles/button'
89+
@require './styles/config'
90+
91+
body
92+
font 16px/1.42857 PingFang SC, Lantinghei SC, Microsoft Yahei, Hiragino Sans GB, Microsoft Sans Serif, WenQuanYi Micro Hei, sans-serif
93+
background-color #fbfcff
94+
95+
.navbar
96+
transition all 0.3s
97+
border-bottom-color transparent
98+
99+
.home-link
100+
margin-left 5px
101+
padding-right 40px
102+
pointer-events none
103+
visibility hidden
104+
105+
.links
106+
transition all 0.3s
107+
108+
.sidebar
109+
@media (min-width $mq-mobile)
110+
background #fbfcff
90111
91112
.theme-container
92113
.previewer
@@ -97,6 +118,14 @@ export default {
97118
margin-right $s-home-middle-gap
98119
transition all 0.6s cubic-bezier(0.645, 0.045, 0.355, 1)
99120
121+
@media (max-width 1080px)
122+
margin-right ($s-home-middle-gap / 4)
123+
124+
@media (max-width $mq-narrow)
125+
visibility hidden
126+
opacity 0
127+
transform scale(0)
128+
100129
#logo
101130
position absolute
102131
z-index 100
@@ -108,6 +137,14 @@ export default {
108137
height 200px
109138
background url('./assets/images/logo.png') no-repeat center/100%
110139
140+
@media (max-width 1080px)
141+
margin-left 191px + ($s-home-middle-gap / 4)
142+
143+
@media (max-width $mq-narrow)
144+
left 50%
145+
margin-left 0
146+
transform translateX(-50%)
147+
111148
+ h1
112149
position absolute
113150
z-index 100
@@ -116,20 +153,20 @@ export default {
116153
margin-left 164px + $s-home-middle-gap
117154
color $c-basic
118155
font-size 32px
156+
white-space nowrap
157+
158+
@media (max-width 1080px)
159+
margin-left 140px + ($s-home-middle-gap / 4)
160+
161+
@media (max-width $mq-narrow)
162+
left 50%
163+
margin-left 0
164+
transform translateX(-50%)
119165
120166
&,
121167
+ h1
122168
transition all 0.6s cubic-bezier(0.645, 0.045, 0.355, 1)
123169
124-
.navbar
125-
transition all 0.3s
126-
127-
.home-link
128-
display none
129-
130-
.links
131-
transition all 0.3s
132-
133170
.intro-container
134171
position absolute
135172
z-index 10
@@ -139,6 +176,15 @@ export default {
139176
transition all 0.3s
140177
transition-delay 0.6s
141178
179+
@media (max-width 1080px)
180+
margin-left ($s-home-middle-gap / 4)
181+
182+
@media (max-width $mq-narrow)
183+
left 50%
184+
margin-left 0
185+
transform translateX(-50%)
186+
transition-delay 0.3s
187+
142188
.footer
143189
margin-top 700px
144190
padding 15px 0
@@ -151,6 +197,10 @@ export default {
151197
color lighten($c-basic-light, 15%)
152198
font-size 14px
153199
200+
@media (min-width $mq-narrow)
201+
.page
202+
margin-right $s-preview-width + $s-edge-gap
203+
154204
&:not(.doc-mode)
155205
.navbar
156206
background transparent
@@ -159,35 +209,88 @@ export default {
159209
opacity 0
160210
visibility hidden
161211
transform translateY(10px)
212+
213+
.page,
214+
.sidebar
215+
visibility hidden
216+
opacity 0
217+
162218
&.doc-mode
219+
.navbar,
220+
.navbar .links,
221+
#logo,
222+
#logo +h1,
223+
.previewer
224+
transition-delay 0.3s
225+
226+
@media (max-width $mq-narrow)
227+
#logo,
228+
#logo +h1
229+
transition-delay 0s
230+
231+
.sidebar,
232+
.page
233+
transition all 0.3s
234+
transition-delay 0.6s
235+
236+
.navbar
237+
box-shadow 0 0 8px rgba($c-basic, 0.15)
238+
163239
#logo
164-
top 5px
240+
position fixed
241+
top 6px
165242
left $s-edge-gap
166243
margin-left 0
167-
width 50px
168-
height 50px
169-
transition-delay 0.3s
244+
width 46px
245+
height 46px
246+
247+
@media (max-width $mq-narrow)
248+
top 9px
249+
width 40px
250+
height 40px
251+
transform none
252+
@media (max-width $mq-mobile)
253+
opacity 0
254+
visibility hidden
170255
171256
+ h1
172-
top 2px
257+
position fixed
258+
top 3px
173259
left $s-edge-gap + 60
174260
margin 12px 0 0
175-
font-size 24px
176-
transition-delay 0.3s
261+
font-size 22px
262+
263+
@media (max-width $mq-narrow)
264+
top 6px
265+
left $s-edge-gap + 50
266+
font-size 18px
267+
transform none
268+
269+
@media (max-width $mq-mobile)
270+
left $s-edge-gap + 40
177271
178272
.previewer
179273
position fixed
180274
right $s-edge-gap
181275
margin-right 0
182-
transition-delay 0.3s
183276
184277
.intro-container
185278
opacity 0
186279
visibility hidden
187280
transform translateY(30px)
188281
transition-delay 0s
189282
283+
@media (max-width $mq-narrow)
284+
transform translate(-50%, 30px)
285+
190286
.footer
191287
opacity 0
192288
visibility hidden
289+
290+
&.no-sidebar
291+
.sidebar
292+
@media (min-width $mq-mobile + 1)
293+
display block
294+
visibility hidden
295+
pointer-events none
193296
</style>

docs/.vuepress/theme/components/Intro.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
width 640px
3333
text-align center
3434
35+
@media (max-width 1080px)
36+
width 590px
37+
3538
> p
3639
margin 0 0 40px
3740
color $c-basic-light
@@ -48,6 +51,7 @@
4851
li
4952
flex 1
5053
color $c-basic-light
54+
line-height 1.42857
5155
word-break break-all
5256
5357
&:not(:last-child)
@@ -76,4 +80,5 @@
7680
h3
7781
margin 0 0 5px
7882
color $c-basic
83+
font-size 1.1rem
7984
</style>

docs/.vuepress/theme/styles/config.styl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,12 @@ $s-edge-gap = 30px;
1515
$s-header-height = 62px;
1616
$s-sidebar-width = 200px;
1717
$s-preview-width = 334px;
18+
19+
/**
20+
* responsive breakpoints
21+
* @note keep inline with https://github.com/vuejs/vuepress/blob/master/packages/%40vuepress/core/lib/app/style/config.styl
22+
*/
23+
24+
$mq-narrow = 959px
25+
$mq-mobile = 719px
26+
$mq-mobile-narrow = 419px

0 commit comments

Comments
 (0)