Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Commit 62706dc

Browse files
josephperrottjelbourn
authored andcommitted
Improve mobile experience across the site (#265)
- Give elevation to navbar on all pages - Make navbar "sticky" on all pages - Show table of contents (non-sticky) at the top of pages on mobile - Shrink landing page spacing on mobile to increase density - Move navbar to a two row version on mobile - Use md-icon for angular and github icons in navbar - Enforce word breaks for p tags in docs, preventing x axis overflows - Decrease height of Guides subheader to match other pages - Shrink docs-api table spacing on mobile to increase density
1 parent c812fad commit 62706dc

18 files changed

+135
-37
lines changed

src/app/material-docs-app.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
<app-navbar [class.mat-elevation-z6]="showShadow"></app-navbar>
1+
<app-navbar class="mat-elevation-z6"></app-navbar>
22
<router-outlet></router-outlet>

src/app/material-docs-app.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ material-docs-app > app-component-sidenav {
1212
flex: 1 1 auto;
1313
}
1414

15+
// Target last-child as it will be the output of the router-outlet within the app's container.
16+
material-docs-app > :last-child {
17+
overflow-y: auto;
18+
}
19+
1520
app-navbar {
1621
position: relative;
1722
z-index: 10;

src/app/material-docs-app.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,13 @@ import 'rxjs/add/operator/filter';
1010
encapsulation: ViewEncapsulation.None,
1111
})
1212
export class MaterialDocsApp {
13-
showShadow = false;
1413

1514
constructor(router: Router) {
16-
const routesWithNavbarShadow = ['/categories', '/components'];
17-
1815
let previousRoute = router.routerState.snapshot.url;
1916

2017
router.events
2118
.filter(event => event instanceof NavigationEnd )
2219
.subscribe((data: NavigationEnd) => {
23-
this.showShadow = !!routesWithNavbarShadow
24-
.find(route => data.urlAfterRedirects.startsWith(route));
25-
2620
// We want to reset the scroll position on navigation except when navigating within
2721
// the documentation for a single component.
2822
if (!isNavigationWithinComponentView(previousRoute, data.urlAfterRedirects)) {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@import '../../../styles/constants';
2+
3+
component-overview {
4+
@media (max-width: $small-breakpoint-width) {
5+
display: flex;
6+
flex-direction: column;
7+
}
8+
}

src/app/pages/component-viewer/component-viewer.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ app-component-viewer {
3232
top: 35px;
3333

3434
@media (max-width: $small-breakpoint-width) {
35-
display: none;
35+
display: flex;
36+
order: -1;
37+
position: inherit;
38+
width: auto;
3639
}
3740
}
3841
}

src/app/pages/component-viewer/component-viewer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export class ComponentViewer {
3535
@Component({
3636
selector: 'component-overview',
3737
templateUrl: './component-overview.html',
38+
styleUrls: ['./component-overview.scss'],
3839
encapsulation: ViewEncapsulation.None,
3940
})
4041
export class ComponentOverview {

src/app/pages/guide-viewer/guide-viewer.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ $guide-content-margin-side-xs: 15px;
2323
}
2424

2525
.docs-guide-toc-and-content {
26-
display: inline-block;
26+
display: block;
2727
text-align: left;
2828
max-width: 940px;
2929
}

src/app/pages/homepage/homepage.scss

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
// The margin between two sections
22
$margin-promotion-sections: 60px;
3+
$margin-promotion-sections-small: 15px;
34

45
.docs-header-background {
5-
height: 300px;
6-
margin-bottom: 40px;
6+
overflow: hidden;
77
}
88

99
.docs-header-section {
1010
text-align: center;
11-
padding-top: 60px;
11+
padding-top: $margin-promotion-sections;
1212
}
1313

1414
.docs-header-headline {
1515
h1 {
1616
font-size: 56px;
1717
font-weight: 300;
1818
line-height: 56px;
19-
margin: 15px 0 15px 0;
19+
margin: 15px 5px;
2020
}
2121

2222
h2 {
@@ -85,3 +85,22 @@ $margin-promotion-sections: 60px;
8585
flex-direction: column;
8686
justify-content: center;
8787
}
88+
89+
90+
/**
91+
* Rules for when the device is detected to be a small screen.
92+
*/
93+
@media (max-width: 720px) {
94+
.docs-header-section {
95+
padding-top: $margin-promotion-sections-small;
96+
}
97+
98+
.docs-header-start,
99+
.docs-homepage-bottom-start {
100+
margin: $margin-promotion-sections-small 0;
101+
}
102+
103+
.docs-homepage-row {
104+
margin: $margin-promotion-sections-small 0;
105+
}
106+
}

src/app/shared/navbar/_navbar-theme.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
app-navbar {
99
color: mat-color($primary, default-contrast);
1010

11-
.docs-navbar {
11+
.docs-navbar, .docs-navbar-header {
1212
background: mat-color($primary);
1313
}
1414
}

src/app/shared/navbar/navbar.html

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
11
<!-- TODO: figure out if the <nav> should go inside of a <header> element. -->
2-
<nav class="docs-navbar">
2+
<nav class="docs-navbar-header">
33
<a md-button class="docs-button" routerLink="/" aria-label="Angular Material">
44
<img class="docs-angular-logo"
5-
src="../../../assets/img/homepage/angular-white-transparent.svg"
6-
alt="angular">
5+
src="../../../assets/img/homepage/angular-white-transparent.svg"
6+
alt="angular">
77
<span>Material</span>
88
</a>
9-
<a md-button class="docs-button" routerLink="components">Components</a>
10-
<a md-button class="docs-button" routerLink="guides">Guides</a>
9+
<a md-button class="docs-navbar-hide-small docs-button" routerLink="components">Components</a>
10+
<a md-button class="docs-navbar-hide-small docs-button" routerLink="guides">Guides</a>
1111
<div class="flex-spacer"></div>
1212
<theme-picker></theme-picker>
13-
<a md-button class="docs-button" href="https://github.com/angular/material2" aria-label="GitHub Repository">
14-
<img class="docs-github-logo"
15-
src="../../../assets/img/homepage/github-circle-white-transparent.svg"
16-
alt="GitHub">
13+
<a md-button class="docs-button docs-navbar-hide-small" href="https://github.com/angular/material2"
14+
aria-label="GitHub Repository">
15+
<img class="docs-angular-logo"
16+
src="../../../assets/img/homepage/github-circle-white-transparent.svg"
17+
alt="angular">
1718
GitHub
1819
</a>
20+
<a md-icon-button class="docs-button docs-navbar-show-small"
21+
href="https://github.com/angular/material2" aria-label="GitHub Repository">
22+
<img class="docs-angular-logo"
23+
src="../../../assets/img/homepage/github-circle-white-transparent.svg"
24+
alt="angular">
25+
</a>
26+
</nav>
27+
<nav class="docs-navbar docs-navbar-show-small">
28+
<a md-button class="docs-navbar-link" routerLink="components">Components</a>
29+
<a md-button class="docs-navbar-link" routerLink="guides">Guides</a>
1930
</nav>

0 commit comments

Comments
 (0)