Skip to content

Commit 58ee1ec

Browse files
committed
feat(demo): add faq section, adjust how it works
1 parent a81cf09 commit 58ee1ec

24 files changed

+480
-312
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ const NAVIGATION = [
99
label: 'DOCS',
1010
url: 'docs',
1111
children: [
12-
{
13-
label: 'Motivation',
14-
url: 'docs/motivation'
15-
},
1612
{
1713
label: 'Getting started',
1814
url: 'docs/getting-started'
@@ -21,9 +17,17 @@ const NAVIGATION = [
2117
label: 'How it works',
2218
url: 'docs/how-it-works'
2319
},
20+
{
21+
label: 'Use cases',
22+
url: 'docs/use-cases'
23+
},
2424
{
2525
label: 'API',
2626
url: 'docs/api'
27+
},
28+
{
29+
label: 'FAQ',
30+
url: 'docs/faq'
2731
}
2832
]
2933
},

projects/elements-demo/src/app/features/contribute/contribute/contribute.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
aria-label="@angular-extensions/elements"
77
></mat-icon>
88
<h1>BECOME A CONTRIBUTOR</h1>
9-
<h3>Found bug or typo in docs?</h3>
9+
<h3>Missing a feature, found bug or typo in docs?</h3>
1010
</div>
1111
<br />
1212
<br />

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,13 @@ import { DocsComponent } from './docs.component';
66
const routes: Routes = [
77
{
88
path: '',
9-
redirectTo: 'motivation',
9+
redirectTo: 'how-it-works',
1010
pathMatch: 'full'
1111
},
1212
{
1313
path: '',
1414
component: DocsComponent,
1515
children: [
16-
{
17-
path: 'motivation',
18-
loadChildren: () =>
19-
import('./motivation/motivation.module').then(m => m.MotivationModule)
20-
},
2116
{
2217
path: 'getting-started',
2318
loadChildren: () =>
@@ -32,9 +27,18 @@ const routes: Routes = [
3227
m => m.HowItWorksModule
3328
)
3429
},
30+
{
31+
path: 'use-cases',
32+
loadChildren: () =>
33+
import('./use-cases/use-cases.module').then(m => m.UseCasesModule)
34+
},
3535
{
3636
path: 'api',
3737
loadChildren: () => import('./api/api.module').then(m => m.ApiModule)
38+
},
39+
{
40+
path: 'faq',
41+
loadChildren: () => import('./faq/faq.module').then(m => m.FaqModule)
3842
}
3943
]
4044
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { NgModule } from '@angular/core';
22
import { Routes, RouterModule } from '@angular/router';
33

4-
import { MotivationComponent } from './motivation.component';
4+
import { FaqComponent } from './faq.component';
55

6-
const routes: Routes = [{ path: '', component: MotivationComponent }];
6+
const routes: Routes = [{ path: '', component: FaqComponent }];
77

88
@NgModule({
99
imports: [RouterModule.forChild(routes)],
1010
exports: [RouterModule]
1111
})
12-
export class MotivationRoutingModule {}
12+
export class FaqRoutingModule {}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<div class="wrapper">
2+
<h1>Frequently asked questions</h1>
3+
4+
<mat-accordion>
5+
<mat-expansion-panel *ngFor="let item of faq">
6+
<mat-expansion-panel-header>
7+
<mat-panel-title [innerHTML]="item.question"></mat-panel-title>
8+
</mat-expansion-panel-header>
9+
<p [innerHTML]="item.answer"></p>
10+
</mat-expansion-panel>
11+
</mat-accordion>
12+
</div>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
h2 {
2+
margin: 40px 0 10px 0;
3+
font-weight: bold;
4+
}
5+
6+
:host-context(.responsive-large) {
7+
.wrapper {
8+
width: 70%;
9+
}
10+
}
11+
12+
.mat-expanded {
13+
p {
14+
margin-top: 25px;
15+
}
16+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@import '~@angular/material/theming';
2+
3+
@mixin demo-faq-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-faq {
11+
.mat-expanded {
12+
mat-expansion-panel-header {
13+
background-color: mat-color(
14+
$background,
15+
disabled-list-option
16+
) !important;
17+
}
18+
}
19+
}
20+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
3+
4+
import { SharedModule } from '../../../shared/shared.module';
5+
6+
import { FaqComponent } from './faq.component';
7+
8+
describe('FaqComponent', () => {
9+
let component: FaqComponent;
10+
let fixture: ComponentFixture<FaqComponent>;
11+
12+
beforeEach(async(() => {
13+
TestBed.configureTestingModule({
14+
imports: [NoopAnimationsModule, SharedModule],
15+
declarations: [FaqComponent]
16+
}).compileComponents();
17+
}));
18+
19+
beforeEach(() => {
20+
fixture = TestBed.createComponent(FaqComponent);
21+
component = fixture.componentInstance;
22+
fixture.detectChanges();
23+
});
24+
25+
it('should create', () => {
26+
expect(component).toBeTruthy();
27+
});
28+
});
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { Component, OnInit } from '@angular/core';
2+
3+
@Component({
4+
selector: 'demo-faq',
5+
templateUrl: './faq.component.html',
6+
styleUrls: ['./faq.component.scss']
7+
})
8+
export class FaqComponent implements OnInit {
9+
faq = FAQ;
10+
11+
constructor() {}
12+
13+
ngOnInit() {}
14+
}
15+
16+
const FAQ = [
17+
{
18+
question:
19+
'When does the <code>*axLazyElement</code> directive trigger download of the element bundle (or module)',
20+
answer:
21+
'The element loading will be postponed until it was rendered in the template of some component. This can happen in following cases... <br>' +
22+
`
23+
<ul>
24+
<li>Angular component uses element in its template</li>
25+
<li>
26+
Angular component uses element in its template conditionally
27+
(<code>*ngIf</code>, <code>*ngFor</code>, ...) and the condition was
28+
fulfilled
29+
</li>
30+
<li>
31+
User navigated to an Angular component which uses element in its template
32+
(can be both eagerly or lazily loaded routes)
33+
</li>
34+
</ul>
35+
`
36+
},
37+
{
38+
question:
39+
'What will happen if I use same element multiple times in single template?',
40+
answer:
41+
'The element bundle will be downloaded only once! The library takes care of this situation by maintaining registry of downloaded / downloading elements and every new occurence will be checked against that registry...'
42+
},
43+
{
44+
question:
45+
'When do we need to use <code>*axLazyElement="module: true"</code> flag?',
46+
answer:
47+
'Some web components libraries might be distributed using ES modules, for example if we look at <a href="https://unpkg.com/@material/mwc-button@0.6.0/mwc-button.js?module" target="_blank">@material/mwc-button</a> we will see that it imports additional things like <code>@material/mwc-base</code> using import statement in its implementation. This means it will need to download multiple files compared to a single bundle when using Angular elements. To make this work, library has to generate <code>\t&#60;script type="module"></code> instead of just plain <code>\t&#60;script></code> tag.'
48+
}
49+
];
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { NgModule } from '@angular/core';
2+
3+
import { SharedModule } from '../../../shared/shared.module';
4+
5+
import { FaqRoutingModule } from './faq-routing.module';
6+
import { FaqComponent } from './faq.component';
7+
8+
@NgModule({
9+
declarations: [FaqComponent],
10+
imports: [SharedModule, FaqRoutingModule]
11+
})
12+
export class FaqModule {}

0 commit comments

Comments
 (0)