Skip to content

Commit b49db16

Browse files
utshow-rehmanmmalerba
authored andcommitted
docs(docs-infra): refactor navigation code based on angular style guide (angular#64177)
PR Close angular#64177
1 parent 7eee93d commit b49db16

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

adev/src/app/core/layout/navigation/navigation.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@
6262
<nav
6363
class="adev-nav-primary docs-scroll-hide"
6464
[class.adev-nav-primary--open]="isMobileNavigationOpened()"
65-
[class.adev-nav-primary--rc]="currentDocsVersionMode === 'rc'"
66-
[class.adev-nav-primary--next]="currentDocsVersionMode === 'next'"
67-
[class.adev-nav-primary--deprecated]="currentDocsVersionMode === 'deprecated'"
65+
[class.adev-nav-primary--rc]="currentDocsVersionMode() === 'rc'"
66+
[class.adev-nav-primary--next]="currentDocsVersionMode() === 'next'"
67+
[class.adev-nav-primary--deprecated]="currentDocsVersionMode() === 'deprecated'"
6868
>
6969
<button
7070
type="button"

adev/src/app/core/layout/navigation/navigation.component.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ describe('Navigation', () => {
3030

3131
const fakeVersionManager = {
3232
currentDocsVersion: signal('v17'),
33+
currentDocsVersionMode: signal('stable'),
3334
versions: signal<Version[]>([]),
3435
};
3536

adev/src/app/core/layout/navigation/navigation.component.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ export class Navigation {
7878
readonly APPLE_SEARCH_LABEL = `⌘`;
7979
readonly DEFAULT_SEARCH_LABEL = `ctrl`;
8080

81-
activeRouteItem = this.navigationState.primaryActiveRouteItem;
82-
protected theme = this.themeManager.theme;
83-
protected openedMenu = signal<MenuType | null>(null);
81+
readonly activeRouteItem = this.navigationState.primaryActiveRouteItem;
82+
protected readonly theme = this.themeManager.theme;
83+
protected readonly openedMenu = signal<MenuType | null>(null);
8484

85-
protected currentDocsVersion = this.versionManager.currentDocsVersion;
86-
protected currentDocsVersionMode = this.versionManager.currentDocsVersionMode;
85+
protected readonly currentDocsVersion = this.versionManager.currentDocsVersion;
86+
protected readonly currentDocsVersionMode = this.versionManager.currentDocsVersionMode;
8787

8888
// Set the values of the search label and title only on the client, because the label is user-agent specific.
8989
protected searchLabel = this.isBrowser

adev/src/app/core/services/version-manager.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ type VersionJson = {version: string; url: string};
3636
export class VersionManager {
3737
private document = inject(DOCUMENT);
3838

39-
get currentDocsVersionMode(): VersionMode {
39+
readonly currentDocsVersionMode = computed<VersionMode>(() => {
4040
const hostname = this.document.location.hostname;
4141
if (hostname.startsWith('v')) return 'deprecated';
4242
if (hostname.startsWith('rc')) return 'rc';
4343
if (hostname.startsWith('next')) return 'next';
4444

4545
return 'stable';
46-
}
46+
});
4747

4848
private localVersions = (versionJson as VersionJson[]).map((v) => {
4949
return {

0 commit comments

Comments
 (0)