Skip to content

Commit

Permalink
build: switch development apps to new control flow
Browse files Browse the repository at this point in the history
Switches the dev and e2e apps to use the new control flow.
  • Loading branch information
crisbeto committed Nov 6, 2023
1 parent 3caea0f commit f3f0fb8
Show file tree
Hide file tree
Showing 35 changed files with 988 additions and 755 deletions.
62 changes: 35 additions & 27 deletions src/dev-app/autocomplete/autocomplete-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
[hideSingleSelectionIndicator]="reactiveHideSingleSelectionIndicator"
[autoActiveFirstOption]="reactiveAutoActiveFirstOption"
[requireSelection]="reactiveRequireSelection">
<mat-option *ngFor="let state of reactiveStates; let index = index" [value]="state"
[disabled]="reactiveIsStateDisabled(state.index)">
<span>{{ state.name }}</span>
<span class="demo-secondary-text"> ({{ state.code }}) </span>
</mat-option>
@for (state of reactiveStates; track state; let index = $index) {
<mat-option [value]="state" [disabled]="reactiveIsStateDisabled(state.index)">
<span>{{ state.name }}</span>
<span class="demo-secondary-text"> ({{ state.code }}) </span>
</mat-option>
}
</mat-autocomplete>

<p>
Expand Down Expand Up @@ -66,21 +67,25 @@
<div>Template-driven value (currentState): {{ currentState }}</div>
<div>Template-driven dirty: {{ modelDir ? modelDir.dirty : false }}</div>

<!-- Added an ngIf below to test that autocomplete works with ngIf -->
<mat-form-field *ngIf="true" [color]="templateStatesTheme">
<mat-label>State</mat-label>
<input matInput [matAutocomplete]="tdAuto" [(ngModel)]="currentState"
(ngModelChange)="tdStates = filterStates(currentState)" [disabled]="tdDisabled">
<mat-autocomplete #tdAuto="matAutocomplete"
[hideSingleSelectionIndicator]="templateHideSingleSelectionIndicator"
[autoActiveFirstOption]="templateAutoActiveFirstOption"
[requireSelection]="templateRequireSelection">
<mat-option *ngFor="let state of tdStates" [value]="state.name"
[disabled]="templateIsStateDisabled(state.index)">
<span>{{ state.name }}</span>
</mat-option>
</mat-autocomplete>
</mat-form-field>
<!-- Added an @if below to test that autocomplete works with @if -->
@if (true) {
<mat-form-field [color]="templateStatesTheme">
<mat-label>State</mat-label>
<input matInput [matAutocomplete]="tdAuto" [(ngModel)]="currentState"
(ngModelChange)="tdStates = filterStates(currentState)" [disabled]="tdDisabled">
<mat-autocomplete #tdAuto="matAutocomplete"
[hideSingleSelectionIndicator]="templateHideSingleSelectionIndicator"
[autoActiveFirstOption]="templateAutoActiveFirstOption"
[requireSelection]="templateRequireSelection">
@for (state of tdStates; track state) {
<mat-option [value]="state.name"
[disabled]="templateIsStateDisabled(state.index)">
<span>{{ state.name }}</span>
</mat-option>
}
</mat-autocomplete>
</mat-form-field>
}

<p>
<button mat-button (click)="clearTemplateState()">RESET</button>
Expand All @@ -89,9 +94,9 @@
TOGGLE DISABLED
</button>
<select [(ngModel)]="templateStatesTheme">
<option *ngFor="let theme of availableThemes" [value]="theme.value">
{{theme.name}}
</option>
@for (theme of availableThemes; track theme) {
<option [value]="theme.value">{{theme.name}}</option>
}
</select>
</p>
<p>
Expand Down Expand Up @@ -141,8 +146,11 @@
</div>

