Skip to content

Commit 0825be1

Browse files
authored
Merge pull request #289 from Cordobo/claude/update-material-angular-21-018S3EvhYqgy27j5tV8VfB4F
feat: update demo app for Angular Material 21 compatibility
2 parents a9d9df7 + b6851ff commit 0825be1

File tree

2 files changed

+40
-32
lines changed

2 files changed

+40
-32
lines changed

projects/demo-app/src/app/app.html

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -79,22 +79,20 @@ <h4>Installation</h4>
7979
></qrcode>
8080
</div>
8181
<div class="downloadButton">
82-
<button
83-
*ngIf="this.elementType !== 'svg'"
84-
mat-raised-button
85-
color="primary"
86-
(click)="saveAsImage(parent)"
87-
>
88-
Download QR Code Image
89-
</button>
90-
<a
91-
*ngIf="this.elementType === 'svg'"
92-
mat-raised-button
93-
color="primary"
94-
[href]="qrCodeSrc"
95-
download="angularx-qrcode"
96-
>Download QR Code Image</a
97-
>
82+
@if (this.elementType !== 'svg') {
83+
<button mat-raised-button color="primary" (click)="saveAsImage(parent)">
84+
Download QR Code Image
85+
</button>
86+
}
87+
@if (this.elementType === 'svg') {
88+
<a
89+
mat-raised-button
90+
color="primary"
91+
[href]="qrCodeSrc"
92+
download="angularx-qrcode"
93+
>Download QR Code Image</a
94+
>
95+
}
9896
</div>
9997
</mat-card-content>
10098

@@ -288,9 +286,9 @@ <h4>Get started with angularx-qrcode:</h4>
288286
[(ngModel)]="width"
289287
selected="width"
290288
>
291-
<mat-button-toggle *ngFor="let o of widthList" [value]="o.val">{{
292-
o.title
293-
}}</mat-button-toggle>
289+
@for (o of widthList; track o.val) {
290+
<mat-button-toggle [value]="o.val">{{ o.title }}</mat-button-toggle>
291+
}
294292
</mat-button-toggle-group>
295293
</div>
296294
</section>
@@ -304,9 +302,9 @@ <h4>Get started with angularx-qrcode:</h4>
304302
[(ngModel)]="margin"
305303
selected="margin"
306304
>
307-
<mat-button-toggle *ngFor="let o of marginList" [value]="o.val">{{
308-
o.title
309-
}}</mat-button-toggle>
305+
@for (o of marginList; track o.val) {
306+
<mat-button-toggle [value]="o.val">{{ o.title }}</mat-button-toggle>
307+
}
310308
</mat-button-toggle-group>
311309
</div>
312310
</section>
@@ -320,9 +318,9 @@ <h4>Get started with angularx-qrcode:</h4>
320318
[(ngModel)]="scale"
321319
selected="scale"
322320
>
323-
<mat-button-toggle *ngFor="let o of scaleList" [value]="o.val">{{
324-
o.title
325-
}}</mat-button-toggle>
321+
@for (o of scaleList; track o.val) {
322+
<mat-button-toggle [value]="o.val">{{ o.title }}</mat-button-toggle>
323+
}
326324
</mat-button-toggle-group>
327325
</div>
328326
</section>
@@ -343,7 +341,8 @@ <h4>Get started with angularx-qrcode:</h4>
343341
</mat-slide-toggle>
344342
<br />
345343
<br />
346-
<section *ngIf="showImage">
344+
@if (showImage) {
345+
<section>
347346
<div class="example-label-container">
348347
<label id="example-name-label" class="example-name-label">Width/Height: </label>
349348
<label class="example-value-label">{{ imageWidth }}/{{ imageHeight }}</label>
@@ -393,6 +392,7 @@ <h4>Get started with angularx-qrcode:</h4>
393392
/>
394393
</mat-form-field>
395394
</section>
395+
}
396396
</mat-card-content>
397397

398398
<mat-divider></mat-divider>
@@ -407,7 +407,8 @@ <h4>Get started with angularx-qrcode:</h4>
407407
</mat-slide-toggle>
408408
<br />
409409
<br />
410-
<section *ngIf="showColors">
410+
@if (showColors) {
411+
<section>
411412
<div class="button-label">Foreground:</div>
412413
<div class="button-row">
413414
<button
@@ -437,7 +438,7 @@ <h4>Get started with angularx-qrcode:</h4>
437438
</div>
438439
</section>
439440

440-
<section *ngIf="showColors">
441+
<section>
441442
<div class="button-label">Background:</div>
442443
<div class="button-row">
443444
<button
@@ -467,6 +468,7 @@ <h4>Get started with angularx-qrcode:</h4>
467468
</mat-button-toggle-group>
468469
</div>
469470
</section>
471+
}
470472
</mat-card-content>
471473

472474
<mat-divider></mat-divider>
@@ -480,7 +482,8 @@ <h4>Get started with angularx-qrcode:</h4>
480482
>Include CSS styling for the qrcode directive
481483
</mat-slide-toggle>
482484

483-
<section *ngIf="showCss">
485+
@if (showCss) {
486+
<section>
484487
<mat-radio-group
485488
aria-label="Select an option"
486489
[(ngModel)]="cssClass"
@@ -498,6 +501,7 @@ <h4>Get started with angularx-qrcode:</h4>
498501
</mat-radio-button>
499502
</mat-radio-group>
500503
</section>
504+
}
501505
</mat-card-content>
502506

503507
<mat-divider></mat-divider>
@@ -513,7 +517,8 @@ <h4>Get started with angularx-qrcode:</h4>
513517
<br />
514518
<br />
515519

516-
<section *ngIf="showA11y">
520+
@if (showA11y) {
521+
<section>
517522
<form class="form-full-width">
518523
<mat-form-field class="input-full-width" appearance="fill">
519524
<mat-label>alt Attribute</mat-label>
@@ -540,6 +545,7 @@ <h4>Get started with angularx-qrcode:</h4>
540545
</form>
541546
<br />
542547
</section>
548+
}
543549
</mat-card-content>
544550
</mat-card>
545551
</div>

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { CommonModule } from '@angular/common'
2-
import { Component } from '@angular/core'
2+
import { Component, inject } from '@angular/core'
33
import { FormsModule, FormControl } from '@angular/forms'
44
import { MatSnackBarModule, MatSnackBar } from '@angular/material/snack-bar'
55
import { SafeUrl } from '@angular/platform-browser'
@@ -55,6 +55,8 @@ type ListType = { title: string; val: number }[]
5555
styleUrls: ['./app.css'],
5656
})
5757
export class App {
58+
private _snackBar = inject(MatSnackBar)
59+
5860
public initial_state = {
5961
allowEmptyString: true,
6062
alt: 'A custom alt attribute',
@@ -107,7 +109,7 @@ export class App {
107109
public showCss: boolean
108110
public showImage: boolean
109111

110-
constructor(private _snackBar: MatSnackBar) {
112+
constructor() {
111113
this.showA11y = true
112114
this.showColors = true
113115
this.showCss = true

0 commit comments

Comments
 (0)