Skip to content

Commit d4fe59d

Browse files
committed
Squashed commit of the following:
commit b684808 Author: Austin <[email protected]> Date: Mon Jul 17 15:35:08 2017 -0600 feat(PWA): add service worker angular#175 (angular#223) commit ec7c637 Author: Austin <[email protected]> Date: Mon Jul 17 13:52:28 2017 -0600 feat(docs): add page titles to doc pages angular#189 (angular#220) commit 6170057 Author: Rafael Santana <[email protected]> Date: Wed Jul 12 20:05:29 2017 -0300 Fix exception being thrown on invalid routes (angular#218) commit 101aeff Author: Michael Prentice <[email protected]> Date: Tue Jul 11 19:38:17 2017 -0400 fix(footer): extra w in www.angular.io (angular#217) just use https://angular.io since that is where www.angular.io goes commit 135c38f Author: Rafael Santana <[email protected]> Date: Sun Jul 9 12:37:39 2017 -0300 Add handling for invalid routes (angular#191) commit ad1400e Author: Will Howell <[email protected]> Date: Sun Jul 9 11:35:25 2017 -0400 Set max width for component and guide viewers (angular#207) commit ac3f30e Author: Austin <[email protected]> Date: Sun Jul 9 10:18:02 2017 -0500 chore(styles): apply material light / dark styles to highlightjs (angular#213)
1 parent d301182 commit d4fe59d

23 files changed

+347
-49
lines changed

angular-cli.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
"test": "test.ts",
1717
"tsconfig": "tsconfig.json",
1818
"prefix": "app",
19-
"mobile": false,
19+
"serviceWorker": true,
2020
"styles": [
2121
"main.scss",
22-
"highlightjs/solarized-light.css",
22+
"highlightjs/material-light.css",
2323
{"input": "assets/pink-bluegrey.css", "lazy": true},
2424
{"input": "assets/deeppurple-amber.css", "lazy": true},
2525
{"input": "assets/indigo-pink.css", "lazy": true},

ngsw-manifest.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"external": {
3+
"urls": [
4+
{"url": "https://fonts.googleapis.com/icon?family=Material+Icons"},
5+
{"url": "https://fonts.googleapis.com/css?family=Roboto|Roboto+Mono"},
6+
{"url": "https://ajax.googleapis.com/ajax/libs/hammerjs/2.0.8/hammer.min.js"},
7+
{"url": "https://cdnjs.cloudflare.com/ajax/libs/web-animations/2.2.5/web-animations.min.js"}
8+
]
9+
}
10+
}

src/app/pages/component-category-list/component-category-list.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('ComponentCategoryList', () => {
2121
spyOn(component, 'ngOnInit').and.callThrough();
2222
fixture.detectChanges();
2323
expect(component.ngOnInit).toHaveBeenCalled();
24-
expect(component._componentPageTitle.title).toEqual('Component Library');
24+
expect(component._componentPageTitle.title).toEqual('Component Categories');
2525
});
2626

2727
it('should render a card for every category', () => {

src/app/pages/component-category-list/component-category-list.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class ComponentCategoryList {
1717
public _componentPageTitle: ComponentPageTitle) {}
1818

1919
ngOnInit() {
20-
this._componentPageTitle.title = 'Component Library';
20+
this._componentPageTitle.title = 'Component Categories';
2121
}
2222
}
2323

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
DocumentationItems,
44
DocCategory
55
} from '../../shared/documentation-items/documentation-items';
6-
import {ActivatedRoute, RouterModule} from '@angular/router';
6+
import {ActivatedRoute, Router, RouterModule} from '@angular/router';
77
import {ComponentPageTitle} from '../page-title/page-title';
88
import {SvgViewerModule} from '../../shared/svg-viewer/svg-viewer';
99
import {CommonModule} from '@angular/common';
@@ -19,10 +19,16 @@ export class ComponentList {
1919

2020
constructor(public docItems: DocumentationItems,
2121
private _componentPageTitle: ComponentPageTitle,
22-
private _route: ActivatedRoute) {
22+
private _route: ActivatedRoute,
23+
private router: Router) {
2324
_route.params.subscribe(p => {
2425
this.category = docItems.getCategoryById(p['id']);
25-
this._componentPageTitle.title = this.category.name;
26+
27+
if (this.category) {
28+
this._componentPageTitle.title = this.category.name;
29+
} else {
30+
this.router.navigate(['/categories']);
31+
}
2632
});
2733
}
2834
}
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
<!-- TODO(jelbourn): turn this into nav tabs -->
2-
<nav md-tab-nav-bar class="docs-component-viewer-tabbed-content">
3-
<a md-tab-link class="docs-component-viewer-section-tab"
4-
*ngFor="let section of ['Overview', 'API', 'Examples']"
5-
[routerLink]="section.toLowerCase()"
6-
routerLinkActive #rla="routerLinkActive"
7-
[active]="rla.isActive">{{section}}</a>
8-
</nav>
1+
<div class="docs-component-viewer">
2+
<nav md-tab-nav-bar class="docs-component-viewer-tabbed-content">
3+
<a md-tab-link class="docs-component-viewer-section-tab"
4+
*ngFor="let section of ['Overview', 'API', 'Examples']"
5+
[routerLink]="section.toLowerCase()"
6+
routerLinkActive #rla="routerLinkActive"
7+
[active]="rla.isActive">{{section}}</a>
8+
</nav>
99

