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:
Alex
2026-04-22 17:26:57 -04:00
committed by Zach Yale
parent 61b9b53a60
commit 55a6343f65
110 changed files with 1688 additions and 1518 deletions
@@ -1,14 +1,78 @@
import {describe, it} from 'vitest';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { TestBed } from '@angular/core/testing';
import { AppConfigService } from './app-config.service';
// NOTE(frontend-seam): Real coverage here needs a theme-runtime seam around Prime theme tokens,
// localStorage hydration, DOM mutation, and browser-only effects so app state initialization can be
// asserted without changing runtime code.
describe.skip('AppConfigService', () => {
it('needs a browser storage and theme-token seam to validate state hydration and persistence effects', () => {
// Intentionally skipped until storage and theme runtime hooks are controllable in tests.
function createLocalStorageMock() {
const store = new Map<string, string>();
return {
getItem: (key: string) => store.get(key) ?? null,
setItem: (key: string, value: string) => {
store.set(key, value);
},
removeItem: (key: string) => {
store.delete(key);
},
clear: () => {
store.clear();
},
};
}
describe('AppConfigService', () => {
let service: AppConfigService;
let localStorageMock: ReturnType<typeof createLocalStorageMock>;
const rootStyle = document.documentElement.style;
beforeEach(() => {
localStorageMock = createLocalStorageMock();
vi.stubGlobal('localStorage', localStorageMock);
rootStyle.cssText = '';
TestBed.resetTestingModule();
TestBed.configureTestingModule({
providers: [AppConfigService],
});
service = TestBed.inject(AppConfigService);
});
it('needs a document mutation seam to validate theme updates without coupling the spec to runtime DOM side effects', () => {
// Intentionally skipped until DOM-side theme application can be driven deterministically.
afterEach(() => {
localStorageMock.clear();
rootStyle.cssText = '';
vi.unstubAllGlobals();
});
it('applies the default app-owned tokens on init', () => {
expect(rootStyle.getPropertyValue('--primary-color')).toBe('#4ade80');
expect(rootStyle.getPropertyValue('--ground-background')).toBe('#0d1012');
expect(rootStyle.getPropertyValue('--content-border-color')).toBe('#464f56');
});
it('updates app-owned tokens for custom palettes', () => {
service.appState.set({
preset: 'Aura',
primary: 'coralSunset',
surface: 'midnight-blue',
});
service.onPresetChange();
expect(rootStyle.getPropertyValue('--primary-color')).toBe('#f59673');
expect(rootStyle.getPropertyValue('--primary-color-rgb')).toBe('239, 117, 80');
expect(rootStyle.getPropertyValue('--ground-background')).toBe('#121518');
expect(rootStyle.getPropertyValue('--card-background')).toBe('#1f252c');
});
it('maps noir to the selected surface palette', () => {
service.appState.set({
preset: 'Aura',
primary: 'noir',
surface: 'charcoal',
});
service.onPresetChange();
expect(rootStyle.getPropertyValue('--primary-color')).toBe('#f0f0f0');
expect(rootStyle.getPropertyValue('--primary-contrast-color')).toBe('#141414');
expect(rootStyle.getPropertyValue('--primary-hover-color')).toBe('#d1d1d1');
});
});
@@ -1,7 +1,7 @@
import { DOCUMENT, isPlatformBrowser } from '@angular/common';
import { effect, inject, Injectable, PLATFORM_ID, signal } from '@angular/core';
import { $t } from '@primeuix/themes';
import Aura from '@primeuix/themes/aura';
import Aura from '../layout/theme-palette-extend';
import { AppState } from '../model/app-state.model';
type ColorPalette = Record<string, string>;
@@ -428,8 +428,72 @@ export class AppConfigService {
}
onPresetChange(): void {
if (!isPlatformBrowser(this.platformId)) {
return;
}
const surfacePalette = this.getSurfacePalette(this.appState().surface ?? 'neutral');
const preset = this.getPresetExt();
$t().preset(Aura).preset(preset).surfacePalette(surfacePalette).use({ useDefaultOptions: true });
this.applyDesignTokens();
}
private applyDesignTokens(): void {
const style = this.document.documentElement.style;
const primaryName = this.appState().primary ?? 'green';
const surfaceName = this.appState().surface ?? 'ash';
const surface = this.getSurfacePalette(surfaceName);
const primary = ((Aura.primitive ?? {}) as Record<string, ColorPalette>)[primaryName] ?? {};
const isNoir = primaryName === 'noir';
const primary400 = isNoir ? surface['50'] : primary['400'];
const primary500 = isNoir ? surface['50'] : (primary['500'] ?? primary['400']);
style.setProperty('--primary-color', primary400 ?? '#4ade80');
style.setProperty('--primary-color-rgb', this.toRgbChannels(primary500));
style.setProperty('--primary-contrast-color', isNoir ? (surface['950'] ?? '#0d1012') : (surface['900'] ?? '#1a1e21'));
style.setProperty('--primary-hover-color', isNoir ? (surface['200'] ?? '#d3d8de') : (primary['300'] ?? primary400 ?? '#86efac'));
style.setProperty('--primary-text-color', primary400 ?? '#4ade80');
style.setProperty('--primary-text-color-dark', isNoir ? (surface['950'] ?? '#0d1012') : (primary['900'] ?? '#14532d'));
style.setProperty('--ground-background', surface['950'] ?? '#0d1012');
style.setProperty('--overlay-background', surface['900'] ?? '#1a1e21');
style.setProperty('--card-background', surface['900'] ?? '#1a1e21');
style.setProperty('--content-background', surface['900'] ?? '#1a1e21');
style.setProperty('--code-background', surface['900'] ?? '#1a1e21');
style.setProperty('--border-color', surface['700'] ?? '#464f56');
style.setProperty('--content-border-color', surface['700'] ?? '#464f56');
style.setProperty('--text-color', surface['0'] ?? '#ffffff');
style.setProperty('--text-color-secondary', surface['300'] ?? '#b4bcc7');
style.setProperty('--text-secondary-color', surface['400'] ?? '#919ca9');
style.setProperty('--text-muted-color', surface['400'] ?? '#919ca9');
style.setProperty('--high-contrast-text-color', surface['0'] ?? '#ffffff');
Object.entries(surface).forEach(([stop, value]) => {
style.setProperty(`--surface-${stop}`, value);
});
}
private toRgbChannels(color: string | undefined): string {
if (!color) {
return '74, 222, 128';
}
const normalized = color.startsWith('#') ? color.slice(1) : color;
const hex = normalized.length === 3
? normalized.split('').map((char) => char + char).join('')
: normalized;
if (hex.length !== 6) {
return '74, 222, 128';
}
const value = Number.parseInt(hex, 16);
if (Number.isNaN(value)) {
return '74, 222, 128';
}
return `${(value >> 16) & 255}, ${(value >> 8) & 255}, ${value & 255}`;
}
}