Skip to content

Commit 495c583

Browse files
committed
fix stacked page title in mobile sizes
1 parent 1251116 commit 495c583

File tree

4 files changed

+118
-69
lines changed

4 files changed

+118
-69
lines changed

docs/src/App.vue

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@
178178
</md-list-item>
179179
</md-list>
180180
</div>
181+
182+
<release-version></release-version>
181183
</md-sidenav>
182184

183185
<transition name="md-router" appear>
@@ -222,6 +224,7 @@
222224
width: $sizebar-size;
223225
display: flex;
224226
flex-flow: column;
227+
overflow: hidden;
225228
226229
@media (min-width: 1281px) {
227230
top: 0;
@@ -269,6 +272,7 @@
269272
270273
.main-sidebar-links {
271274
overflow: auto;
275+
flex: 1;
272276
273277
.md-inset .md-list-item-container {
274278
padding-left: 36px;
@@ -279,6 +283,24 @@
279283
font-weight: 500;
280284
}
281285
}
286+
287+
.release-version {
288+
padding: 8px 8px 8px 16px;
289+
border-top: 1px solid rgba(#000, .12);
290+
display: none;
291+
292+
@media (max-width: 480px) {
293+
display: block;
294+
}
295+
296+
> div {
297+
justify-content: center;
298+
}
299+
300+
.md-select:after {
301+
color: rgba(#000, .87);
302+
}
303+
}
282304
}
283305
284306
.main-content {

docs/src/components/PageContent.vue

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@
77

88
<div class="md-title">{{ pageTitle }}</div>
99

10-
<div class="release-version" v-if="availableDocs.length > 1">
11-
<span>Version:</span>
12-
<md-select id="docs-select" v-model="currentDocs" @change="changeDocs">
13-
<md-option v-for="doc in availableDocs" :value="doc">{{ doc }}</md-option>
14-
</md-select>
15-
</div>
10+
<release-version></release-version>
1611

1712
<md-button href="https://github.com/marcosmoura/vue-material" target="_blank" rel="noopener" class="md-icon-button github">
1813
<md-icon md-src="assets/icon-github.svg"></md-icon>
@@ -51,26 +46,6 @@
5146
}
5247
}
5348
54-
.md-toolbar {
55-
.md-select {
56-
&:after {
57-
color: rgba(#fff, .87);
58-
}
59-
}
60-
}
61-
62-
.release-version {
63-
display: flex;
64-
align-items: center;
65-
font-size: 15px;
66-
67-
.md-select {
68-
width: auto;
69-
min-width: auto;
70-
margin: 0 8px;
71-
}
72-
}
73-
7449
.github {
7550
@media (max-width: 480px) {
7651
display: none;
@@ -83,55 +58,12 @@
8358
props: {
8459
pageTitle: String
8560
},
86-
data: () => ({
87-
latest: null,
88-
currentDocs: null,
89-
availableDocs: []
90-
}),
9161
methods: {
92-
changeDocs() {
93-
const location = window.location;
94-
95-
if (this.currentDocs === this.latest) {
96-
window.location.href = location.origin + '/' + location.hash;
97-
} else {
98-
window.location.href = location.origin + '/releases/v' + this.currentDocs + '/' + location.hash;
99-
}
100-
},
10162
toggleSidenav() {
10263
this.$root.toggleSidenav();
103-
},
104-
getVersions(callback) {
105-
const request = new XMLHttpRequest();
106-
107-
request.open('GET', '/versions.json', true);
108-
request.setRequestHeader('Content-Type', 'application/json');
109-
request.onload = function() {
110-
callback(JSON.parse(this.response));
111-
};
112-
request.send();
113-
},
114-
setVersion(versions) {
115-
versions.sort((a, b) => a < b);
116-
117-
this.latest = versions[0];
118-
this.currentDocs = versions[0];
119-
this.availableDocs = versions;
120-
},
121-
setCurrentByLocation() {
122-
let normalizedPathname = location.pathname.replace(/\/|releases\/v/g, '');
123-
124-
if (normalizedPathname && this.availableDocs.indexOf(normalizedPathname) >= 0) {
125-
this.currentDocs = normalizedPathname;
126-
}
12764
}
12865
},
12966
mounted() {
130-
this.getVersions((response) => {
131-
this.setVersion(response);
132-
this.setCurrentByLocation();
133-
});
134-
13567
document.title = this.pageTitle + ' - Vue Material';
13668
}
13769
};
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<template>
2+
<div class="release-version">
3+
<div v-if="availableDocs.length > 1">
4+
<span>Version:</span>
5+
<md-select id="docs-select" v-model="currentDocs" @change="changeDocs">
6+
<md-option v-for="doc in availableDocs" :value="doc">{{ doc }}</md-option>
7+
</md-select>
8+
</div>
9+
</div>
10+
</template>
11+
12+
<style lang="sass" scoped>
13+
.release-version {
14+
font-size: 15px;
15+
16+
@media (max-width: 480px) {
17+
display: none;
18+
}
19+
20+
> div {
21+
display: flex;
22+
align-items: center;
23+
}
24+
25+
.md-select {
26+
width: auto;
27+
min-width: auto;
28+
margin: 0 8px;
29+
30+
&:after {
31+
color: rgba(#fff, .87);
32+
}
33+
}
34+
}
35+
</style>
36+
37+
<script>
38+
let versions = null;
39+
40+
export default {
41+
data: () => ({
42+
latest: null,
43+
currentDocs: null,
44+
availableDocs: []
45+
}),
46+
methods: {
47+
changeDocs() {
48+
const location = window.location;
49+
50+
if (this.currentDocs === this.latest) {
51+
window.location.href = location.origin + '/' + location.hash;
52+
} else {
53+
window.location.href = location.origin + '/releases/v' + this.currentDocs + '/' + location.hash;
54+
}
55+
},
56+
getVersions(callback) {
57+
if (!versions) {
58+
const request = new XMLHttpRequest();
59+
60+
request.open('GET', '/versions.json', true);
61+
request.setRequestHeader('Content-Type', 'application/json');
62+
request.onload = function() {
63+
versions = JSON.parse(this.response);
64+
callback(versions);
65+
};
66+
request.send();
67+
} else {
68+
callback(versions);
69+
}
70+
},
71+
setVersion(versions) {
72+
versions.sort((a, b) => a < b);
73+
74+
this.latest = versions[0];
75+
this.currentDocs = versions[0];
76+
this.availableDocs = versions;
77+
},
78+
setCurrentByLocation() {
79+
let normalizedPathname = location.pathname.replace(/\/|releases\/v/g, '');
80+
81+
if (normalizedPathname && this.availableDocs.indexOf(normalizedPathname) >= 0) {
82+
this.currentDocs = normalizedPathname;
83+
}
84+
}
85+
},
86+
mounted() {
87+
this.getVersions((response) => {
88+
this.setVersion(response);
89+
this.setCurrentByLocation();
90+
});
91+
}
92+
};
93+
</script>

docs/src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ import DocsComponent from './components/DocsComponent';
1212
import ExampleBox from './components/ExampleBox';
1313
import ApiTable from './components/ApiTable';
1414
import CodeBlock from './components/CodeBlock';
15+
import ReleaseVersion from './components/ReleaseVersion';
1516

1617
Vue.component('page-content', PageContent);
1718
Vue.component('docs-component', DocsComponent);
1819
Vue.component('example-box', ExampleBox);
1920
Vue.component('api-table', ApiTable);
2021
Vue.component('code-block', CodeBlock);
22+
Vue.component('release-version', ReleaseVersion);
2123

2224
Vue.use(VueRouter);
2325

0 commit comments

Comments
 (0)