Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Angular Material for v17 #134

Merged
merged 11 commits into from
Dec 4, 2023
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
browser: chrome
start: npm start
install: false
wait-on: 'http://[::1]:4200'
wait-on: http://[::1]:4200
42 changes: 16 additions & 26 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ export class EditComponent implements OnInit, OnDestroy {

async gotoList() {
if (this.person) {
await this.router.navigate(['/search', {term: this.person.name} ]);
await this.router.navigate(['/search', {term: this.person.name}]);
} else {
await this.router.navigate(['/search']);
}
Expand Down Expand Up @@ -1539,37 +1539,27 @@ ng add @angular/material

When prompted for the theme, pick the one you prefer, using the links to preview them. Accept the defaults for the other questions.

Add the relevant Material modules as imports in `app.module.ts`:
Change your HTML templates to use Material components. For example, change `<h1>` in `app.component.html` to be `<mat-toolbar>`.

[source,javascript]
.src/app/app.module.ts
[source,html]
.src/app/app.component.html
----
import { MatButtonModule } from '@angular/material/button';
import { MatListModule } from '@angular/material/list';
import { MatInputModule } from '@angular/material/input';
import { MatIconModule } from '@angular/material/icon';
import { MatToolbarModule } from '@angular/material/toolbar';

@NgModule({
...
imports: [
...
MatButtonModule,
MatIconModule,
MatInputModule,
MatListModule,
MatToolbarModule
],
...
})
<mat-toolbar>Welcome to {{ title }}!</mat-toolbar>
----

Change HTML templates to use Material components. For example, change `<h1>` in `app.component.html` to be `<mat-toolbar>`.
You'll need to import the `MatToolbarModule` in `app.component.ts` for it to compile.

[source,html]
.src/app/app.component.html
[source,typescript]
----
<mat-toolbar>Welcome to {{ title }}!</mat-toolbar>
import { MatToolbarModule } from '@angular/material/toolbar';

@Component({
selector: 'app-root',
standalone: true,
imports: [CommonModule, RouterOutlet, MatToolbarModule],
templateUrl: './app.component.html',
styleUrl: './app.component.css'
})
----

After modifying your templates to match this branch, the edit screen will look as follows.
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/edit.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('Edit', () => {
cy.get('#name').type(' Rocks!');
cy.get('#save').click();
// verify one element matched this change
const list = cy.get('app-search mat-list mat-list-item');
const list = cy.get('app-search mat-list-item');
list.should('have.length', 1);
});
});
2 changes: 1 addition & 1 deletion cypress/e2e/search.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Search', () => {
it('should allow searching', () => {
cy.get('input').type('A');
cy.get('button').click();
const list = cy.get('app-search mat-list mat-list-item');
const list = cy.get('app-search mat-list-item');
list.should('have.length', 3);
});
});
Loading