diff --git a/examples/chat/angular/src/app/shell/demo-shell.component.html b/examples/chat/angular/src/app/shell/demo-shell.component.html index 7c859e96..0aa685f4 100644 --- a/examples/chat/angular/src/app/shell/demo-shell.component.html +++ b/examples/chat/angular/src/app/shell/demo-shell.component.html @@ -88,6 +88,11 @@ /> + { + const scheme = this.colorScheme(); + const html = this.document.documentElement; + html.setAttribute('data-color-scheme', scheme); + html.setAttribute('data-ngaf-chat-theme', scheme); + const currentTheme = this.theme(); + if (currentTheme === 'default-dark' || currentTheme === 'default-light') { + const next = scheme === 'light' ? 'default-light' : 'default-dark'; + if (currentTheme !== next) { + this.theme.set(next); + this.persistence.write('theme', next); + } + } + }); + // Refresh threads list whenever the active thread changes (e.g. after // create or switch) so the panel stays up to date. The effect also // covers the initial load (fires synchronously on first reactive read). @@ -152,6 +174,15 @@ export class DemoShell { */ readonly theme = signal(this.persistence.read('theme') ?? 'default-dark'); + /** + * App-wide color scheme. Single source of truth for the demo page bg, + * the chat lib's internal `data-ngaf-chat-theme`, and (when the A2UI + * theme is on a default preset) the base A2UI theme. Persisted. + */ + readonly colorScheme = signal<'light' | 'dark'>( + (this.persistence.read('colorScheme') as 'light' | 'dark' | null) ?? 'dark', + ); + /** Whether the threads drawer is open. Persisted across reloads. */ protected readonly drawerOpen = signal(this.persistence.read('drawerOpen') ?? false); @@ -228,6 +259,11 @@ export class DemoShell { { value: 'json-render', label: 'json-render' }, ]); + protected readonly colorSchemeOptions = [ + { value: 'light', label: 'Light' }, + { value: 'dark', label: 'Dark' }, + ] as const; + protected readonly themeOptions = signal([ { value: 'default-dark', label: 'Default dark' }, { value: 'default-light', label: 'Default light' }, @@ -347,6 +383,12 @@ export class DemoShell { this.persistence.write('theme', next); } + protected onColorSchemeChange(next: 'light' | 'dark' | string): void { + if (next !== 'light' && next !== 'dark') return; + this.colorScheme.set(next); + this.persistence.write('colorScheme', next); + } + protected onSidenavOpenChange(next: boolean): void { this.drawerOpen.set(next); this.persistence.write('drawerOpen', next); diff --git a/examples/chat/angular/src/app/shell/palette-persistence.service.ts b/examples/chat/angular/src/app/shell/palette-persistence.service.ts index 6bf77235..7d0c3e72 100644 --- a/examples/chat/angular/src/app/shell/palette-persistence.service.ts +++ b/examples/chat/angular/src/app/shell/palette-persistence.service.ts @@ -12,6 +12,7 @@ interface PaletteState { drawerOpen?: boolean | null; sidenavMode?: 'expanded' | 'collapsed' | null; selectedProjectId?: string | null; + colorScheme?: 'light' | 'dark' | null; } type PaletteKey = keyof PaletteState; diff --git a/examples/chat/angular/src/index.html b/examples/chat/angular/src/index.html index 30b61a4c..3f5c006e 100644 --- a/examples/chat/angular/src/index.html +++ b/examples/chat/angular/src/index.html @@ -1,10 +1,31 @@ - + NGAF chat — canonical demo + diff --git a/examples/chat/angular/src/styles.css b/examples/chat/angular/src/styles.css index 3c08dd26..bbd50c91 100644 --- a/examples/chat/angular/src/styles.css +++ b/examples/chat/angular/src/styles.css @@ -11,8 +11,24 @@ html, body { padding: 0; height: 100%; font-family: system-ui, -apple-system, sans-serif; - background: #0f1116; - color: #e6e9ef; + background: var(--demo-page-bg); + color: var(--demo-page-text); +} + +/* + * Demo page color scheme — driven by `data-color-scheme` on . + * The pre-bootstrap inline script in index.html sets the attribute + * from persisted state before any stylesheet applies; the runtime + * effect in DemoShell keeps it in sync afterwards. Default (no + * attribute) is dark to match prior behavior. + */ +html { + --demo-page-bg: #0f1116; + --demo-page-text: #e6e9ef; +} +html[data-color-scheme="light"] { + --demo-page-bg: #ffffff; + --demo-page-text: #1c1c1c; } /*