feat(ui): OLED dark mode variant (#1560)
This commit is contained in:
+7
-1
@@ -1,4 +1,10 @@
|
||||
<div class="author-card" [class.selected]="isSelected" role="button" tabindex="0" (click)="onCardClick($event)" (keydown.enter)="onCardClick($event)">
|
||||
<div
|
||||
class="author-card surface-card-outline"
|
||||
[class.selected]="isSelected"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
(click)="onCardClick($event)"
|
||||
(keydown.enter)="onCardClick($event)">
|
||||
<div class="cover-container">
|
||||
@if (hasPhoto) {
|
||||
<img
|
||||
|
||||
@@ -108,7 +108,10 @@
|
||||
tooltipPosition="top">
|
||||
<i class="pi pi-cog"></i>
|
||||
</a>
|
||||
<p-popover #seriesCollapseOverlay [dismissable]="true" appendTo="body">
|
||||
<p-popover
|
||||
#seriesCollapseOverlay
|
||||
[dismissable]="true"
|
||||
appendTo="body">
|
||||
<div class="display-settings-popover">
|
||||
<div class="display-settings-section">
|
||||
<div class="display-settings-checkbox-row">
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
<div class="book-card"
|
||||
<div class="book-card surface-card-outline"
|
||||
[class.selected]="isSelected()"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
|
||||
@@ -142,7 +142,7 @@
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: color-mix(in srgb, var(--color-primary) 8%, transparent);
|
||||
background: var(--color-active-surface);
|
||||
color: var(--color-primary);
|
||||
|
||||
.command-palette-item-icon {
|
||||
|
||||
+11
@@ -42,6 +42,17 @@
|
||||
</p-select>
|
||||
</div>
|
||||
|
||||
@if (showOledDarkModeToggle()) {
|
||||
<div class="theme-toggle-row">
|
||||
<label class="field-label" for="oled-dark-mode">{{ 'settingsView.theme.oledDarkMode' | transloco }}</label>
|
||||
<p-toggleswitch
|
||||
inputId="oled-dark-mode"
|
||||
[ngModel]="oledDarkMode()"
|
||||
(ngModelChange)="configService.setOledDarkMode($event)">
|
||||
</p-toggleswitch>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="form-field">
|
||||
<label class="field-label" for="app-theme">{{ 'layout.theme.theme' | transloco }}</label>
|
||||
<p-select
|
||||
|
||||
+11
@@ -154,6 +154,17 @@ fieldset.form-field {
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.theme-toggle-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
|
||||
.field-label {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.edit-actions {
|
||||
margin-top: 0.5rem;
|
||||
|
||||
|
||||
+7
-5
@@ -3,6 +3,7 @@ import {Button} from 'primeng/button';
|
||||
import {AbstractControl, FormBuilder, FormGroup, FormsModule, ReactiveFormsModule, ValidationErrors, ValidatorFn, Validators} from '@angular/forms';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {Password} from 'primeng/password';
|
||||
import {ToggleSwitch} from 'primeng/toggleswitch';
|
||||
import {User, UserService, UserUpdateRequest} from '../user-management/user.service';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
@@ -17,8 +18,6 @@ import {
|
||||
AppTheme,
|
||||
CUSTOM_PRIMARY_OPTIONS,
|
||||
CustomPrimary,
|
||||
DEFAULT_APP_THEME,
|
||||
DEFAULT_CUSTOM_PRIMARY,
|
||||
} from '../../../shared/model/app-state.model';
|
||||
|
||||
export const passwordMatchValidator: ValidatorFn = (control: AbstractControl): ValidationErrors | null => {
|
||||
@@ -41,6 +40,7 @@ export const passwordMatchValidator: ValidatorFn = (control: AbstractControl): V
|
||||
InputText,
|
||||
Password,
|
||||
Select,
|
||||
ToggleSwitch,
|
||||
TranslocoDirective,
|
||||
TranslocoPipe,
|
||||
],
|
||||
@@ -66,10 +66,12 @@ export class UserProfileDialogComponent {
|
||||
private readonly t = inject(TranslocoService);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
protected readonly activeLang = toSignal(this.t.langChanges$, {initialValue: this.t.getActiveLang()});
|
||||
protected readonly selectedThemePreference = computed(() => this.configService.appState().themePreference ?? DEFAULT_APP_THEME);
|
||||
protected readonly selectedAppearancePreference = computed(() => this.configService.appState().appearancePreference ?? 'system');
|
||||
protected readonly selectedThemePreference = computed(() => this.configService.appState().themePreference);
|
||||
protected readonly selectedAppearancePreference = computed(() => this.configService.appState().appearancePreference);
|
||||
protected readonly oledDarkMode = computed(() => this.configService.appState().oledDarkMode);
|
||||
protected readonly showOledDarkModeToggle = computed(() => this.configService.effectiveAppearance() === 'dark');
|
||||
protected readonly selectedCustomPrimary = computed<CustomPrimary>(
|
||||
() => this.configService.appState().customPrimary ?? DEFAULT_CUSTOM_PRIMARY,
|
||||
() => this.configService.appState().customPrimary,
|
||||
);
|
||||
protected readonly customPrimaryOptions = CUSTOM_PRIMARY_OPTIONS;
|
||||
protected readonly themeOptions = computed(() => {
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
}
|
||||
|
||||
.sidebar-item-container.active-route-container {
|
||||
background-color: color-mix(in srgb, var(--color-primary) 8%, transparent);
|
||||
background-color: var(--color-active-surface);
|
||||
}
|
||||
|
||||
.sidebar-item-link {
|
||||
@@ -233,7 +233,7 @@ a.sidebar-item-link.active-route {
|
||||
}
|
||||
|
||||
.sidebar-item-container.active-route-container {
|
||||
background-color: color-mix(in srgb, var(--color-primary) 8%, transparent);
|
||||
background-color: var(--color-active-surface);
|
||||
}
|
||||
|
||||
.sidebar-item-container:has(:focus-visible) {
|
||||
|
||||
@@ -233,7 +233,7 @@
|
||||
|
||||
&.active-route {
|
||||
color: var(--color-primary-text);
|
||||
background-color: color-mix(in srgb, var(--color-primary) 8%, transparent);
|
||||
background-color: var(--color-active-surface);
|
||||
|
||||
.sidebar-footer-action-label {
|
||||
color: inherit;
|
||||
@@ -598,7 +598,7 @@
|
||||
}
|
||||
|
||||
&.active-route {
|
||||
background-color: color-mix(in srgb, var(--color-primary) 8%, transparent);
|
||||
background-color: var(--color-active-surface);
|
||||
color: var(--color-primary-text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,18 @@ const appHighlight = {
|
||||
focusColor: 'var(--color-primary-text)',
|
||||
};
|
||||
|
||||
const contentSurface = {
|
||||
background: 'var(--color-page)',
|
||||
borderColor: 'var(--color-border)',
|
||||
color: 'var(--color-text)',
|
||||
};
|
||||
|
||||
const overlaySurface = {
|
||||
background: 'var(--color-card)',
|
||||
borderColor: 'var(--color-border)',
|
||||
color: 'var(--color-text)',
|
||||
};
|
||||
|
||||
function buildAppTokenPalette(prefix: 'primary' | 'surface', stops: readonly string[]): ColorPalette {
|
||||
return Object.fromEntries(
|
||||
stops.map((stop) => [stop, `var(--color-${prefix}-${stop})`])
|
||||
@@ -87,10 +99,19 @@ function buildPrimePalettePreset(theme: ResolvedThemePalettes): object {
|
||||
const AppPrimePreset = definePreset(Aura, {
|
||||
semantic: {
|
||||
colorScheme: {
|
||||
light: { content: { background: 'var(--color-page)' } },
|
||||
light: {
|
||||
content: contentSurface,
|
||||
overlay: {
|
||||
popover: overlaySurface,
|
||||
modal: overlaySurface,
|
||||
},
|
||||
},
|
||||
dark: {
|
||||
content: { background: 'var(--color-page)' },
|
||||
// Card menus are surface.800; Aura default hover is also 800 — use app surface-hover mix.
|
||||
content: contentSurface,
|
||||
overlay: {
|
||||
popover: overlaySurface,
|
||||
modal: overlaySurface,
|
||||
},
|
||||
navigation: {
|
||||
item: {
|
||||
focusBackground: 'color-mix(in srgb, {text.color}, transparent 92%)',
|
||||
|
||||
@@ -1,32 +1,12 @@
|
||||
import {describe, expect, expectTypeOf, it} from 'vitest';
|
||||
import {describe, expect, it} from 'vitest';
|
||||
|
||||
import {
|
||||
APP_THEME_OPTIONS,
|
||||
AppearancePreference,
|
||||
AppState,
|
||||
AppTheme,
|
||||
CustomPrimary,
|
||||
DEFAULT_APP_THEME,
|
||||
THEME_REGISTRY,
|
||||
} from './app-state.model';
|
||||
|
||||
describe('app-state.model', () => {
|
||||
it('supports partially specified visual theme state', () => {
|
||||
const appState: AppState = {
|
||||
themePreference: DEFAULT_APP_THEME,
|
||||
appearancePreference: 'system',
|
||||
};
|
||||
|
||||
expect(appState.themePreference).toBe(DEFAULT_APP_THEME);
|
||||
expect(appState.appearancePreference).toBe('system');
|
||||
});
|
||||
|
||||
it('keeps each field optional and constrained to supported values', () => {
|
||||
expectTypeOf<AppState['themePreference']>().toEqualTypeOf<AppTheme | undefined>();
|
||||
expectTypeOf<AppState['appearancePreference']>().toEqualTypeOf<AppearancePreference | undefined>();
|
||||
expectTypeOf<AppState['customPrimary']>().toEqualTypeOf<CustomPrimary | undefined>();
|
||||
});
|
||||
|
||||
it('derives theme options from the registry', () => {
|
||||
expect(APP_THEME_OPTIONS).toBe(THEME_REGISTRY);
|
||||
expect(APP_THEME_OPTIONS.some(option => option.name === DEFAULT_APP_THEME)).toBe(true);
|
||||
|
||||
@@ -12,7 +12,8 @@ export {
|
||||
export type {AppTheme, CustomPrimary} from './theme-registry';
|
||||
|
||||
export interface AppState {
|
||||
themePreference?: AppTheme;
|
||||
appearancePreference?: AppearancePreference;
|
||||
customPrimary?: CustomPrimary;
|
||||
themePreference: AppTheme;
|
||||
appearancePreference: AppearancePreference;
|
||||
customPrimary: CustomPrimary;
|
||||
oledDarkMode: boolean;
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ describe('AppConfigService', () => {
|
||||
vi.spyOn(window, 'getComputedStyle').mockReturnValue(computedStyle);
|
||||
root.classList.remove('dark');
|
||||
delete root.dataset['appTheme'];
|
||||
delete root.dataset['oledDarkMode'];
|
||||
|
||||
TestBed.resetTestingModule();
|
||||
TestBed.configureTestingModule({
|
||||
@@ -84,6 +85,7 @@ describe('AppConfigService', () => {
|
||||
rootStyle.cssText = '';
|
||||
root.classList.remove('dark');
|
||||
delete root.dataset['appTheme'];
|
||||
delete root.dataset['oledDarkMode'];
|
||||
vi.restoreAllMocks();
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
@@ -93,6 +95,7 @@ describe('AppConfigService', () => {
|
||||
themePreference: 'grimmory',
|
||||
appearancePreference: 'system',
|
||||
customPrimary: 'orange',
|
||||
oledDarkMode: false,
|
||||
});
|
||||
expect(localStorageMock.getItem('appConfigState')).toBeNull();
|
||||
expect(root.dataset['appTheme']).toBe('grimmory');
|
||||
@@ -145,6 +148,7 @@ describe('AppConfigService', () => {
|
||||
themePreference: 'grimmory',
|
||||
appearancePreference: 'system',
|
||||
customPrimary: 'orange',
|
||||
oledDarkMode: false,
|
||||
});
|
||||
expect(root.dataset['appTheme']).toBe('grimmory');
|
||||
expect(root.classList.contains('dark')).toBe(false);
|
||||
@@ -152,6 +156,23 @@ describe('AppConfigService', () => {
|
||||
themePreference: 'grimmory',
|
||||
appearancePreference: 'system',
|
||||
customPrimary: 'orange',
|
||||
oledDarkMode: false,
|
||||
}));
|
||||
});
|
||||
|
||||
it('applies OLED mode only when the effective appearance is dark', () => {
|
||||
service.setOledDarkMode(true);
|
||||
|
||||
expect(root.dataset['oledDarkMode']).toBeUndefined();
|
||||
|
||||
service.setAppearancePreference('dark');
|
||||
|
||||
expect(root.classList.contains('dark')).toBe(true);
|
||||
expect(root.dataset['oledDarkMode']).toBe('true');
|
||||
|
||||
service.setAppearancePreference('light');
|
||||
|
||||
expect(root.classList.contains('dark')).toBe(false);
|
||||
expect(root.dataset['oledDarkMode']).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -22,6 +22,8 @@ type StoredAppState = Partial<AppState> & {
|
||||
surface?: unknown;
|
||||
};
|
||||
|
||||
type AppStatePatch = Partial<AppState>;
|
||||
|
||||
interface LoadedAppState {
|
||||
state: AppState;
|
||||
shouldPersist: boolean;
|
||||
@@ -33,8 +35,10 @@ interface LoadedAppState {
|
||||
export class AppConfigService {
|
||||
private readonly STORAGE_KEY = 'appConfigState';
|
||||
readonly themes = APP_THEME_OPTIONS;
|
||||
private readonly appStateSignal = signal<AppState>({});
|
||||
private readonly appStateSignal = signal<AppState>(this.withDefaults({}));
|
||||
private readonly effectiveAppearanceSignal = signal<'light' | 'dark'>('dark');
|
||||
readonly appState = this.appStateSignal.asReadonly();
|
||||
readonly effectiveAppearance = this.effectiveAppearanceSignal.asReadonly();
|
||||
document = inject(DOCUMENT);
|
||||
platformId = inject(PLATFORM_ID);
|
||||
faviconService = inject(FaviconService);
|
||||
@@ -61,7 +65,11 @@ export class AppConfigService {
|
||||
this.updateAppState({appearancePreference});
|
||||
}
|
||||
|
||||
private updateAppState(patch: AppState): void {
|
||||
setOledDarkMode(oledDarkMode: boolean): void {
|
||||
this.updateAppState({oledDarkMode});
|
||||
}
|
||||
|
||||
private updateAppState(patch: AppStatePatch): void {
|
||||
const state = this.withDefaults({
|
||||
...this.appStateSignal(),
|
||||
...patch,
|
||||
@@ -103,6 +111,7 @@ export class AppConfigService {
|
||||
themePreference: state.themePreference,
|
||||
appearancePreference: state.appearancePreference,
|
||||
customPrimary: state.customPrimary,
|
||||
oledDarkMode: state.oledDarkMode,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -110,22 +119,23 @@ export class AppConfigService {
|
||||
return 'preset' in state || 'primary' in state || 'surface' in state;
|
||||
}
|
||||
|
||||
private withDefaults(state: AppState): AppState {
|
||||
private withDefaults(state: AppStatePatch): AppState {
|
||||
return {
|
||||
themePreference: this.resolveThemePreference(state.themePreference),
|
||||
appearancePreference: this.resolveAppearancePreference(state.appearancePreference),
|
||||
customPrimary: this.resolveCustomPrimary(state.customPrimary),
|
||||
oledDarkMode: state.oledDarkMode === true,
|
||||
};
|
||||
}
|
||||
|
||||
private resolveCustomPrimary(customPrimary: AppState['customPrimary']): CustomPrimary {
|
||||
private resolveCustomPrimary(customPrimary: AppStatePatch['customPrimary']): CustomPrimary {
|
||||
if (customPrimary && CUSTOM_PRIMARY_OPTIONS.includes(customPrimary)) {
|
||||
return customPrimary;
|
||||
}
|
||||
return DEFAULT_CUSTOM_PRIMARY;
|
||||
}
|
||||
|
||||
private resolveThemePreference(themePreference: AppState['themePreference']): AppTheme {
|
||||
private resolveThemePreference(themePreference: AppStatePatch['themePreference']): AppTheme {
|
||||
if (themePreference && this.themes.some((option) => option.name === themePreference)) {
|
||||
return themePreference;
|
||||
}
|
||||
@@ -133,7 +143,7 @@ export class AppConfigService {
|
||||
return DEFAULT_APP_THEME;
|
||||
}
|
||||
|
||||
private resolveAppearancePreference(appearancePreference: AppState['appearancePreference']): AppearancePreference {
|
||||
private resolveAppearancePreference(appearancePreference: AppStatePatch['appearancePreference']): AppearancePreference {
|
||||
if (appearancePreference === 'light' || appearancePreference === 'dark' || appearancePreference === 'system') {
|
||||
return appearancePreference;
|
||||
}
|
||||
@@ -152,12 +162,12 @@ export class AppConfigService {
|
||||
|
||||
private saveAppState(state: AppState): void {
|
||||
if (isPlatformBrowser(this.platformId)) {
|
||||
localStorage.setItem(this.STORAGE_KEY, JSON.stringify(this.withDefaults(state)));
|
||||
localStorage.setItem(this.STORAGE_KEY, JSON.stringify(state));
|
||||
}
|
||||
}
|
||||
|
||||
applyCurrentTheme(): void {
|
||||
this.applyAppState(this.withDefaults(this.appStateSignal()));
|
||||
this.applyAppState(this.appStateSignal());
|
||||
}
|
||||
|
||||
private applyAppState(state: AppState): void {
|
||||
@@ -177,8 +187,14 @@ export class AppConfigService {
|
||||
const appearancePreference = this.resolveAppearancePreference(state.appearancePreference);
|
||||
const effective = this.effectiveAppearancePreference(appearancePreference);
|
||||
|
||||
this.effectiveAppearanceSignal.set(effective);
|
||||
root.dataset['appTheme'] = theme;
|
||||
root.classList.toggle('dark', effective === 'dark');
|
||||
if (state.oledDarkMode && effective === 'dark') {
|
||||
root.dataset['oledDarkMode'] = 'true';
|
||||
} else {
|
||||
delete root.dataset['oledDarkMode'];
|
||||
}
|
||||
root.style.setProperty('color-scheme', effective);
|
||||
this.applyCustomPrimary(root, theme, this.resolveCustomPrimary(state.customPrimary));
|
||||
this.syncSystemSchemeListener(appearancePreference);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
padding: 1.5rem 1.5rem 1.25rem;
|
||||
border-radius: 10px 10px 0 0;
|
||||
border: 1px solid var(--border-color);
|
||||
background: var(--color-card);
|
||||
box-shadow: 0 2px 6px rgb(0 0 0 / 8%);
|
||||
|
||||
.header-icon-wrapper {
|
||||
|
||||
@@ -112,6 +112,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
.p-dialog .p-dialog-header,
|
||||
.dialog-header {
|
||||
background: var(--color-page) !important;
|
||||
}
|
||||
|
||||
.dialog-xs.p-dialog {
|
||||
width: 90vw;
|
||||
max-width: 400px;
|
||||
|
||||
@@ -40,7 +40,9 @@
|
||||
--color-page: var(--color-surface-50);
|
||||
--color-card: var(--color-surface-0);
|
||||
--color-border: var(--color-surface-200);
|
||||
--color-card-outline: transparent;
|
||||
--color-surface-hover: color-mix(in srgb, var(--color-text) 8%, transparent);
|
||||
--color-active-surface: color-mix(in srgb, var(--color-primary) 8%, transparent);
|
||||
--color-text: var(--color-surface-950);
|
||||
--color-text-secondary: var(--color-surface-600);
|
||||
--color-text-muted: var(--color-surface-500);
|
||||
@@ -60,7 +62,9 @@
|
||||
--color-page: var(--color-surface-50);
|
||||
--color-card: var(--color-surface-0);
|
||||
--color-border: var(--color-surface-200);
|
||||
--color-card-outline: transparent;
|
||||
--color-surface-hover: color-mix(in srgb, var(--color-text) 8%, transparent);
|
||||
--color-active-surface: color-mix(in srgb, var(--color-primary) 8%, transparent);
|
||||
--color-text: var(--color-surface-950);
|
||||
--color-text-secondary: var(--color-surface-600);
|
||||
--color-text-muted: var(--color-surface-500);
|
||||
@@ -490,6 +494,15 @@
|
||||
--color-surface-950: var(--color-zinc-950);
|
||||
}
|
||||
|
||||
.dark[data-oled-dark-mode="true"] {
|
||||
--color-app: #000000;
|
||||
--color-page: #000000;
|
||||
--color-card: #000000;
|
||||
--color-border: color-mix(in srgb, var(--color-text) 18%, transparent);
|
||||
--color-card-outline: color-mix(in srgb, var(--color-text) 14%, transparent);
|
||||
--color-active-surface: color-mix(in srgb, var(--color-primary) 14%, transparent);
|
||||
}
|
||||
|
||||
@source inline("bg-{red,orange,amber,yellow,lime,green,emerald,teal,cyan,sky,blue,indigo,violet,purple,fuchsia,pink,rose}-{50,100,200,300,400,500,600,700,800,900,950}");
|
||||
|
||||
@source not "../embedpdf-frame.html";
|
||||
|
||||
@@ -30,6 +30,21 @@
|
||||
--control-bg: color-mix(in srgb, var(--color-surface-0) 6%, var(--color-card));
|
||||
|
||||
background: var(--color-card);
|
||||
box-shadow: inset 0 0 0 1px var(--color-card-outline);
|
||||
}
|
||||
|
||||
.surface-card-outline {
|
||||
position: relative;
|
||||
|
||||
&::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 5;
|
||||
border-radius: inherit;
|
||||
box-shadow: inset 0 0 0 1px var(--color-card-outline);
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
.gradient-divider {
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
},
|
||||
"theme": {
|
||||
"sectionTitle": "Display",
|
||||
"sectionDesc": "Pick your preferred app theme and appearance mode for this browser."
|
||||
"sectionDesc": "Pick your preferred app theme and appearance mode for this browser.",
|
||||
"oledDarkMode": "OLED dark mode"
|
||||
},
|
||||
"librarySort": {
|
||||
"sectionTitle": "Library and Shelf View & Sort Preferences",
|
||||
|
||||
Reference in New Issue
Block a user