Skip to content

Commit 1987f2c

Browse files
committed
feat(demo): add navigation
1 parent c6dd530 commit 1987f2c

39 files changed

+326
-78
lines changed

projects/elements-demo/src/app/app-routing.module.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@ import { NgModule } from '@angular/core';
22
import { Routes, RouterModule } from '@angular/router';
33

44
import { HomeComponent } from './features/home/home/home.component';
5-
import { EagerComponent } from './features/eager/eager/eager.component';
65

76
const routes: Routes = [
87
{
98
path: 'home',
109
component: HomeComponent
1110
},
1211
{
13-
path: 'eager',
14-
component: EagerComponent
12+
path: 'docs',
13+
loadChildren: () =>
14+
import('./features/docs/docs.module').then(m => m.DocsModule)
1515
},
1616
{
17-
path: 'lazy',
17+
path: 'examples',
1818
loadChildren: () =>
19-
import('./features/lazy/lazy.module').then(m => m.LazyModule)
19+
import('./features/examples/examples.module').then(m => m.ExamplesModule)
2020
},
2121
{
2222
path: '**',

projects/elements-demo/src/app/app.module.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { LazyElementsModule } from '../../../elements/src/lib/lazy-elements/lazy
88
import { CoreModule } from './core/core.module';
99
import { SharedModule } from './shared/shared.module';
1010
import { HomeModule } from './features/home/home.module';
11-
import { EagerModule } from './features/eager/eager.module';
1211
import { AppRoutingModule } from './app-routing.module';
1312

1413
import { AppComponent } from './app.component';
@@ -29,8 +28,7 @@ import { AppComponent } from './app.component';
2928
CoreModule,
3029
SharedModule,
3130
AppRoutingModule,
32-
HomeModule,
33-
EagerModule
31+
HomeModule
3432
],
3533
providers: [],
3634
bootstrap: [AppComponent]
Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,26 @@
1-
<p>navigation works!</p>
1+
<mat-nav-list>
2+
<ng-container *ngFor="let nav of navigation">
3+
<a
4+
mat-list-item
5+
[routerLink]="nav.url"
6+
routerLinkActive="active"
7+
#rla="routerLinkActive"
8+
>
9+
{{ nav.label }}
10+
<mat-icon matListIcon>{{
11+
nav.children && rla.isActive ? 'expand_more' : 'chevron_right'
12+
}}</mat-icon>
13+
</a>
14+
<ng-container *ngIf="nav.children && rla.isActive">
15+
<a
16+
mat-list-item
17+
class="sub-nav"
18+
*ngFor="let child of nav.children"
19+
[routerLink]="child.url"
20+
routerLinkActive="active"
21+
>
22+
{{ child.label }}
23+
</a>
24+
</ng-container>
25+
</ng-container>
26+
</mat-nav-list>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
mat-nav-list {
2+
padding-top: 0;
3+
}
4+
5+
a[mat-list-item] {
6+
width: 250px;
7+
8+
&.sub-nav {
9+
width: auto;
10+
padding-left: 33px !important;
11+
font-size: 1em !important;
12+
}
13+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@import '~@angular/material/theming';
2+
3+
@mixin demo-navigation-component-theme($theme) {
4+
$primary: map-get($theme, primary);
5+
$accent: map-get($theme, accent);
6+
$warn: map-get($theme, warn);
7+
$foreground: map-get($theme, foreground);
8+
$background: map-get($theme, background);
9+
10+
demo-navigation {
11+
.active {
12+
color: mat-color($primary) !important;
13+
}
14+
}
15+
}

projects/elements-demo/src/app/core/layout/navigation/navigation.component.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
import { RouterTestingModule } from '@angular/router/testing';
23

34
import { SharedModule } from '../../../shared/shared.module';
45

@@ -10,7 +11,7 @@ describe('NavigationComponent', () => {
1011

1112
beforeEach(async(() => {
1213
TestBed.configureTestingModule({
13-
imports: [SharedModule],
14+
imports: [RouterTestingModule, SharedModule],
1415
declarations: [NavigationComponent]
1516
}).compileComponents();
1617
}));

projects/elements-demo/src/app/core/layout/navigation/navigation.component.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,48 @@
11
import { Component, OnInit } from '@angular/core';
22

3+
const NAVIGATION = [
4+
{
5+
label: 'HOME',
6+
url: 'home'
7+
},
8+
{
9+
label: 'DOCS',
10+
url: 'docs',
11+
children: [
12+
{
13+
label: 'Getting started',
14+
url: 'docs/getting-started'
15+
},
16+
{
17+
label: 'Mechanism',
18+
url: 'docs/mechanism'
19+
}
20+
]
21+
},
22+
{
23+
label: 'EXAMPLES',
24+
url: 'examples',
25+
children: [
26+
{
27+
label: 'Basic',
28+
url: 'basic'
29+
},
30+
{
31+
label: 'Lazy Loading',
32+
url: 'lazy'
33+
}
34+
]
35+
}
36+
];
37+
338
@Component({
439
selector: 'demo-navigation',
540
templateUrl: './navigation.component.html',
641
styleUrls: ['./navigation.component.scss']
742
})
843
export class NavigationComponent implements OnInit {
44+
navigation = NAVIGATION;
45+
946
constructor() {}
1047

1148
ngOnInit() {}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { NgModule } from '@angular/core';
2+
import { Routes, RouterModule } from '@angular/router';
3+
4+
import { DocsComponent } from './docs.component';
5+
6+
const routes: Routes = [
7+
{
8+
path: '',
9+
redirectTo: 'getting-started',
10+
pathMatch: 'full'
11+
},
12+
{
13+
path: '',
14+
component: DocsComponent,
15+
children: [
16+
{
17+
path: 'getting-started',
18+
loadChildren: () =>
19+
import('./getting-started/getting-started.module').then(
20+
m => m.GettingStartedModule
21+
)
22+
},
23+
{
24+
path: 'mechanism',
25+
loadChildren: () =>
26+
import('./mechanism/mechanism.module').then(m => m.MechanismModule)
27+
}
28+
]
29+
}
30+
];
31+
32+
@NgModule({
33+
imports: [RouterModule.forChild(routes)],
34+
exports: [RouterModule]
35+
})
36+
export class DocsRoutingModule {}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h1>Documentation</h1>
2+
<router-outlet></router-outlet>

0 commit comments

Comments
 (0)