-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
150 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,26 @@ | ||
<asset-sg-app-bar> | ||
<ng-template [cdkPortalOutlet]="appPortalService.appBarPortalContent$ | push"></ng-template> | ||
</asset-sg-app-bar> | ||
<asset-sg-menu-bar /> | ||
<div class="router-outlet"> | ||
<router-outlet></router-outlet> | ||
</div> | ||
<div class="drawer-portal"> | ||
<ng-template [cdkPortalOutlet]="appPortalService.drawerPortalContent$ | push"></ng-template> | ||
</div> | ||
<ng-container *ngIf="errorService.onMessage | async as error; else content"> | ||
<asset-sg-app-bar /> | ||
<div class="error"> | ||
<span>{{error}}</span> | ||
<button asset-sg-warn (click)="authService.logOut()"> | ||
Logout | ||
</button> | ||
</div> | ||
</ng-container> | ||
|
||
<ng-template #content> | ||
<asset-sg-app-bar> | ||
<ng-template [cdkPortalOutlet]="appPortalService.appBarPortalContent$ | push"></ng-template> | ||
</asset-sg-app-bar> | ||
<asset-sg-menu-bar /> | ||
<div class="router-outlet"> | ||
<router-outlet></router-outlet> | ||
</div> | ||
<div class="drawer-portal"> | ||
<ng-template [cdkPortalOutlet]="appPortalService.drawerPortalContent$ | push"></ng-template> | ||
</div> | ||
</ng-template> | ||
|
||
<div class="alerts"> | ||
<ul app-alert-list></ul> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './lib/auth.module'; | ||
export * from './lib/services/auth.interceptor'; | ||
export * from './lib/services/auth.service'; | ||
export * from './lib/services/error.service'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { BehaviorSubject, Observable } from 'rxjs'; | ||
|
||
@Injectable() | ||
export class ErrorService { | ||
private message$ = new BehaviorSubject<string | null>(null); | ||
|
||
get onMessage(): Observable<string | null> { | ||
return this.message$.asObservable(); | ||
} | ||
|
||
updateMessage(message: string) { | ||
this.message$.next(message); | ||
} | ||
|
||
clear(): void { | ||
this.message$.next(null); | ||
} | ||
} |
144 changes: 72 additions & 72 deletions
144
libs/client-shared/src/lib/components/button/button.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,72 @@ | ||
import { FocusMonitor } from '@angular/cdk/a11y'; | ||
import { BooleanInput, coerceBooleanProperty } from '@angular/cdk/coercion'; | ||
import { | ||
AfterViewInit, | ||
ChangeDetectionStrategy, | ||
ChangeDetectorRef, | ||
Component, | ||
ElementRef, | ||
HostBinding, | ||
Input, | ||
OnDestroy, | ||
inject, | ||
} from '@angular/core'; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: | ||
// eslint-disable-next-line @angular-eslint/component-selector | ||
'button[asset-sg-reset], button[asset-sg-icon-button], button[asset-sg-primary], button[asset-sg-secondary], button[asset-sg-icon-button-tw]', | ||
template: '<ng-content></ng-content>', | ||
styleUrls: ['./button.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class ButtonComponent implements AfterViewInit, OnDestroy { | ||
protected _host = inject<ElementRef<HTMLElement>>(ElementRef); | ||
private _focusMonitor = inject(FocusMonitor); | ||
private _cd = inject(ChangeDetectorRef); | ||
|
||
constructor() { | ||
const observer = new MutationObserver(mutations => { | ||
mutations.forEach(mutation => { | ||
if (mutation.type === 'attributes') { | ||
if (this._host.nativeElement.attributes.getNamedItem('asset-sg-icon-button-tw')) { | ||
this._classes = 'bg-white'; | ||
this._cd.detectChanges(); | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
observer.observe(this._host.nativeElement, { | ||
attributes: true, //configure it to listen to attribute changes | ||
}); | ||
// console.log(this._host.nativeElement.attributes); | ||
} | ||
|
||
@HostBinding('class') | ||
private _classes: string | undefined; | ||
|
||
private _disabled: true | undefined; | ||
@HostBinding('[attr.disabled]') | ||
@HostBinding('[attr.aria-disabled]') | ||
@Input() | ||
get disabled(): true | false | undefined { | ||
return this._disabled; | ||
} | ||
set disabled(value: BooleanInput) { | ||
this._disabled = coerceBooleanProperty(value) || undefined; | ||
} | ||
|
||
@HostBinding('attr.type') | ||
@Input() | ||
public type = this._host.nativeElement.tagName === 'BUTTON' ? 'button' : undefined; | ||
|
||
ngAfterViewInit() { | ||
this._focusMonitor.monitor(this._host, false); | ||
} | ||
|
||
ngOnDestroy() { | ||
this._focusMonitor.stopMonitoring(this._host); | ||
} | ||
} | ||
import { FocusMonitor } from '@angular/cdk/a11y'; | ||
import { BooleanInput, coerceBooleanProperty } from '@angular/cdk/coercion'; | ||
import { | ||
AfterViewInit, | ||
ChangeDetectionStrategy, | ||
ChangeDetectorRef, | ||
Component, | ||
ElementRef, | ||
HostBinding, | ||
Input, | ||
OnDestroy, | ||
inject, | ||
} from '@angular/core'; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: | ||
// eslint-disable-next-line @angular-eslint/component-selector | ||
'button[asset-sg-reset], button[asset-sg-icon-button], button[asset-sg-primary], button[asset-sg-warn], button[asset-sg-secondary], button[asset-sg-icon-button-tw]', | ||
template: '<ng-content></ng-content>', | ||
styleUrls: ['./button.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class ButtonComponent implements AfterViewInit, OnDestroy { | ||
protected _host = inject<ElementRef<HTMLElement>>(ElementRef); | ||
private _focusMonitor = inject(FocusMonitor); | ||
private _cd = inject(ChangeDetectorRef); | ||
|
||
constructor() { | ||
const observer = new MutationObserver(mutations => { | ||
mutations.forEach(mutation => { | ||
if (mutation.type === 'attributes') { | ||
if (this._host.nativeElement.attributes.getNamedItem('asset-sg-icon-button-tw')) { | ||
this._classes = 'bg-white'; | ||
this._cd.detectChanges(); | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
observer.observe(this._host.nativeElement, { | ||
attributes: true, //configure it to listen to attribute changes | ||
}); | ||
// console.log(this._host.nativeElement.attributes); | ||
} | ||
|
||
@HostBinding('class') | ||
private _classes: string | undefined; | ||
|
||
private _disabled: true | undefined; | ||
@HostBinding('[attr.disabled]') | ||
@HostBinding('[attr.aria-disabled]') | ||
@Input() | ||
get disabled(): true | false | undefined { | ||
return this._disabled; | ||
} | ||
set disabled(value: BooleanInput) { | ||
this._disabled = coerceBooleanProperty(value) || undefined; | ||
} | ||
|
||
@HostBinding('attr.type') | ||
@Input() | ||
public type = this._host.nativeElement.tagName === 'BUTTON' ? 'button' : undefined; | ||
|
||
ngAfterViewInit() { | ||
this._focusMonitor.monitor(this._host, false); | ||
} | ||
|
||
ngOnDestroy() { | ||
this._focusMonitor.stopMonitoring(this._host); | ||
} | ||
} |