Skip to content

Commit 2e0a374

Browse files
committed
feat(demo): improved the demo app + added ability to customize the component
1 parent 935ba53 commit 2e0a374

12 files changed

+315
-21
lines changed

angular.json

+7-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@
2929
],
3030
"styles": [
3131
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
32-
"src/styles.scss"
32+
"src/styles.scss",
33+
"./node_modules/prismjs/themes/prism-okaidia.css"
3334
],
34-
"scripts": []
35+
"scripts": [
36+
"./node_modules/prismjs/prism.js",
37+
"./node_modules/prismjs/components/prism-typescript.min.js"
38+
]
3539
},
3640
"configurations": {
3741
"production": {
@@ -222,4 +226,4 @@
222226
"cli": {
223227
"analytics": "7d642609-882d-4ec8-8f86-9bddc376febc"
224228
}
225-
}
229+
}

package-lock.json

+84-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"@nguniversal/express-engine": "^9.1.1",
3636
"angulartics2": "^9.1.0",
3737
"express": "^4.15.2",
38+
"ngx-markdown": "^9.1.1",
3839
"rxjs": "~6.5.4",
3940
"tslib": "^1.10.0",
4041
"zone.js": "~0.10.2"

src/app/app.component.html

+31-11
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
}
195195

196196
.terminal pre {
197-
font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;
197+
font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
198198
color: white;
199199
padding: 0 1rem 1rem;
200200
margin: 0;
@@ -238,17 +238,17 @@
238238
align-items: center;
239239
font-size: 12px;
240240
padding: 3px 10px;
241-
border: 1px solid rgba(27,31,35,.2);
241+
border: 1px solid rgba(27, 31, 35, .2);
242242
border-radius: 3px;
243-
background-image: linear-gradient(-180deg,#fafbfc,#eff3f6 90%);
243+
background-image: linear-gradient(-180deg, #fafbfc, #eff3f6 90%);
244244
margin-left: 4px;
245245
font-weight: 600;
246-
font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
246+
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;
247247
}
248248

249249
.github-star-badge:hover {
250-
background-image: linear-gradient(-180deg,#f0f3f6,#e6ebf1 90%);
251-
border-color: rgba(27,31,35,.35);
250+
background-image: linear-gradient(-180deg, #f0f3f6, #e6ebf1 90%);
251+
border-color: rgba(27, 31, 35, .35);
252252
background-position: -.5em;
253253
}
254254

@@ -270,7 +270,7 @@
270270
/* Responsive Styles */
271271
@media screen and (max-width: 767px) {
272272

273-
.card-container > *:not(.circle-link) ,
273+
.card-container > *:not(.circle-link),
274274
.terminal {
275275
width: 100%;
276276
}
@@ -428,9 +428,30 @@ <h2>Install</h2>
428428
</div>
429429

430430
<!-- Usage -->
431-
<h2>Usage</h2>
432-
433-
<mat-input-counter [min]="0"></mat-input-counter>
431+
<h2 style="margin-top: 2rem">Usage</h2>
432+
433+
<mat-toolbar color="primary">
434+
Usage
435+
<span fxFlex></span>
436+
<button mat-icon-button matTooltip="customize" (click)="openCustomizeDialog()">
437+
<mat-icon>edit</mat-icon>
438+
</button>
439+
</mat-toolbar>
440+
<mat-card>
441+
<mat-card-content>
442+
<form [formGroup]="formGroup">
443+
<mat-input-counter formControlName="inputCounter"
444+
[min]="+options.min"
445+
[max]="+options.max"
446+
[step]="+options.step"
447+
[label]="options.label"
448+
[placeholder]="options.placeholder">
449+
</mat-input-counter>
450+
</form>
451+
</mat-card-content>
452+
</mat-card>
453+
454+
<markdown src="assets/md/ex1.md"></markdown>
434455

435456
<!-- Next Steps -->
436457
<h2 style="margin-top: 4rem">Next Steps</h2>
@@ -605,5 +626,4 @@ <h2 style="margin-top: 4rem">Next Steps</h2>
605626
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
606627

607628

608-
609629
<router-outlet></router-outlet>

src/app/app.component.scss

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.mat-card{
2+
margin-top: 2rem;
3+
margin-bottom: 2rem;
4+
}

src/app/app.component.ts

+29-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,37 @@
1-
import { Component } from '@angular/core';
1+
import {Component, OnInit} from '@angular/core';
2+
import {MatDialog} from '@angular/material/dialog';
3+
import {CustomizeDialogComponent, InputCounterOptions} from './dialogs/customize-dialog/customize-dialog.component';
4+
import {FormControl, FormGroup} from '@angular/forms';
25

36
@Component({
47
selector: 'app-root',
58
templateUrl: './app.component.html',
69
styleUrls: ['./app.component.scss']
710
})
8-
export class AppComponent {
11+
export class AppComponent implements OnInit {
12+
13+
formGroup: FormGroup;
14+
915
title = 'input-counter';
16+
options: InputCounterOptions = {min: 0, max: 10, step: 1};
17+
18+
constructor(private dialog: MatDialog) {
19+
}
20+
21+
openCustomizeDialog() {
22+
this.dialog.open(CustomizeDialogComponent, {data: this.options}).afterClosed().subscribe(data => {
23+
if (data) {
24+
this.options = Object.assign(this.options, data);
25+
}
26+
});
27+
}
28+
29+
ngOnInit(): void {
30+
this.formGroup = new FormGroup({
31+
inputCounter: new FormControl()
32+
});
33+
34+
this.formGroup.get('inputCounter').valueChanges.subscribe(value => console.log('inout counter value: ', value));
35+
}
36+
1037
}

src/app/app.module.ts

+29-3
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,42 @@ import { AppRoutingModule } from './app-routing.module';
55
import { AppComponent } from './app.component';
66
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
77
import {MatInputCounterModule} from '@angular-material-extensions/input-counter';
8+
import {MatToolbarModule} from '@angular/material/toolbar';
9+
import {FlexModule} from '@angular/flex-layout';
10+
import {MatCardModule} from '@angular/material/card';
11+
import {MatIconModule} from '@angular/material/icon';
12+
import {MatButtonModule} from '@angular/material/button';
13+
import {MatTooltipModule} from '@angular/material/tooltip';
14+
import { CustomizeDialogComponent } from './dialogs/customize-dialog/customize-dialog.component';
15+
import {MatDialogModule} from '@angular/material/dialog';
16+
import {MatInputModule} from '@angular/material/input';
17+
import {ReactiveFormsModule} from '@angular/forms';
18+
import {Angulartics2Module} from 'angulartics2';
19+
import {MarkdownModule} from 'ngx-markdown';
20+
import {HttpClientModule} from '@angular/common/http';
821

922
@NgModule({
1023
declarations: [
11-
AppComponent
24+
AppComponent,
25+
CustomizeDialogComponent
1226
],
1327
imports: [
14-
BrowserModule.withServerTransition({ appId: 'serverApp' }),
28+
BrowserModule.withServerTransition({appId: 'serverApp'}),
29+
Angulartics2Module.forRoot(),
30+
MarkdownModule.forRoot(),
31+
HttpClientModule,
1532
AppRoutingModule,
1633
BrowserAnimationsModule,
17-
MatInputCounterModule
34+
MatInputCounterModule,
35+
MatToolbarModule,
36+
FlexModule,
37+
MatCardModule,
38+
MatIconModule,
39+
MatButtonModule,
40+
MatTooltipModule,
41+
MatDialogModule,
42+
MatInputModule,
43+
ReactiveFormsModule
1844
],
1945
providers: [],
2046
bootstrap: [AppComponent]

0 commit comments

Comments
 (0)