10-
<div class="docs-component-viewer-content">
11-
<router-outlet></router-outlet>
10+
<div class="docs-component-viewer-content">
11+
<router-outlet></router-outlet>
12+
</div>
1213
</div>

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@
22

33
app-component-viewer {
44
font-weight: 400;
5-
margin: 20px 70px 50px 70px;
5+
padding: 20px $content-padding-side 50px;
6+
7+
@media ($mat-xsmall) {
8+
padding-left: $content-padding-side-xs;
9+
padding-right: $content-padding-side-xs;
10+
}
11+
}
12+
13+
.docs-component-viewer {
14+
margin: 0 auto;
15+
max-width: 940px;
616
}
717

818
.docs-component-viewer-section-tab {

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component, NgModule, ViewEncapsulation} from '@angular/core';
2-
import {ActivatedRoute, RouterModule} from '@angular/router';
2+
import {ActivatedRoute, Router, RouterModule} from '@angular/router';
33
import {DocumentationItems, DocItem} from '../../shared/documentation-items/documentation-items';
44
import {ComponentPageTitle} from '../page-title/page-title';
55
import {MdTabsModule} from '@angular/material';
@@ -18,11 +18,17 @@ export class ComponentViewer {
1818
componentDocItem: DocItem;
1919

2020
constructor(private _route: ActivatedRoute,
21+
private router: Router,
2122
public _componentPageTitle: ComponentPageTitle,
2223
public docItems: DocumentationItems) {
23-
_route.params.subscribe(p => {
24-
this.componentDocItem = docItems.getItemById(p['id']);
25-
this._componentPageTitle.title = `${this.componentDocItem.name}`;
24+
this._route.params.subscribe(params => {
25+
this.componentDocItem = docItems.getItemById(params['id']);
26+
27+
if (this.componentDocItem) {
28+
this._componentPageTitle.title = `${this.componentDocItem.name}`;
29+
} else {
30+
this.router.navigate(['/components']);
31+
}
2632
});
2733
}
2834
}
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
1-
import {Component, NgModule} from '@angular/core';
1+
import {Component, NgModule, OnInit} from '@angular/core';
22
import {GuideItems} from '../../shared/guide-items/guide-items';
33
import {MdListModule} from '@angular/material';
44
import {RouterModule} from '@angular/router';
55
import {FooterModule} from '../../shared/footer/footer';
66
import {CommonModule} from '@angular/common';
7+
import {ComponentPageTitle} from '../page-title/page-title';
78

89
@Component({
910
selector: 'app-guides',
1011
templateUrl: './guide-list.html',
1112
styleUrls: ['./guide-list.scss']
1213
})
13-
export class GuideList {
14-
constructor(public guideItems: GuideItems) {}
14+
export class GuideList implements OnInit {
15+
constructor(public guideItems: GuideItems, public _componentPageTitle: ComponentPageTitle) {}
16+
17+
ngOnInit(): void {
18+
this._componentPageTitle.title = 'Guides';
19+
}
1520
}
1621

1722

1823
@NgModule({
1924
imports: [MdListModule, RouterModule, FooterModule, CommonModule],
2025
exports: [GuideList],
2126
declarations: [GuideList],
22-
providers: [GuideItems],
27+
providers: [GuideItems, ComponentPageTitle],
2328
})
2429
export class GuideListModule { }

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
<h1>{{guide.name}}</h1>
33
</div>
44

5-
<div class="docs-guide-content">
6-
<doc-viewer class="docs-guide-viewer" [documentUrl]="guide.document"></doc-viewer>
5+
<div class="docs-guide-wrapper">
6+
<div class="docs-guide-inner">
7+
<doc-viewer class="docs-guide-content" [documentUrl]="guide.document"></doc-viewer>
78
<table-of-contents></table-of-contents>
89
</div>
10+
</div>
911

1012
<app-footer></app-footer>

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,37 @@ $guide-content-margin-side-xs: 15px;
1111
flex-grow: 1;
1212
}
1313

14-
.docs-guide-content {
14+
.docs-guide-wrapper {
15+
padding: 20px $content-padding-side 0;
1516
display: block;
16-
margin: 20px $guide-content-margin-side 0;
17-
flex-grow: 1;
17+
text-align: center;
1818

1919
@media ($mat-xsmall) {
20-
margin-left: $guide-content-margin-side-xs;
21-
margin-right: $guide-content-margin-side-xs;
20+
padding-left: $content-padding-side-xs;
21+
padding-right: $content-padding-side-xs;
2222
}
2323
}
2424

25-
.docs-guide-viewer {
26-
width: 80%;
25+
.docs-guide-inner {
26+
display: inline-block;
27+
text-align: left;
28+
max-width: 940px;
29+
}
30+
31+
.docs-guide-content {
2732
display: block;
2833
float: left;
34+
width: 80%;
2935

3036
@media (max-width: $small-breakpoint-width) {
3137
width: 100%;
3238
}
3339
}
3440

3541
table-of-contents {
36-
float: right;
3742
top: 35px;
43+
float: right;
44+
width: 15%;
3845

3946
@media (max-width: $small-breakpoint-width) {
4047
display: none;
Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,42 @@
1-
import {Component, NgModule} from '@angular/core';
2-
import {ActivatedRoute, RouterModule} from '@angular/router';
1+
import {Component, NgModule, OnInit} from '@angular/core';
2+
import {ActivatedRoute, RouterModule, Router} from '@angular/router';
33
import {GuideItem, GuideItems} from '../../shared/guide-items/guide-items';
44
import {FooterModule} from '../../shared/footer/footer';
55
import {DocViewerModule} from '../../shared/doc-viewer/doc-viewer-module';
66
import {HeaderLinkModule} from '../../shared/header-link/header-link.module';
77
import {TableOfContentsModule} from '../../shared/table-of-contents/table-of-contents.module';
8+
import {ComponentPageTitle} from '../page-title/page-title';
89

910
@Component({
1011
selector: 'guide-viewer',
1112
templateUrl: './guide-viewer.html',
1213
styleUrls: ['./guide-viewer.scss'],
1314
})
14-
export class GuideViewer {
15+
export class GuideViewer implements OnInit {
1516
guide: GuideItem;
1617

17-
constructor(private _route: ActivatedRoute, public guideItems: GuideItems) {
18+
constructor(private _route: ActivatedRoute,
19+
private _componentPageTitle: ComponentPageTitle,
20+
private router: Router,
21+
public guideItems: GuideItems) {
1822
_route.params.subscribe(p => {
1923
this.guide = guideItems.getItemById(p['id']);
24+
25+
if (!this.guide) {
26+
this.router.navigate(['/guides']);
27+
}
2028
});
2129
}
30+
31+
ngOnInit(): void {
32+
this._componentPageTitle.title = this.guide.name;
33+
}
2234
}
2335

2436
@NgModule({
2537
imports: [DocViewerModule, FooterModule, RouterModule, HeaderLinkModule, TableOfContentsModule],
2638
exports: [GuideViewer],
2739
declarations: [GuideViewer],
28-
providers: [GuideItems],
40+
providers: [GuideItems, ComponentPageTitle],
2941
})
3042
export class GuideViewerModule {}

src/app/pages/homepage/homepage.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
1-
import {Component, NgModule} from '@angular/core';
1+
import {Component, NgModule, OnInit} from '@angular/core';
22
import {SvgViewerModule} from '../../shared/svg-viewer/svg-viewer';
33
import {MdButtonModule} from '@angular/material';
44
import {FooterModule} from '../../shared/footer/footer';
55
import {RouterModule} from '@angular/router';
6+
import {ComponentPageTitle} from '../page-title/page-title';
67

78
@Component({
89
selector: 'app-homepage',
910
templateUrl: './homepage.html',
1011
styleUrls: ['./homepage.scss']
1112
})
12-
export class Homepage {}
13+
export class Homepage implements OnInit {
14+
constructor(public _componentPageTitle: ComponentPageTitle) {}
15+
16+
ngOnInit(): void {
17+
this._componentPageTitle.title = '';
18+
}
19+
}
1320

1421
@NgModule({
1522
imports: [SvgViewerModule, MdButtonModule, FooterModule, RouterModule],
1623
exports: [Homepage],
1724
declarations: [Homepage],
1825
})
19-
export class HomepageModule { }
26+
export class HomepageModule {}

src/app/pages/page-title/page-title.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import {ComponentPageTitle} from './page-title';
2-
2+
import {Title} from '@angular/platform-browser';
33

44
describe('ComponentPageTitle', () => {
5-
const service: ComponentPageTitle = new ComponentPageTitle();
5+
const title: Title = new Title({});
6+
const service: ComponentPageTitle = new ComponentPageTitle(title);
67

78
it('should initialize title to empty string', () => {
89
expect(service._title).toEqual('');

src/app/pages/page-title/page-title.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {Injectable} from '@angular/core';
2+
import {Title} from '@angular/platform-browser';
23

34
/**
45
* Service responsible for setting the title that appears above the components and guide pages.
@@ -8,5 +9,15 @@ export class ComponentPageTitle {
89
_title = '';
910

1011
get title(): string { return this._title; }
11-
set title(title: string) { this._title = title; }
12+
13+
set title(title: string) {
14+
this._title = title;
15+
if (title !== '') {
16+
title = `${title} | `;
17+
}
18+
this.bodyTitle.setTitle(`${title}Angular Material`);
19+
}
20+
21+
constructor(private bodyTitle: Title) { }
22+
1223
}

src/app/routes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ export const MATERIAL_DOCS_ROUTES: Routes = [
3737
{path: 'overview', component: ComponentOverview, pathMatch: 'full'},
3838
{path: 'api', component: ComponentApi, pathMatch: 'full'},
3939
{path: 'examples', component: ComponentExamples, pathMatch: 'full'},
40+
{path: '**', redirectTo: 'overview'},
4041
],
4142
},
4243
],
4344
},
4445
{path: 'guides', component: GuideList},
4546
{path: 'guide/:id', component: GuideViewer},
47+
{path: '**', redirectTo: ''},
4648
];

src/app/shared/footer/footer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<div class="docs-footer-links">
1010
<ul>
11-
<li> <a href="https://wwww.angular.io">Learn Angular</a> </li>
11+
<li> <a href="https://angular.io">Learn Angular</a> </li>
1212
</ul>
1313
</div>
1414

src/assets/custom-themes/pink-bluegrey.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@import '../../app-theme';
2+
@import '../../highlightjs/material-dark';
23

34
// Define the dark theme.
45
$primary: mat-palette($mat-pink);

src/assets/custom-themes/purple-green.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@import '../../app-theme';
2+
@import '../../highlightjs/material-dark';
23

34
// Define the dark theme.
45
$primary: mat-palette($mat-purple);

src/assets/img/favicons/manifest.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
{
2-
"name": "Angular.io",
2+
"name": "Angular Material",
3+
"short_name": "Angular Material",
4+
"theme_color": "#FFFFFF",
5+
"background_color": "#3F51B5",
6+
"start_url": "/",
7+
"display": "standalone",
8+
"orientation": "portrait",
39
"icons": [
410
{
511
"src": "\/android-chrome-36x36.png",

0 commit comments

Comments
 (0)