Skip to content

Commit ac434d5

Browse files
authored
Update for mobile devices etc (#15)
* Update the home button for external links * Update for mobile devices
1 parent 3f8c299 commit ac434d5

File tree

6 files changed

+181
-112
lines changed

6 files changed

+181
-112
lines changed

β€ŽHome.vueβ€Ž

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@ export default {
4343
action() {
4444
return {
4545
text: this.data.actionText,
46-
link: localizePath(this.data.actionLink, this.$localePath),
46+
link:
47+
this.data.actionLink.indexOf('http') == -1
48+
? localizePath(this.data.actionLink, this.$localePath)
49+
: this.data.actionLink,
4750
}
4851
},
4952
footer() {
5053
const defaultFooter =
5154
'Open Source on [GitHub](https://github.com/sqrthree/vuepress-theme-api), Made by [@sqrthree](https://github.com/sqrthree), Power by [vuepress](https://github.com/vuejs/vuepress).'
52-
5355
return md.render(this.data.footer || defaultFooter)
5456
},
5557
},
@@ -60,7 +62,6 @@ export default {
6062
@import './styles/_variables.styl'
6163
6264
.home
63-
6465
&__header
6566
margin: 10rem 0
6667
text-align: center
@@ -82,8 +83,10 @@ export default {
8283
&__content
8384
padding: 6rem 4rem
8485
border-top: 1px solid $divider-color
85-
86+
8687
&__footer
87-
margin: 2rem 0
88+
margin-bottom: 3rem
89+
margin-left: 4rem
90+
margin-right: 4rem
8891
text-align: center
8992
</style>

β€ŽLayout.vueβ€Ž

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
<template>
22
<div class="theme__container" :class="pageClasses">
3+
<div class="menu__container">
4+
<a v-on:click="openMenu()" v-show="shouldShowSidebar">
5+
<img src="./src/menu.png" v-show="shouldContentSeen" />
6+
<img src="./src/close.png" v-show="shouldMenuOpen" />
7+
</a>
8+
</div>
39
<div class="row" v-if="shouldShowSidebar">
4-
<div class="col-md-2">
10+
<div class="col-md-3 col-lg-2 sidebar__container" v-show="shouldMenuOpen">
511
<Sidebar :items="sidebarItems">
612
<slot name="sidebar-top" slot="top" />
713
<slot name="sidebar-bottom" slot="bottom" />
814
</Sidebar>
915
</div>
10-
<div class="col-md-10">
16+
<div
17+
class="col-md-9 col-lg-10 content__container"
18+
v-show="shouldContentSeen"
19+
>
1120
<div class="custom__layout" v-if="$page.frontmatter.layout">
1221
<component :is="$page.frontmatter.layout" />
1322
</div>
@@ -44,8 +53,23 @@ export default {
4453
data() {
4554
return {
4655
isSidebarOpen: true,
56+
shouldMenuOpen: false,
57+
shouldContentSeen: true,
4758
}
4859
},
60+
methods: {
61+
openMenu: function() {
62+
this.shouldMenuOpen
63+
? (this.shouldMenuOpen = false)
64+
: (this.shouldMenuOpen = true)
65+
this.shouldContentSeen
66+
? (this.shouldContentSeen = false)
67+
: (this.shouldContentSeen = true)
68+
this.isSidebarOpen
69+
? (this.isSidebarOpen = false)
70+
: (this.isSidebarOpen = true)
71+
},
72+
},
4973
computed: {
5074
sidebarItems() {
5175
return resolveSidebarItems(this.$page, this.$site, this.$localePath)
@@ -87,6 +111,13 @@ export default {
87111
nprogress.done()
88112
})
89113
},
114+
watch: {
115+
$route: function() {
116+
this.isSidebarOpen = false
117+
this.shouldMenuOpen = false
118+
this.shouldContentSeen = true
119+
},
120+
},
90121
created() {
91122
if (this.$ssrContext) {
92123
this.$ssrContext.title = this.$title
@@ -99,3 +130,31 @@ export default {
99130

100131
<style src="prismjs/themes/prism-tomorrow.css"></style>
101132
<style src="./styles/theme.styl" lang="stylus"></style>
133+
<style lang="stylus">
134+
@import './styles/_variables.styl'
135+
136+
@media screen and (max-width: $container-max-widths.md)
137+
img
138+
width: 100%
139+
height: 100%
140+
141+
.menu__container
142+
display: block
143+
position: sticky
144+
padding: 2rem 2rem 0
145+
text-align: right
146+
147+
img
148+
width: 30px
149+
150+
@media screen and (min-width: $container-max-widths.md)
151+
img
152+
width: 50%
153+
height: 50%
154+
155+
.menu__container
156+
display: none
157+
158+
.content__container, .sidebar__container
159+
display: block !important
160+
</style>

β€ŽPage.vueβ€Ž

Lines changed: 110 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
<div class="content__footer-container">
55
<div class="content__footer">
66
<div v-if="editLink" class="edit-link">
7-
<a :href="editLink" target="_blank" rel="noopener noreferrer">
8-
{{ editLinkText }}
9-
</a>
7+
<a :href="editLink" target="_blank" rel="noopener noreferrer">{{
8+
editLinkText
9+
}}</a>
1010
<svg
1111
viewBox="0 0 33 32"
1212
version="1.1"
@@ -186,109 +186,114 @@ export default {
186186
</script>
187187

188188
<style lang="stylus">
189-
@import './styles/_variables.styl';
190-
191-
.page__container {
192-
min-height: 100vh;
193-
padding: 4rem 6rem 0;
194-
195-
.curl__container {
196-
text-align: center;
197-
}
198-
}
199-
200-
.content__footer {
201-
display: flex;
202-
justify-content: space-between;
203-
padding: 2em 0;
204-
font-size: 14px;
205-
color: #999;
206-
207-
.edit-link {
208-
a {
209-
margin-right: 0.5em;
210-
font-weight: 600;
211-
color: #000;
212-
}
213-
214-
svg {
215-
vertical-align: middle;
216-
}
217-
}
218-
}
219-
220-
.page--block-layout {
221-
.content__footer-container {
222-
margin: 0 -3rem;
223-
background-color: #000;
224-
}
225-
226-
.content__footer {
227-
width: 50%;
228-
padding: 0 3rem 2rem;
229-
background-color: #fafafa;
230-
}
231-
}
232-
233-
.content-block {
234-
margin: -4rem -6rem 4rem;
235-
background-color: $black;
236-
237-
&:last-child {
238-
margin-bottom: 0;
239-
}
240-
241-
&:after {
242-
height: 1px;
243-
display: block;
244-
content: '';
245-
width: 100%;
246-
background-image: linear-gradient(90deg, #eaeaea 50%, #333 50%);
247-
}
248-
249-
&:last-child:after {
250-
display: none;
251-
}
252-
253-
&__heading {
254-
width: 50%;
255-
padding: 4rem 3rem 0;
256-
overflow: auto;
257-
background-color: #fafafa;
258-
}
259-
260-
&__body {
261-
display: flex;
262-
}
263-
264-
&__cont, &__examples {
265-
width: 50%;
266-
padding: 0 3rem 2rem;
267-
}
268-
269-
&__cont {
270-
background-color: #fafafa;
271-
}
272-
273-
&__examples {
274-
color: $white;
275-
276-
.btn {
277-
margin: 2em 0;
278-
}
279-
280-
p {
281-
font-size: 12px;
282-
}
189+
@import './styles/_variables.styl'
190+
191+
.page__container
192+
min-height: 100vh
193+
padding: 4rem 6rem 0
194+
195+
.curl__container
196+
text-align: center
197+
198+
@media screen and (max-width: $container-max-widths.md)
199+
padding: 2rem 2rem 0
200+
201+
.content-block__heading, .content-block__cont, .content-block
202+
width: 100%
203+
padding: 1rem 0 0 0
204+
margin: 0
205+
background-color: $white
206+
207+
.content-block__examples
208+
padding: 0
209+
margin: 0
210+
width: 100%
211+
212+
.examples
213+
width: 100%
214+
padding: 1rem
215+
background-color: $black
216+
border-radius: 6px
217+
218+
.content-block__body
219+
flex-direction: column
220+
221+
.content-block::after
222+
background-image: none
223+
224+
.content__footer
225+
display: flex
226+
justify-content: space-between
227+
padding: 2em 0
228+
font-size: 14px
229+
color: #999
230+
231+
.edit-link
232+
a
233+
margin-right: 0.5em
234+
font-weight: 600
235+
color: #000
236+
237+
svg
238+
vertical-align: middle
239+
240+
.page--block-layout
241+
.content__footer-container
242+
margin: 0 -3rem
243+
background-color: #000
244+
245+
.content__footer
246+
width: 50%
247+
padding: 0 3rem 2rem
248+
background-color: #fafafa
249+
250+
.content-block
251+
margin: -4rem -6rem 4rem
252+
background-color: $black
253+
254+
&:last-child
255+
margin-bottom: 0
256+
257+
&:after
258+
height: 1px
259+
display: block
260+
content: ''
261+
width: 100%
262+
background-image: linear-gradient(90deg, #eaeaea 50%, #333 50%)
263+
264+
&:last-child:after
265+
display: none
266+
267+
&__heading
268+
width: 50%
269+
padding: 4rem 3rem 0
270+
overflow: auto
271+
background-color: #fafafa
272+
273+
&__body
274+
display: flex
275+
overflow-x: hidden
276+
277+
&__cont, &__examples
278+
width: 50%
279+
padding: 0 3rem 2rem
280+
281+
&__cont
282+
background-color: #fafafa
283+
284+
&__examples
285+
color: $white
286+
287+
.btn
288+
margin: 2em 0
289+
290+
p
291+
font-size: 12px
283292
284293
// reset style
285-
blockquote {
286-
border-left-color: $white;
294+
blockquote
295+
border-left-color: $white
287296
288-
p {
289-
color: #888;
290-
}
291-
}
292-
}
293-
}
297+
p
298+
color: #888
294299
</style>

β€Žcomponents/Sidebar/index.vueβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ export default {
150150
padding-top: 3rem
151151
overflow: auto
152152
background: $white
153+
@media screen and (max-width: $container-max-widths.md)
154+
position: relative
153155
154156
.group
155157
margin-bottom: 4rem

β€Žsrc/close.pngβ€Ž

2.75 KB
Loading

β€Žsrc/menu.pngβ€Ž

993 Bytes
Loading

0 commit comments

Comments
Β (0)