Skip to content

Commit d589734

Browse files
authored
docs: apply Angular’s recommended guidelines (#31908)
1 parent 5373ced commit d589734

File tree

8 files changed

+29
-29
lines changed

8 files changed

+29
-29
lines changed

docs/src/app/pages/component-category-list/component-category-list.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ import {ComponentPageTitle} from '../page-title/page-title';
2727
imports: [NavigationFocus, RouterLink, MatRipple],
2828
})
2929
export class ComponentCategoryList implements OnInit, OnDestroy {
30-
readonly _docItems = inject(DocumentationItems);
31-
private _componentPageTitle = inject(ComponentPageTitle);
32-
private _route = inject(ActivatedRoute);
30+
private readonly _docItems = inject(DocumentationItems);
31+
private readonly _componentPageTitle = inject(ComponentPageTitle);
32+
private readonly _route = inject(ActivatedRoute);
3333

3434
items: DocItem[] = [];
3535
section = '';

docs/src/app/pages/component-page-header/component-page-header.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import {Component, EventEmitter, Output} from '@angular/core';
9+
import {Component, output} from '@angular/core';
1010

1111
import {MatButton} from '@angular/material/button';
1212
import {MatIcon} from '@angular/material/icon';
@@ -18,5 +18,5 @@ import {MatIcon} from '@angular/material/icon';
1818
imports: [MatButton, MatIcon],
1919
})
2020
export class ComponentPageHeader {
21-
@Output() toggleSidenav = new EventEmitter<void>();
21+
readonly toggleSidenav = output<void>();
2222
}

docs/src/app/pages/guide-list/guide-list.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import {MatRipple} from '@angular/material/core';
2525
},
2626
})
2727
export class GuideList implements OnInit {
28-
guideItems = inject(GuideItems);
29-
_componentPageTitle = inject(ComponentPageTitle);
28+
readonly guideItems = inject(GuideItems);
29+
private readonly _componentPageTitle = inject(ComponentPageTitle);
3030

3131
ngOnInit(): void {
3232
this._componentPageTitle.title = 'Guides';

docs/src/app/pages/guide-viewer/guide-viewer.html

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<div class="docs-guide-wrapper">
22
<div class="docs-guide-toc-and-content">
3-
<doc-viewer class="docs-guide-content"
4-
(contentRendered)="toc.addHeaders('Guide Content', $event); toc.updateScrollPosition()"
5-
[document]="guide?.document"
6-
focusOnNavigation
7-
id="guide-content"
8-
aria-label="Guide content" />
3+
<doc-viewer
4+
class="docs-guide-content"
5+
(contentRendered)="toc.addHeaders('Guide Content', $event); toc.updateScrollPosition()"
6+
[document]="guide()?.document"
7+
focusOnNavigation
8+
id="guide-content"
9+
aria-label="Guide content"
10+
/>
911
<table-of-contents #toc container="guide-viewer" />
1012
</div>
1113
</div>

docs/src/app/pages/guide-viewer/guide-viewer.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ describe('GuideViewer', () => {
3636
it('should set the guide based off route params', () => {
3737
const component = fixture.componentInstance;
3838
fixture.detectChanges();
39-
expect(component.guide).toEqual(component.guideItems.getItemById(guideItemsId));
39+
expect(component.guide()).toEqual(component.guideItems.getItemById(guideItemsId));
4040
});
4141
});

docs/src/app/pages/guide-viewer/guide-viewer.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import {Component, OnInit, inject} from '@angular/core';
9+
import {Component, OnInit, inject, signal} from '@angular/core';
1010
import {ActivatedRoute, Router} from '@angular/router';
1111
import {GuideItem, GuideItems} from '../../shared/guide-items/guide-items';
1212
import {Footer} from '../../shared/footer/footer';
@@ -26,11 +26,11 @@ import {DocViewer} from '../../shared/doc-viewer/doc-viewer';
2626
},
2727
})
2828
export class GuideViewer implements OnInit {
29-
private _componentPageTitle = inject(ComponentPageTitle);
30-
private _router = inject(Router);
29+
private readonly _componentPageTitle = inject(ComponentPageTitle);
30+
private readonly _router = inject(Router);
3131
guideItems = inject(GuideItems);
3232

33-
guide: GuideItem | undefined;
33+
guide = signal<GuideItem | undefined>(undefined);
3434

3535
constructor() {
3636
const _route = inject(ActivatedRoute);
@@ -39,18 +39,18 @@ export class GuideViewer implements OnInit {
3939
_route.params.subscribe(p => {
4040
const guideItem = guideItems.getItemById(p['id']);
4141
if (guideItem) {
42-
this.guide = guideItem;
42+
this.guide.set(guideItem);
4343
}
4444

45-
if (!this.guide) {
45+
if (!this.guide()) {
4646
this._router.navigate(['/guides']);
4747
}
4848
});
4949
}
5050

5151
ngOnInit(): void {
52-
if (this.guide !== undefined) {
53-
this._componentPageTitle.title = this.guide.name;
52+
if (this.guide() !== undefined) {
53+
this._componentPageTitle.title = this.guide()!.name;
5454
}
5555
}
5656
}

docs/src/app/pages/homepage/homepage.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ <h2>Featured components</h2>
5353
</a>
5454
</div>
5555
<app-carousel [aria-label]="'Featured components'">
56-
@for (comp of getTopComponents(); track comp) {
56+
@for (comp of topComponents; track comp) {
5757
<a carousel-item class="docs-carousel-item docs-featured-components-carousel-item"
5858
routerLink="/components/{{comp}}">
5959
<div class="docs-homepage-img-container">

docs/src/app/pages/homepage/homepage.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,12 @@ const TOP_COMPONENTS = ['datepicker', 'input', 'slide-toggle', 'slider', 'button
5050
},
5151
})
5252
export class Homepage implements OnInit {
53-
_componentPageTitle = inject(ComponentPageTitle);
54-
guideItems = inject(GuideItems);
53+
private readonly _componentPageTitle = inject(ComponentPageTitle);
54+
protected readonly guideItems = inject(GuideItems);
55+
56+
protected readonly topComponents = TOP_COMPONENTS;
5557

5658
ngOnInit(): void {
5759
this._componentPageTitle.title = '';
5860
}
59-
60-
getTopComponents(): string[] {
61-
return TOP_COMPONENTS;
62-
}
6361
}

0 commit comments

Comments
 (0)