Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
<mat-sidenav-container class="sidenav-container">
<mat-sidenav #drawer class="sidenav" fixedInViewport
[attr.role]="(isHandset$ | async) ? 'dialog' : 'navigation'"
[mode]="(isHandset$ | async) ? 'over' : 'side'"
[opened]="(isHandset$ | async) === false">
<mat-toolbar>Menu</mat-toolbar>
[attr.role]="(isHandset()) ? 'dialog' : 'navigation'"
[mode]="(isHandset()) ? 'over' : 'side'"
[opened]="!(isHandset())">
<mat-toolbar>
<span>Menu</span>
</mat-toolbar>
<mat-nav-list>
<a mat-list-item <%= routing ? 'routerLink="/"' : 'href="#"' %>>Link 1</a>
<a mat-list-item <%= routing ? 'routerLink="/"' : 'href="#"' %>>Link 2</a>
<a mat-list-item <%= routing ? 'routerLink="/"' : 'href="#"' %>>Link 3</a>
<a mat-list-item <%= routing ? 'routerLink="/"' : 'href="#"' %> (click)="drawer.close()">Link 1</a>
<a mat-list-item <%= routing ? 'routerLink="/"' : 'href="#"' %> (click)="drawer.close()">Link 2</a>
<a mat-list-item <%= routing ? 'routerLink="/"' : 'href="#"' %> (click)="drawer.close()">Link 3</a>
</mat-nav-list>
</mat-sidenav>
<mat-sidenav-content>
<mat-toolbar color="primary">
@if (isHandset$ | async) {
<mat-toolbar class="mat-elevation-z4">
@if (isHandset()) {
<button
type="button"
aria-label="Toggle sidenav"
Expand All @@ -21,7 +23,7 @@
<mat-icon aria-label="Side nav toggle icon">menu</mat-icon>
</button>
}
<span><%= project %></span>
<span class="toolbar-title"><%= project %></span>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Class does not exist.

</mat-toolbar>
<!-- Add Content Here -->
</mat-sidenav-content>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { Component, inject<% if(!!viewEncapsulation) { %>, ViewEncapsulation<% }%><% if(changeDetection !== 'Default') { %>, ChangeDetectionStrategy<% }%> } from '@angular/core';
import { Component, inject, signal, computed<% if(!!viewEncapsulation) { %>, ViewEncapsulation<% }%><% if(changeDetection !== 'Default') { %>, ChangeDetectionStrategy<% }%> } from '@angular/core';
import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';<% if(standalone) { %>
import { AsyncPipe } from '@angular/common';
import { NgIf } from '@angular/common';
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatButtonModule } from '@angular/material/button';
import { MatSidenavModule } from '@angular/material/sidenav';
import { MatListModule } from '@angular/material/list';
import { MatIconModule } from '@angular/material/icon';<% } %>
import { Observable } from 'rxjs';
import { map, shareReplay } from 'rxjs/operators';

@Component({
selector: '<%= selector %>',<% if(inlineTemplate) { %>
Expand All @@ -27,16 +25,17 @@ import { map, shareReplay } from 'rxjs/operators';
MatSidenavModule,
MatListModule,
MatIconModule,
AsyncPipe,
NgIf,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for an import

]<% } else { %>,
standalone: false<% } %>
})
export class <%= classify(name) %>Component {
private breakpointObserver = inject(BreakpointObserver);
protected isHandset = signal(false);

isHandset$: Observable<boolean> = this.breakpointObserver.observe(Breakpoints.Handset)
.pipe(
map(result => result.matches),
shareReplay()
);
constructor() {
this.breakpointObserver.observe(Breakpoints.Handset).subscribe(result => {

@michael-small michael-small Jun 12, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A subscription in a constructor to imperatively set the value is a step down. The original isHandset$ assignment can be wrapped in a toSignal and be sufficient.

this.isHandset.set(result.matches);
});
}
}
Loading