refactor(ui): new standard and accessible UI font (#1777)

This commit is contained in:
Alex
2026-06-20 07:50:47 +01:00
committed by GitHub
parent 08ec10b4e7
commit 8ce487b9d0
26 changed files with 474 additions and 11 deletions
@@ -347,6 +347,7 @@
.rating-value {
font-weight: 600;
font-size: var(--app-text-sm);
font-variant-numeric: tabular-nums;
color: var(--color-text);
}
@@ -440,6 +441,7 @@
.metadata-value {
color: var(--color-text-secondary);
font-variant-numeric: tabular-nums;
overflow: hidden;
text-overflow: ellipsis;
}
@@ -773,6 +775,7 @@
.navigation-position {
font-size: var(--app-text-sm);
font-variant-numeric: tabular-nums;
color: var(--color-text-secondary);
}
@@ -830,6 +833,7 @@
font-size: 0.8313rem;
color: var(--color-text);
font-weight: 500;
font-variant-numeric: tabular-nums;
}
.comic-volume-number,
@@ -242,12 +242,12 @@ describe('UserService', () => {
httpTestingController.expectOne(req => req.url.endsWith('/api/v1/users/me')).flush(buildUser());
await flushCurrentUserQuery();
service.updateUserProfile(7, {locale: 'de', theme: 'custom', themeAccent: 'teal', themeSyncEnabled: true}).subscribe();
service.updateUserProfile(7, {locale: 'de', theme: 'custom', themeAccent: 'teal', themeSyncEnabled: true, uiFont: 'atkinson'}).subscribe();
const request = httpTestingController.expectOne(req => req.url.endsWith('/api/v1/users/7/profile'));
expect(request.request.method).toBe('PUT');
expect(request.request.body).toEqual({locale: 'de', theme: 'custom', themeAccent: 'teal', themeSyncEnabled: true});
request.flush(buildUser({locale: 'de', theme: 'custom', themeAccent: 'teal', themeSyncEnabled: true}));
expect(request.request.body).toEqual({locale: 'de', theme: 'custom', themeAccent: 'teal', themeSyncEnabled: true, uiFont: 'atkinson'});
request.flush(buildUser({locale: 'de', theme: 'custom', themeAccent: 'teal', themeSyncEnabled: true, uiFont: 'atkinson'}));
await flushCurrentUserQuery();
expect(service.currentUser()).toEqual(expect.objectContaining({
@@ -255,6 +255,7 @@ describe('UserService', () => {
theme: 'custom',
themeAccent: 'teal',
themeSyncEnabled: true,
uiFont: 'atkinson',
}));
});
});
@@ -9,6 +9,7 @@ import { DashboardConfig } from '../../dashboard/models/dashboard-config.model';
import { injectQuery, queryOptions, QueryClient } from '@tanstack/angular-query-experimental';
import { CURRENT_USER_QUERY_KEY } from './user-query-keys';
import { AppTheme, CustomPrimary } from '../../../shared/model/app-state.model';
import {DEFAULT_UI_FONT, normalizeUiFont, type UiFontPreference} from '../../../shared/model/ui-font.model';
export interface EntityViewPreferences {
global: EntityViewPreference;
@@ -324,6 +325,7 @@ export interface User {
theme: AppTheme;
themeAccent: CustomPrimary | null;
themeSyncEnabled: boolean;
uiFont?: UiFontPreference;
assignedLibraries: Library[];
permissions: {
admin: boolean;
@@ -382,6 +384,7 @@ export interface UserProfileUpdateRequest {
theme?: AppTheme;
themeAccent?: CustomPrimary | null;
themeSyncEnabled?: boolean;
uiFont?: UiFontPreference;
}
@Injectable({
@@ -535,6 +538,7 @@ export class UserService {
theme,
themeAccent: theme === 'custom' ? user.themeAccent ?? 'orange' : null,
themeSyncEnabled: user.themeSyncEnabled ?? true,
uiFont: normalizeUiFont(user.uiFont ?? DEFAULT_UI_FONT),
permissions: {
...permissions,
canBulkResetGrimmoryReadProgress: permissions.canBulkResetGrimmoryReadProgress ?? permissions.canBulkResetBookloreReadProgress,
@@ -108,6 +108,20 @@
</div>
</section>
<section class="w-full max-w-2xl rounded-md border-l-[3px] border-l-primary bg-[color-mix(in_srgb,var(--color-card)_35%,var(--color-page))] p-3.5 transition-[background,border-color] duration-200 hover:bg-[color-mix(in_srgb,var(--color-card)_20%,var(--color-page))] max-md:p-2.5">
<div class="mb-1">
<span class="text-sm font-medium text-text">{{ t('uiFont.label') }}</span>
</div>
<div class="mt-2.5 flex max-w-lg items-center gap-2.5 border-t border-dashed border-border pt-2.5">
<p-toggleswitch
inputId="interface-font"
[ngModel]="useAccessibleUiFont()"
(ngModelChange)="updateAccessibleUiFont($event)">
</p-toggleswitch>
<label class="text-sm font-medium text-text" for="interface-font">{{ t('uiFont.accessibleLabel') }}</label>
</div>
</section>
<section class="w-full max-w-2xl rounded-md border-l-[3px] border-l-primary bg-[color-mix(in_srgb,var(--color-card)_35%,var(--color-page))] p-3.5 transition-[background,border-color] duration-200 hover:bg-[color-mix(in_srgb,var(--color-card)_20%,var(--color-page))] max-md:p-2.5">
<div class="mb-1">
<label class="text-sm font-medium text-text" for="interface-language">{{ t('language.label') }}</label>
@@ -17,6 +17,8 @@ import type {AppearancePreference, AppTheme, CustomPrimary} from '../../../../sh
import {APPEARANCE_OPTIONS} from '../../../../shared/layout/theme/appearance-options';
import {UserService} from '../../user-management/user.service';
import type {User, UserProfileUpdateRequest} from '../../user-management/user.service';
import {AppUiFontService} from '../../../../shared/service/app-ui-font.service';
import {ACCESSIBLE_UI_FONT, DEFAULT_UI_FONT} from '../../../../shared/model/ui-font.model';
@Component({
selector: 'app-display-preferences',
@@ -34,6 +36,7 @@ import type {User, UserProfileUpdateRequest} from '../../user-management/user.se
export class DisplayPreferencesComponent {
private readonly themeService = inject(AppThemeService);
private readonly localeService = inject(AppLocaleService);
private readonly uiFontService = inject(AppUiFontService);
private readonly userService = inject(UserService);
private readonly messageService = inject(MessageService);
private readonly t = inject(TranslocoService);
@@ -51,6 +54,8 @@ export class DisplayPreferencesComponent {
label: LANG_LABELS[value] ?? value,
}));
protected readonly selectedAppearancePreference = this.themeService.appearancePreference;
protected readonly selectedUiFont = this.uiFontService.uiFont;
protected readonly useAccessibleUiFont = computed(() => this.selectedUiFont() === ACCESSIBLE_UI_FONT);
protected readonly selectedThemePreference = this.themeService.themePreference;
protected readonly oledDarkMode = this.themeService.oledDarkMode;
protected readonly showOledDarkModeToggle = computed(() => this.themeService.effectiveAppearance() === 'dark');
@@ -84,6 +89,21 @@ export class DisplayPreferencesComponent {
this.showSavedToast('settingsView.language.savedDetail');
}
protected async updateAccessibleUiFont(useAccessibleFont: boolean): Promise<void> {
const uiFont = useAccessibleFont ? ACCESSIBLE_UI_FONT : DEFAULT_UI_FONT;
if (uiFont === this.selectedUiFont()) return;
const previousUiFont = this.selectedUiFont();
this.uiFontService.applyUiFont(uiFont);
if (!await this.updateCurrentUserProfile({uiFont})) {
this.uiFontService.applyUiFont(previousUiFont);
return;
}
this.showSavedToast('settingsView.uiFont.savedDetail');
}
protected async updateThemePreference(themePreference: AppTheme): Promise<void> {
if (!this.selectedThemeSyncEnabled()) {
this.themeService.applyDeviceTheme(themePreference, this.selectedCustomPrimary());