-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathheader.component.ts
More file actions
32 lines (28 loc) · 900 Bytes
/
header.component.ts
File metadata and controls
32 lines (28 loc) · 900 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import {
ChangeDetectionStrategy,
Component,
computed,
inject,
} from '@angular/core';
import { Button } from 'primeng/button';
import { Router, RouterLink } from '@angular/router';
import { toSignal } from '@angular/core/rxjs-interop';
import { map } from 'rxjs';
@Component({
standalone: true,
selector: 'osf-header',
imports: [Button, RouterLink],
templateUrl: './header.component.html',
styleUrl: './header.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class HeaderComponent {
#router = inject(Router);
#currentUrl = toSignal(this.#router.events.pipe(map(() => this.#router.url)));
protected readonly authButtonText = computed(() =>
this.#currentUrl()?.includes('sign-up') ? 'Sign In' : 'Sign Up',
);
protected readonly authButtonLink = computed(() =>
this.#currentUrl()?.includes('sign-up') ? '/login' : '/sign-up',
);
}