refactor(frontend): decouple app shell from PrimeNG layout system (#307)
* refactor(layout): decouple shell from PrimeNG * fix(frontend): review fixes for layout decoupling - Rewrite layout service spec to match new API surface - Remove dead ToastModule import from AppLayoutComponent - Add missing type="button" to profile and logout buttons - Add missing i18n keys to all non-English locales * chore(frontend): Layout shell consistency * chore(frontend): shell and routing improvements * chore(frontend): remove stray shimmer effect * chore(frontend): code cleanup * chore(ui): Fix navitem types consistency * chore(frontend): simplify layout structure + imports * chore(frontend): remove empty files * chore(frontend): Menu component cleanup * chore(frontend): remove nav translation layer * chore(frontend): revert stray artwork change * chore(frontend): revert author animation tweak * chore(frontend): review fixes * fix(frontend): restore topbar template after rebase conflict
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import { DOCUMENT } from '@angular/common';
|
||||
import { effect, inject, Injectable, signal } from '@angular/core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class LayoutService {
|
||||
private readonly document = inject(DOCUMENT);
|
||||
|
||||
readonly scale = signal(14);
|
||||
readonly sidebarOpen = signal(true);
|
||||
readonly mobileSidebarOpen = signal(false);
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
this.changeScale(this.scale());
|
||||
});
|
||||
}
|
||||
|
||||
onMenuToggle(): void {
|
||||
if (this.isDesktop()) {
|
||||
this.sidebarOpen.update((value) => !value);
|
||||
} else {
|
||||
this.mobileSidebarOpen.update((value) => !value);
|
||||
}
|
||||
}
|
||||
|
||||
closeMobileSidebar(): void {
|
||||
this.mobileSidebarOpen.set(false);
|
||||
}
|
||||
|
||||
isDesktop(): boolean {
|
||||
return (this.document.defaultView?.innerWidth ?? 992) > 991;
|
||||
}
|
||||
|
||||
private changeScale(value: number): void {
|
||||
this.document.documentElement.style.fontSize = `${value}px`;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user