<mat-autocomplete #groupedAuto="matAutocomplete">
<mat-optgroup *ngFor="let group of filteredGroupedStates"
[label]="'States starting with ' + group.letter">
<mat-option *ngFor="let state of group.states" [value]="state.name">{{ state.name }}</mat-option>
</mat-optgroup>
@for (group of filteredGroupedStates; track group) {
<mat-optgroup [label]="'States starting with ' + group.letter">
@for (state of group.states; track state) {
<mat-option [value]="state.name">{{ state.name }}</mat-option>
}
</mat-optgroup>
}
</mat-autocomplete>
6 changes: 3 additions & 3 deletions src/dev-app/autocomplete/autocomplete-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ export class AutocompleteDemo {
<mat-label>T-Shirt Size</mat-label>
<input matInput [matAutocomplete]="tdAuto" [(ngModel)]="currentSize" name="size">
<mat-autocomplete #tdAuto="matAutocomplete">
<mat-option *ngFor="let size of sizes" [value]="size">
{{size}}
</mat-option>
@for (size of sizes; track size) {
<mat-option [value]="size">{{size}}</mat-option>
}
</mat-autocomplete>
</mat-form-field>
Expand Down
6 changes: 3 additions & 3 deletions src/dev-app/badge/badge-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ <h3>Size</h3>

<div class="demo-badge">
<h3>Text</h3>
<span [matBadge]="badgeContent" matBadgeOverlap="false" *ngIf="visible">
Hello
</span>
@if (visible) {
<span [matBadge]="badgeContent" matBadgeOverlap="false">Hello</span>
}

<span matBadge="11111" matBadgeOverlap="false">
Hello
Expand Down
12 changes: 7 additions & 5 deletions src/dev-app/bottom-sheet/bottom-sheet-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ <h2>Options</h2>

<ng-template let-bottomSheetRef="bottomSheetRef">
<mat-nav-list>
<mat-list-item (click)="bottomSheetRef.dismiss()" *ngFor="let action of [1, 2, 3]">
<mat-icon matListItemIcon>folder</mat-icon>
<span matListItemTitle>Action {{ action }}</span>
<span matLine>Description</span>
</mat-list-item>
@for (action of [1, 2, 3]; track action) {
<mat-list-item (click)="bottomSheetRef.dismiss()">
<mat-icon matListItemIcon>folder</mat-icon>
<span matListItemTitle>Action {{ action }}</span>
<span matLine>Description</span>
</mat-list-item>
}
</mat-nav-list>
</ng-template>
10 changes: 6 additions & 4 deletions src/dev-app/bottom-sheet/bottom-sheet-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ export class BottomSheetDemo {
@Component({
template: `
<mat-nav-list>
<a href="#" mat-list-item (click)="handleClick($event)" *ngFor="let action of [1, 2, 3]">
<span matListItemTitle>Action {{ action }}</span>
<span matListItemLine>Description</span>
</a>
@for (action of [1, 2, 3]; track action) {
<a href="#" mat-list-item (click)="handleClick($event)">
<span matListItemTitle>Action {{ action }}</span>
<span matListItemLine>Description</span>
</a>
}
</mat-nav-list>
`,
standalone: true,
Expand Down
6 changes: 3 additions & 3 deletions src/dev-app/button-toggle/button-toggle-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ <h1>Single Toggle</h1>
<h1>Dynamic Exclusive Selection</h1>
<section>
<mat-button-toggle-group name="pies" [(ngModel)]="favoritePie" [vertical]="isVertical">
<mat-button-toggle *ngFor="let pie of pieOptions" [value]="pie">
{{pie}}
</mat-button-toggle>
@for (pie of pieOptions; track pie) {
<mat-button-toggle [value]="pie">{{pie}}</mat-button-toggle>
}
</mat-button-toggle-group>
<p>Your favorite type of pie is: {{favoritePie}}</p>
</section>
36 changes: 16 additions & 20 deletions src/dev-app/cdk-menu/cdk-menu-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -145,48 +145,44 @@ <h3>Radio items</h3>

<ng-template #sizeMenu>
<div class="example-menu" cdkMenu>
<button
*ngFor="let size of sizes"
@for (size of sizes; track size) {
<button
cdkMenuItemRadio
[cdkMenuItemChecked]="selectedSize === size"
(cdkMenuItemTriggered)="selectedSize = size">
{{size}}
</button>
(cdkMenuItemTriggered)="selectedSize = size">{{size}}</button>
}
</div>
</ng-template>

<ng-template #colorMenu>
<div class="example-menu" cdkMenu>
<div cdkMenuGroup>
<button
*ngFor="let color of colors"
@for (color of colors; track color) {
<button
cdkMenuItemRadio
[cdkMenuItemChecked]="selectedColor === color"
(cdkMenuItemTriggered)="selectedColor = color">
{{color}}
</button>
(cdkMenuItemTriggered)="selectedColor = color">{{color}}</button>
}
</div>
</div>
</ng-template>

<ng-template #sizeAndColorMenu>
<div class="example-menu" cdkMenu>
<button
*ngFor="let size of sizes"
@for (size of sizes; track size) {
<button
cdkMenuItemRadio
[cdkMenuItemChecked]="selectedSize === size"
(cdkMenuItemTriggered)="selectedSize = size">
{{size}}
</button>
(cdkMenuItemTriggered)="selectedSize = size">{{size}}</button>
}
<hr />
<div cdkMenuGroup>
<button
*ngFor="let color of colors"
@for (color of colors; track color) {
<button
cdkMenuItemRadio
[cdkMenuItemChecked]="selectedColor === color"
(cdkMenuItemTriggered)="selectedColor = color">
{{color}}
</button>
(cdkMenuItemTriggered)="selectedColor = color">{{color}}</button>
}
</div>
</div>
</ng-template>
Expand Down
32 changes: 24 additions & 8 deletions src/dev-app/checkbox/checkbox-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ <h5>Click action: check-indeterminate</h5>
[indeterminate]="demoIndeterminate"
(change)="demoChecked = $event.checked"
(indeterminateChange)="demoIndeterminate = $event">
<ng-container *ngIf="!demoHideLabel">Checkbox w/ [checked] & (change)</ng-container>
@if (!demoHideLabel) {
Checkbox w/ [checked] & (change)
}
</mat-checkbox>
<mat-checkbox
[required]="demoRequired"
Expand All @@ -167,7 +169,9 @@ <h5>Click action: check-indeterminate</h5>
[indeterminate]="demoIndeterminate"
[(ngModel)]="demoChecked"
(indeterminateChange)="demoIndeterminate = $event">
<ng-container *ngIf="!demoHideLabel">Checkbox w/ [(ngModel)]</ng-container>
@if (!demoHideLabel) {
Checkbox w/ [(ngModel)]
}
</mat-checkbox>
</div>
<div clickActionCheck>
Expand All @@ -187,7 +191,9 @@ <h5>Click action: check</h5>
[indeterminate]="demoIndeterminate"
(change)="demoChecked = $event.checked"
(indeterminateChange)="demoIndeterminate = $event">
<ng-container *ngIf="!demoHideLabel">Checkbox w/ [checked] & (change)</ng-container>
@if (!demoHideLabel) {
Checkbox w/ [checked] & (change)
}
</mat-checkbox>
<mat-checkbox
[required]="demoRequired"
Expand All @@ -203,7 +209,9 @@ <h5>Click action: check</h5>
[indeterminate]="demoIndeterminate"
[(ngModel)]="demoChecked"
(indeterminateChange)="demoIndeterminate = $event">
<ng-container *ngIf="!demoHideLabel">Checkbox w/ [(ngModel)]</ng-container>
@if (!demoHideLabel) {
Checkbox w/ [(ngModel)]
}
</mat-checkbox>
</div>
<div clickActionNoop>
Expand All @@ -223,7 +231,9 @@ <h5>Click action: noop</h5>
[indeterminate]="demoIndeterminate"
(change)="demoChecked = $event.checked"
(indeterminateChange)="demoIndeterminate = $event">
<ng-container *ngIf="!demoHideLabel">Checkbox w/ [checked] & (change)</ng-container>
@if (!demoHideLabel) {
Checkbox w/ [checked] & (change)
}
</mat-checkbox>
<mat-checkbox
[required]="demoRequired"
Expand All @@ -239,7 +249,9 @@ <h5>Click action: noop</h5>
[indeterminate]="demoIndeterminate"
[(ngModel)]="demoChecked"
(indeterminateChange)="demoIndeterminate = $event">
<ng-container *ngIf="!demoHideLabel">Checkbox w/ [(ngModel)]</ng-container>
@if (!demoHideLabel) {
Checkbox w/ [(ngModel)]
}
</mat-checkbox>
</div>
<div animationsNoop>
Expand All @@ -259,7 +271,9 @@ <h5>No animations</h5>
[indeterminate]="demoIndeterminate"
(change)="demoChecked = $event.checked"
(indeterminateChange)="demoIndeterminate = $event">
<ng-container *ngIf="!demoHideLabel">Checkbox w/ [checked] & (change)</ng-container>
@if (!demoHideLabel) {
Checkbox w/ [checked] & (change)
}
</mat-checkbox>
<mat-checkbox
[required]="demoRequired"
Expand All @@ -275,7 +289,9 @@ <h5>No animations</h5>
[indeterminate]="demoIndeterminate"
[(ngModel)]="demoChecked"
(indeterminateChange)="demoIndeterminate = $event">
<ng-container *ngIf="!demoHideLabel">Checkbox w/ [(ngModel)]</ng-container>
@if (!demoHideLabel) {
Checkbox w/ [(ngModel)]
}
</mat-checkbox>
</div>
</div>
Expand Down
35 changes: 20 additions & 15 deletions src/dev-app/checkbox/nested-checklist.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
<h2>Tasks</h2>
<ul>
<li *ngFor="let task of tasks">
<mat-checkbox [(ngModel)]="task.completed"
[checked]="allComplete(task)"
[indeterminate]="someComplete(task.subtasks)"
(change)="setAllCompleted(task.subtasks, $event.checked)">
<h3>{{task.name}}</h3>
</mat-checkbox>
<ul>
<li *ngFor="let subtask of task.subtasks">
<mat-checkbox [(ngModel)]="subtask.completed">
{{subtask.name}}
</mat-checkbox>
</li>
</ul>
</li>
@for (task of tasks; track task) {
<li>
<mat-checkbox
[(ngModel)]="task.completed"
[checked]="allComplete(task)"
[indeterminate]="someComplete(task.subtasks)"
(change)="setAllCompleted(task.subtasks, $event.checked)">
<h3>{{task.name}}</h3>
</mat-checkbox>
<ul>
@for (subtask of task.subtasks; track subtask) {
<li>
<mat-checkbox [(ngModel)]="subtask.completed">
{{subtask.name}}
</mat-checkbox>
</li>
}
</ul>
</li>
}
</ul>
Loading

0 comments on commit f3f0fb8

Please sign in to comment.