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

Commit 049117c

Browse files
andrewseguinjelbourn
authored andcommitted
add sidenav toggle on mobile displays (#62)
* add sidenav toggle when mobile * fix lint errors
1 parent 9e9001b commit 049117c

20 files changed

+146
-32
lines changed

src/app/app-module.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import {ExampleModule} from './examples/example-module';
1515
import {SharedModule} from './shared/shared-module';
1616
import {ComponentCategoryList} from './pages/component-category-list/component-category-list';
1717
import {ComponentSidenav} from './pages/component-sidenav/component-sidenav';
18+
import {ComponentPageTitle} from './pages/page-title/page-title';
19+
import {ComponentPageHeader} from './pages/component-page-header/component-page-header';
1820

1921

2022
@NgModule({
@@ -24,6 +26,7 @@ import {ComponentSidenav} from './pages/component-sidenav/component-sidenav';
2426
ComponentList,
2527
ComponentSidenav,
2628
ComponentViewer,
29+
ComponentPageHeader,
2730
GuideList,
2831
GuideViewer,
2932
Homepage,
@@ -39,6 +42,7 @@ import {ComponentSidenav} from './pages/component-sidenav/component-sidenav';
3942
],
4043
providers: [
4144
Location,
45+
ComponentPageTitle,
4246
{provide: LocationStrategy, useClass: PathLocationStrategy},
4347
],
4448
bootstrap: [MaterialDocsApp],

src/app/pages/component-category-list/_component-category-list-theme.scss

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@
55
$background: map-get($theme, background);
66
$foreground: map-get($theme, foreground);
77

8-
.docs-component-category-list-header {
9-
background: md-color($primary);
10-
11-
h1 {
12-
color: md-color($primary, default-contrast);
13-
}
14-
}
15-
168
.docs-component-category-list-card-summary {
179
color: md-color($foreground, secondary-text);
1810
}

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
<div class="docs-component-category-list-header">
2-
<h1>Component Library</h1>
3-
</div>
4-
51
<div class="docs-component-category-list">
62
<md-card
73
*ngFor="let category of docItems.getItemsInCategories()"

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1+
@import '../../../styles/constants';
2+
13
.docs-component-category-list {
24
padding: 20px;
5+
6+
@media (max-width: $small-breakpoint-width) {
7+
display: flex;
8+
flex-wrap: wrap;
9+
justify-content: center;
10+
}
311
}
412

513
.docs-component-category-list-card {
@@ -24,6 +32,8 @@
2432

2533
.docs-component-category-list-header {
2634
padding-left: 20px;
35+
display: flex;
36+
align-items: center;
2737

2838
h1 {
2939
font-size: 30px;
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {Component} from '@angular/core';
22
import {DocumentationItems} from '../../shared/documentation-items/documentation-items';
3+
import {ComponentPageTitle} from '../page-title/page-title';
34

45

56
@Component({
@@ -8,5 +9,10 @@ import {DocumentationItems} from '../../shared/documentation-items/documentation
89
styleUrls: ['./component-category-list.scss']
910
})
1011
export class ComponentCategoryList {
11-
constructor(public docItems: DocumentationItems) {}
12+
constructor(public docItems: DocumentationItems,
13+
private _componentPageTitle: ComponentPageTitle) {}
14+
15+
ngOnInit() {
16+
this._componentPageTitle.title = 'Component Library';
17+
}
1218
}

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
<div class="docs-primary-header">
2-
<h1> {{category.name}} </h1>
3-
</div>
4-
51
<div class="docs-component-list-category">
62
<a *ngFor="let component of category.items"
73
class="docs-component-list-item"

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
@import '~@angular/material/button/button-base';
2-
2+
@import '../../../styles/constants';
33

44
.docs-component-list-category {
55
margin: 20px;
6+
7+
@media (max-width: $small-breakpoint-width) {
8+
display: flex;
9+
flex-wrap: wrap;
10+
justify-content: space-around;
11+
}
612
}
713

814
.docs-component-list-item {

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
DocCategory
55
} from '../../shared/documentation-items/documentation-items';
66
import {ActivatedRoute} from '@angular/router';
7+
import {ComponentPageTitle} from '../page-title/page-title';
78

89
@Component({
910
selector: 'app-components',
@@ -13,9 +14,12 @@ import {ActivatedRoute} from '@angular/router';
1314
export class ComponentList {
1415
category: DocCategory;
1516

16-
constructor(public docItems: DocumentationItems, private _route: ActivatedRoute) {
17+
constructor(public docItems: DocumentationItems,
18+
private _componentPageTitle: ComponentPageTitle,
19+
private _route: ActivatedRoute) {
1720
_route.params.subscribe(p => {
1821
this.category = docItems.getCategoryById(p['id']);
22+
this._componentPageTitle.title = this.category.name;
1923
});
2024
}
2125
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div class="docs-primary-header component-page-header">
2+
<button md-button class="sidenav-toggle" (click)="toggleSidenav.emit()">
3+
<md-icon>menu</md-icon>
4+
</button>
5+
6+
<h1>{{getTitle()}} </h1>
7+
</div>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
@import '../../../styles/constants';
2+
3+
.component-page-header {
4+
display: flex;
5+
align-items: center;
6+
7+
@media (max-width: $small-breakpoint-width) {
8+
padding-left: 0;
9+
}
10+
}
11+
12+
h1 {
13+
@media (max-width: $small-breakpoint-width) {
14+
padding: 24px 8px;
15+
font-size: 20px;
16+
}
17+
}
18+
19+
.sidenav-toggle {
20+
padding: 0;
21+
margin: 8px;
22+
min-width: 64px;
23+
display: none;
24+
@media (max-width: $small-breakpoint-width) {
25+
display: flex;
26+
align-items: center;
27+
justify-content: center;
28+
}
29+
30+
md-icon {
31+
font-size: 30px;
32+
height: 64px;
33+
width: 64px;
34+
line-height: 64px;
35+
color: white;
36+
}
37+
}

0 commit comments

Comments
 (0)