chore(ui): move theme/language preferences into user profile (#1243)
This commit is contained in:
+65
@@ -22,6 +22,71 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-container">
|
<div class="form-container">
|
||||||
|
<div class="form-section preferences-section">
|
||||||
|
<h3 class="section-title">
|
||||||
|
<i class="pi pi-language" aria-hidden="true"></i>
|
||||||
|
{{ 'settingsView.language.sectionTitle' | transloco }}
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<p-select
|
||||||
|
size="small"
|
||||||
|
[options]="languageOptions"
|
||||||
|
[ngModel]="activeLang()"
|
||||||
|
(ngModelChange)="onLanguageChange($event)"
|
||||||
|
optionLabel="label"
|
||||||
|
optionValue="value"
|
||||||
|
appendTo="body"
|
||||||
|
class="language-select">
|
||||||
|
</p-select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="gradient-divider"></div>
|
||||||
|
|
||||||
|
<div class="form-section preferences-section">
|
||||||
|
<div class="preference-group">
|
||||||
|
<h3 class="section-title">
|
||||||
|
<i class="pi pi-palette" aria-hidden="true"></i>
|
||||||
|
{{ 'settingsView.theme.sectionTitle' | transloco }}
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<div class="theme-row">
|
||||||
|
<span class="theme-row-label">{{ 'layout.theme.primary' | transloco }}</span>
|
||||||
|
<div class="color-swatches">
|
||||||
|
@for (primaryColor of primaryColors; track primaryColor.name) {
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
[title]="primaryColor.name"
|
||||||
|
[attr.aria-label]="primaryColor.name"
|
||||||
|
[attr.aria-pressed]="primaryColor.name === selectedPrimaryColor()"
|
||||||
|
(click)="updateThemeColor($event, 'primary', primaryColor)"
|
||||||
|
[ngClass]="{ 'active-color': primaryColor.name === selectedPrimaryColor() }"
|
||||||
|
[style]="{ 'background-color': primaryColor.name === 'noir' ? 'var(--text-color)' : primaryColor.palette['500'] || 'transparent' }">
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="theme-row">
|
||||||
|
<span class="theme-row-label">{{ 'layout.theme.surface' | transloco }}</span>
|
||||||
|
<div class="color-swatches">
|
||||||
|
@for (surface of surfaces; track surface.name) {
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
[title]="surface.name"
|
||||||
|
[attr.aria-label]="surface.name"
|
||||||
|
[attr.aria-pressed]="selectedSurfaceColor() ? selectedSurfaceColor() === surface.name : surface.name === 'zinc'"
|
||||||
|
(click)="updateThemeColor($event, 'surface', surface)"
|
||||||
|
[ngClass]="{ 'active-color': selectedSurfaceColor() ? selectedSurfaceColor() === surface.name : surface.name === 'zinc' }"
|
||||||
|
[style]="{ 'background-color': surface.name === 'noir' ? 'var(--text-color)' : surface.palette['500'] }">
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="gradient-divider"></div>
|
||||||
|
|
||||||
<div class="form-section">
|
<div class="form-section">
|
||||||
<h3 class="section-title">
|
<h3 class="section-title">
|
||||||
<i class="pi pi-id-card"></i>
|
<i class="pi pi-id-card"></i>
|
||||||
|
|||||||
+68
-4
@@ -1,4 +1,5 @@
|
|||||||
@use '../../../shared/styles/panel-shared' as panel;
|
@use '../../../shared/styles/panel-shared' as panel;
|
||||||
|
@use '../../../../assets/layout/styles/layout/variables';
|
||||||
|
|
||||||
.user-profile-dialog {
|
.user-profile-dialog {
|
||||||
min-width: 300px;
|
min-width: 300px;
|
||||||
@@ -33,7 +34,7 @@
|
|||||||
max-height: 60vh;
|
max-height: 60vh;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
|
||||||
@media (width <= 480px) {
|
@media #{variables.$mobile-shell-media-query} {
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
gap: 1.25rem;
|
gap: 1.25rem;
|
||||||
}
|
}
|
||||||
@@ -66,6 +67,62 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.preferences-section {
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.language-select {
|
||||||
|
width: 11rem;
|
||||||
|
max-width: 100%;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preference-group {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-row {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.625rem;
|
||||||
|
padding: 0.75rem;
|
||||||
|
background: var(--ground-background);
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: inset 0 0 0 1px var(--border-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-row-label {
|
||||||
|
color: var(--text-color-secondary);
|
||||||
|
font-size: var(--text-sm);
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color-swatches {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 0.375rem;
|
||||||
|
min-width: 0;
|
||||||
|
|
||||||
|
button {
|
||||||
|
width: 1.5rem;
|
||||||
|
height: 1.5rem;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 50%;
|
||||||
|
cursor: pointer;
|
||||||
|
outline: transparent solid 2px;
|
||||||
|
outline-offset: 1px;
|
||||||
|
|
||||||
|
&:focus-visible,
|
||||||
|
&.active-color {
|
||||||
|
outline-color: var(--primary-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.form-field {
|
.form-field {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -80,10 +137,11 @@
|
|||||||
.field-input {
|
.field-input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
&:disabled {
|
&.p-inputtext:disabled {
|
||||||
background-color: var(--surface-100);
|
background: color-mix(in srgb, var(--ground-background) 50%, var(--p-surface-800) 50%) !important;
|
||||||
color: var(--text-color-secondary);
|
color: var(--text-color-secondary);
|
||||||
opacity: 0.6;
|
-webkit-text-fill-color: var(--text-color-secondary);
|
||||||
|
opacity: 1;
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -155,3 +213,9 @@
|
|||||||
color: var(--text-secondary-color);
|
color: var(--text-secondary-color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media #{variables.$mobile-shell-media-query} {
|
||||||
|
.language-select {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+66
-2
@@ -1,4 +1,5 @@
|
|||||||
import {Component, effect, inject} from '@angular/core';
|
import {NgClass} from '@angular/common';
|
||||||
|
import {Component, DestroyRef, computed, effect, inject} from '@angular/core';
|
||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {AbstractControl, FormBuilder, FormGroup, FormsModule, ReactiveFormsModule, ValidationErrors, ValidatorFn, Validators} from '@angular/forms';
|
import {AbstractControl, FormBuilder, FormGroup, FormsModule, ReactiveFormsModule, ValidationErrors, ValidatorFn, Validators} from '@angular/forms';
|
||||||
import {InputText} from 'primeng/inputtext';
|
import {InputText} from 'primeng/inputtext';
|
||||||
@@ -7,6 +8,19 @@ import {User, UserService, UserUpdateRequest} from '../user-management/user.serv
|
|||||||
import {MessageService} from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||||
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
||||||
|
import {Select} from 'primeng/select';
|
||||||
|
import {takeUntilDestroyed, toSignal} from '@angular/core/rxjs-interop';
|
||||||
|
import {AVAILABLE_LANGS, LANG_LABELS} from '../../../core/config/transloco-loader';
|
||||||
|
import {LANG_STORAGE_KEY} from '../../../core/config/language-initializer';
|
||||||
|
import {AppConfigService} from '../../../shared/service/app-config.service';
|
||||||
|
import Aura from '../../../shared/layout/theme-palette-extend';
|
||||||
|
|
||||||
|
type ColorPalette = Record<string, string>;
|
||||||
|
|
||||||
|
interface Palette {
|
||||||
|
name: string;
|
||||||
|
palette: ColorPalette;
|
||||||
|
}
|
||||||
|
|
||||||
export const passwordMatchValidator: ValidatorFn = (control: AbstractControl): ValidationErrors | null => {
|
export const passwordMatchValidator: ValidatorFn = (control: AbstractControl): ValidationErrors | null => {
|
||||||
const newPassword = control.get('newPassword');
|
const newPassword = control.get('newPassword');
|
||||||
@@ -27,8 +41,10 @@ export const passwordMatchValidator: ValidatorFn = (control: AbstractControl): V
|
|||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
InputText,
|
InputText,
|
||||||
Password,
|
Password,
|
||||||
|
Select,
|
||||||
|
NgClass,
|
||||||
TranslocoDirective,
|
TranslocoDirective,
|
||||||
TranslocoPipe
|
TranslocoPipe,
|
||||||
],
|
],
|
||||||
templateUrl: './user-profile-dialog.component.html',
|
templateUrl: './user-profile-dialog.component.html',
|
||||||
styleUrls: ['./user-profile-dialog.component.scss']
|
styleUrls: ['./user-profile-dialog.component.scss']
|
||||||
@@ -39,12 +55,23 @@ export class UserProfileDialogComponent {
|
|||||||
currentUser: User | null = null;
|
currentUser: User | null = null;
|
||||||
editUserData: Partial<User> = {};
|
editUserData: Partial<User> = {};
|
||||||
changePasswordForm: FormGroup;
|
changePasswordForm: FormGroup;
|
||||||
|
readonly languageOptions = AVAILABLE_LANGS.map(value => ({
|
||||||
|
value,
|
||||||
|
label: LANG_LABELS[value] ?? value,
|
||||||
|
}));
|
||||||
|
|
||||||
protected readonly userService = inject(UserService);
|
protected readonly userService = inject(UserService);
|
||||||
|
protected readonly configService = inject(AppConfigService);
|
||||||
private readonly messageService = inject(MessageService);
|
private readonly messageService = inject(MessageService);
|
||||||
private readonly fb = inject(FormBuilder);
|
private readonly fb = inject(FormBuilder);
|
||||||
private readonly dialogRef = inject(DynamicDialogRef);
|
private readonly dialogRef = inject(DynamicDialogRef);
|
||||||
private readonly t = inject(TranslocoService);
|
private readonly t = inject(TranslocoService);
|
||||||
|
private readonly destroyRef = inject(DestroyRef);
|
||||||
|
protected readonly activeLang = toSignal(this.t.langChanges$, {initialValue: this.t.getActiveLang()});
|
||||||
|
protected readonly selectedPrimaryColor = computed(() => this.configService.appState().primary);
|
||||||
|
protected readonly selectedSurfaceColor = computed(() => this.configService.appState().surface);
|
||||||
|
protected readonly surfaces = this.configService.surfaces;
|
||||||
|
protected readonly primaryColors = this.getPrimaryColors();
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.changePasswordForm = this.fb.group(
|
this.changePasswordForm = this.fb.group(
|
||||||
@@ -82,6 +109,43 @@ export class UserProfileDialogComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onLanguageChange(lang: string): void {
|
||||||
|
if (lang === this.activeLang()) return;
|
||||||
|
this.t.load(lang).pipe(takeUntilDestroyed(this.destroyRef)).subscribe({
|
||||||
|
next: () => {
|
||||||
|
this.t.setActiveLang(lang);
|
||||||
|
localStorage.setItem(LANG_STORAGE_KEY, lang);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
updateThemeColor(event: Event, type: 'primary' | 'surface', color: { name: string; palette?: ColorPalette }): void {
|
||||||
|
this.configService.appState.update((state) => ({
|
||||||
|
...state,
|
||||||
|
[type]: color.name,
|
||||||
|
}));
|
||||||
|
event.stopPropagation();
|
||||||
|
}
|
||||||
|
|
||||||
|
private getPrimaryColors(): Palette[] {
|
||||||
|
const presetPalette = (Aura.primitive ?? {}) as Record<string, ColorPalette>;
|
||||||
|
const colors = [
|
||||||
|
'orange', 'amber', 'yellow', 'lime', 'green', 'emerald',
|
||||||
|
'teal', 'cyan', 'sky', 'blue', 'indigo', 'violet',
|
||||||
|
'purple', 'fuchsia', 'pink', 'rose', 'red',
|
||||||
|
'coralSunset', 'roseBlush', 'melonBlush', 'cottonCandy',
|
||||||
|
'apricotSunrise', 'antiqueBronze', 'butteryYellow', 'vanillaCream',
|
||||||
|
'citrusMint', 'freshMint', 'sagePearl', 'skyBlue', 'periwinkleCream',
|
||||||
|
'pastelRoyalBlue', 'lavenderDream', 'dustyNeutral',
|
||||||
|
];
|
||||||
|
return [{name: 'noir', palette: {}}].concat(
|
||||||
|
colors.map(name => ({
|
||||||
|
name,
|
||||||
|
palette: presetPalette[name] ?? {},
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
updateProfile(): void {
|
updateProfile(): void {
|
||||||
if (!this.currentUser) {
|
if (!this.currentUser) {
|
||||||
this.messageService.add({
|
this.messageService.add({
|
||||||
|
|||||||
-32
@@ -1,32 +0,0 @@
|
|||||||
<ng-container *transloco="let t; prefix: 'settingsView.language'">
|
|
||||||
<div class="settings-card">
|
|
||||||
<div class="section-header">
|
|
||||||
<h3 class="section-title">
|
|
||||||
<i class="pi pi-language"></i>
|
|
||||||
{{ t('sectionTitle') }}
|
|
||||||
</h3>
|
|
||||||
<p class="section-description">{{ t('sectionDesc') }}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="section-body">
|
|
||||||
<div class="setting-item">
|
|
||||||
<div class="setting-header-standalone">
|
|
||||||
<span class="setting-label">{{ t('label') }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="setting-options">
|
|
||||||
<div class="select-group">
|
|
||||||
<p-select
|
|
||||||
size="small"
|
|
||||||
[options]="languageOptions"
|
|
||||||
[ngModel]="activeLang()"
|
|
||||||
(ngModelChange)="onLanguageChange($event)"
|
|
||||||
optionLabel="label"
|
|
||||||
optionValue="value"
|
|
||||||
appendTo="body">
|
|
||||||
</p-select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</ng-container>
|
|
||||||
-41
@@ -1,41 +0,0 @@
|
|||||||
@use '../../../../shared/styles/settings-shared' as settings;
|
|
||||||
|
|
||||||
.settings-card {
|
|
||||||
@include settings.settings-card;
|
|
||||||
}
|
|
||||||
|
|
||||||
.section-header {
|
|
||||||
@include settings.settings-section-header;
|
|
||||||
}
|
|
||||||
|
|
||||||
.section-title {
|
|
||||||
@include settings.settings-section-title;
|
|
||||||
}
|
|
||||||
|
|
||||||
.section-description {
|
|
||||||
@include settings.settings-section-description;
|
|
||||||
}
|
|
||||||
|
|
||||||
.section-body {
|
|
||||||
@include settings.settings-section-body;
|
|
||||||
}
|
|
||||||
|
|
||||||
.setting-item {
|
|
||||||
@include settings.settings-item;
|
|
||||||
}
|
|
||||||
|
|
||||||
.setting-header-standalone {
|
|
||||||
@include settings.settings-item-header-standalone;
|
|
||||||
}
|
|
||||||
|
|
||||||
.setting-label {
|
|
||||||
@include settings.settings-label;
|
|
||||||
}
|
|
||||||
|
|
||||||
.setting-options {
|
|
||||||
@include settings.settings-options;
|
|
||||||
}
|
|
||||||
|
|
||||||
.select-group {
|
|
||||||
@include settings.settings-select-group;
|
|
||||||
}
|
|
||||||
-35
@@ -1,35 +0,0 @@
|
|||||||
import {Component, DestroyRef, inject} from '@angular/core';
|
|
||||||
import {FormsModule} from '@angular/forms';
|
|
||||||
import {takeUntilDestroyed, toSignal} from '@angular/core/rxjs-interop';
|
|
||||||
import {Select} from 'primeng/select';
|
|
||||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
|
||||||
import {AVAILABLE_LANGS, LANG_LABELS} from '../../../../core/config/transloco-loader';
|
|
||||||
import {LANG_STORAGE_KEY} from '../../../../core/config/language-initializer';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-language-preferences',
|
|
||||||
standalone: true,
|
|
||||||
imports: [FormsModule, Select, TranslocoDirective],
|
|
||||||
templateUrl: './language-preferences.component.html',
|
|
||||||
styleUrl: './language-preferences.component.scss',
|
|
||||||
})
|
|
||||||
export class LanguagePreferencesComponent {
|
|
||||||
readonly languageOptions = AVAILABLE_LANGS.map(value => ({
|
|
||||||
value,
|
|
||||||
label: LANG_LABELS[value] ?? value,
|
|
||||||
}));
|
|
||||||
|
|
||||||
private readonly t = inject(TranslocoService);
|
|
||||||
private readonly destroyRef = inject(DestroyRef);
|
|
||||||
readonly activeLang = toSignal(this.t.langChanges$, {initialValue: this.t.getActiveLang()});
|
|
||||||
|
|
||||||
onLanguageChange(lang: string): void {
|
|
||||||
if (lang === this.activeLang()) return;
|
|
||||||
this.t.load(lang).pipe(takeUntilDestroyed(this.destroyRef)).subscribe({
|
|
||||||
next: () => {
|
|
||||||
this.t.setActiveLang(lang);
|
|
||||||
localStorage.setItem(LANG_STORAGE_KEY, lang);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-15
@@ -1,15 +0,0 @@
|
|||||||
<ng-container *transloco="let t; prefix: 'settingsView.theme'">
|
|
||||||
<div class="settings-card">
|
|
||||||
<div class="section-header">
|
|
||||||
<h3 class="section-title">
|
|
||||||
<i class="pi pi-palette"></i>
|
|
||||||
{{ t('sectionTitle') }}
|
|
||||||
</h3>
|
|
||||||
<p class="section-description">{{ t('sectionDesc') }}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="section-body">
|
|
||||||
<app-theme-configurator></app-theme-configurator>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</ng-container>
|
|
||||||
-21
@@ -1,21 +0,0 @@
|
|||||||
@use '../../../../shared/styles/settings-shared' as settings;
|
|
||||||
|
|
||||||
.settings-card {
|
|
||||||
@include settings.settings-card;
|
|
||||||
}
|
|
||||||
|
|
||||||
.section-header {
|
|
||||||
@include settings.settings-section-header;
|
|
||||||
}
|
|
||||||
|
|
||||||
.section-title {
|
|
||||||
@include settings.settings-section-title;
|
|
||||||
}
|
|
||||||
|
|
||||||
.section-description {
|
|
||||||
@include settings.settings-section-description;
|
|
||||||
}
|
|
||||||
|
|
||||||
.section-body {
|
|
||||||
@include settings.settings-section-body;
|
|
||||||
}
|
|
||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
import {Component} from '@angular/core';
|
|
||||||
import {TranslocoDirective} from '@jsverse/transloco';
|
|
||||||
import {ThemeConfiguratorComponent} from '../../../../shared/layout/theme-configurator/theme-configurator.component';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-theme-preferences',
|
|
||||||
standalone: true,
|
|
||||||
imports: [TranslocoDirective, ThemeConfiguratorComponent],
|
|
||||||
templateUrl: './theme-preferences.component.html',
|
|
||||||
styleUrl: './theme-preferences.component.scss',
|
|
||||||
})
|
|
||||||
export class ThemePreferencesComponent {}
|
|
||||||
-5
@@ -10,11 +10,6 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<app-language-preferences></app-language-preferences>
|
|
||||||
<div class="section-divider"><hr></div>
|
|
||||||
<app-theme-preferences></app-theme-preferences>
|
|
||||||
<div class="section-divider"><hr></div>
|
|
||||||
|
|
||||||
<app-view-preferences></app-view-preferences>
|
<app-view-preferences></app-view-preferences>
|
||||||
<div class="section-divider"><hr></div>
|
<div class="section-divider"><hr></div>
|
||||||
<app-filter-preferences></app-filter-preferences>
|
<app-filter-preferences></app-filter-preferences>
|
||||||
|
|||||||
-4
@@ -6,8 +6,6 @@ import {ViewPreferencesComponent} from './view-preferences/view-preferences.comp
|
|||||||
import {SidebarSortingPreferencesComponent} from './sidebar-sorting-preferences/sidebar-sorting-preferences.component';
|
import {SidebarSortingPreferencesComponent} from './sidebar-sorting-preferences/sidebar-sorting-preferences.component';
|
||||||
import {MetaCenterViewModeComponent} from './meta-center-view-mode/meta-center-view-mode-component';
|
import {MetaCenterViewModeComponent} from './meta-center-view-mode/meta-center-view-mode-component';
|
||||||
import {FilterPreferencesComponent} from './filter-preferences/filter-preferences.component';
|
import {FilterPreferencesComponent} from './filter-preferences/filter-preferences.component';
|
||||||
import {LanguagePreferencesComponent} from './language-preferences/language-preferences.component';
|
|
||||||
import {ThemePreferencesComponent} from './theme-preferences/theme-preferences.component';
|
|
||||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||||
import {Slider} from 'primeng/slider';
|
import {Slider} from 'primeng/slider';
|
||||||
import {MessageService} from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
@@ -23,8 +21,6 @@ import {LayoutService, SIDEBAR_MAX_WIDTH, SIDEBAR_MIN_WIDTH} from '../../../shar
|
|||||||
SidebarSortingPreferencesComponent,
|
SidebarSortingPreferencesComponent,
|
||||||
MetaCenterViewModeComponent,
|
MetaCenterViewModeComponent,
|
||||||
FilterPreferencesComponent,
|
FilterPreferencesComponent,
|
||||||
LanguagePreferencesComponent,
|
|
||||||
ThemePreferencesComponent,
|
|
||||||
TranslocoDirective,
|
TranslocoDirective,
|
||||||
Slider,
|
Slider,
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
<ng-container *transloco="let t; prefix: 'layout.theme'">
|
|
||||||
<div class="setting-item">
|
|
||||||
<div class="setting-header-standalone">
|
|
||||||
<span class="setting-label">{{ t('primary') }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="setting-options">
|
|
||||||
<div class="color-swatches">
|
|
||||||
@for (primaryColor of primaryColors(); track primaryColor.name) {
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
[title]="primaryColor.name"
|
|
||||||
[attr.aria-label]="primaryColor.name"
|
|
||||||
[attr.aria-pressed]="primaryColor.name === selectedPrimaryColor()"
|
|
||||||
(click)="updateColors($event, 'primary', primaryColor)"
|
|
||||||
[ngClass]="{ 'active-color': primaryColor.name === selectedPrimaryColor() }"
|
|
||||||
[style]="{ 'background-color': primaryColor.name === 'noir' ? 'var(--text-color)' : primaryColor.palette['500'] || 'transparent' }"
|
|
||||||
></button>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="setting-item">
|
|
||||||
<div class="setting-header-standalone">
|
|
||||||
<span class="setting-label">{{ t('surface') }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="setting-options">
|
|
||||||
<div class="color-swatches">
|
|
||||||
@for (surface of surfaces; track surface.name) {
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
[title]="surface.name"
|
|
||||||
[attr.aria-label]="surface.name"
|
|
||||||
[attr.aria-pressed]="selectedSurfaceColor() ? selectedSurfaceColor() === surface.name : surface.name === 'zinc'"
|
|
||||||
(click)="updateColors($event, 'surface', surface)"
|
|
||||||
[ngClass]="{ 'active-color': selectedSurfaceColor() ? selectedSurfaceColor() === surface.name : surface.name === 'zinc' }"
|
|
||||||
[style]="{'background-color': surface.name === 'noir' ? 'var(--text-color)' : surface.palette['500'] }">
|
|
||||||
</button>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</ng-container>
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
@use '../../styles/settings-shared' as settings;
|
|
||||||
|
|
||||||
:host {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: settings.$settings-section-body-gap;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.setting-item {
|
|
||||||
@include settings.settings-item;
|
|
||||||
}
|
|
||||||
|
|
||||||
.setting-header-standalone {
|
|
||||||
@include settings.settings-item-header-standalone;
|
|
||||||
}
|
|
||||||
|
|
||||||
.setting-label {
|
|
||||||
@include settings.settings-label;
|
|
||||||
}
|
|
||||||
|
|
||||||
.setting-options {
|
|
||||||
@include settings.settings-options;
|
|
||||||
}
|
|
||||||
|
|
||||||
.color-swatches {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 0.5rem;
|
|
||||||
|
|
||||||
button {
|
|
||||||
border: none;
|
|
||||||
width: 1.25rem;
|
|
||||||
height: 1.25rem;
|
|
||||||
border-radius: 50%;
|
|
||||||
padding: 0;
|
|
||||||
cursor: pointer;
|
|
||||||
outline: transparent solid 2px;
|
|
||||||
outline-offset: 1px;
|
|
||||||
|
|
||||||
&:focus-visible {
|
|
||||||
outline-color: var(--primary-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
&.active-color {
|
|
||||||
outline-color: var(--primary-color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-17
@@ -1,17 +0,0 @@
|
|||||||
import {describe, it} from 'vitest';
|
|
||||||
|
|
||||||
// NOTE(frontend-seam): Real coverage here needs a stable app-config signal seam plus favicon
|
|
||||||
// side-effect interception. The component is mostly computed/effect wiring over `AppConfigService`
|
|
||||||
// state, palette tokens, and `FaviconService`, so a useful spec should validate those reactions
|
|
||||||
// without reaching through private signal internals.
|
|
||||||
describe.skip('ThemeConfiguratorComponent', () => {
|
|
||||||
it('needs an app-config seam to verify selected palette derivation and color updates', () => {
|
|
||||||
// TODO(seam): Cover computed primary/surface selections and updateColors state writes once
|
|
||||||
// the config signal can be driven through a stable public harness.
|
|
||||||
});
|
|
||||||
|
|
||||||
it('needs a favicon side-effect seam to verify palette-to-favicon synchronization', () => {
|
|
||||||
// TODO(seam): Cover favicon updates after exposing a testable effect boundary around the
|
|
||||||
// config-driven favicon sync.
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
import {ChangeDetectionStrategy, Component, computed, inject} from '@angular/core';
|
|
||||||
import {FormsModule} from '@angular/forms';
|
|
||||||
import {AppConfigService} from '../../service/app-config.service';
|
|
||||||
import {TranslocoDirective} from '@jsverse/transloco';
|
|
||||||
import {NgClass} from '@angular/common';
|
|
||||||
import Aura from '../theme-palette-extend';
|
|
||||||
|
|
||||||
type ColorPalette = Record<string, string>;
|
|
||||||
|
|
||||||
interface Palette {
|
|
||||||
name: string;
|
|
||||||
palette: ColorPalette;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-theme-configurator',
|
|
||||||
standalone: true,
|
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
||||||
templateUrl: './theme-configurator.component.html',
|
|
||||||
styleUrl: './theme-configurator.component.scss',
|
|
||||||
imports: [
|
|
||||||
NgClass,
|
|
||||||
FormsModule,
|
|
||||||
TranslocoDirective
|
|
||||||
]
|
|
||||||
})
|
|
||||||
export class ThemeConfiguratorComponent {
|
|
||||||
readonly configService = inject(AppConfigService);
|
|
||||||
|
|
||||||
readonly surfaces = this.configService.surfaces;
|
|
||||||
|
|
||||||
readonly selectedPrimaryColor = computed(() => this.configService.appState().primary);
|
|
||||||
readonly selectedSurfaceColor = computed(() => this.configService.appState().surface);
|
|
||||||
|
|
||||||
readonly primaryColors = computed<Palette[]>(() => {
|
|
||||||
const presetPalette = (Aura.primitive ?? {}) as Record<string, ColorPalette>;
|
|
||||||
const colors = [
|
|
||||||
'orange', 'amber', 'yellow', 'lime', 'green', 'emerald',
|
|
||||||
'teal', 'cyan', 'sky', 'blue', 'indigo', 'violet',
|
|
||||||
'purple', 'fuchsia', 'pink', 'rose', 'red',
|
|
||||||
'coralSunset', 'roseBlush', 'melonBlush', 'cottonCandy',
|
|
||||||
'apricotSunrise', 'antiqueBronze', 'butteryYellow', 'vanillaCream',
|
|
||||||
'citrusMint', 'freshMint', 'sagePearl', 'skyBlue','periwinkleCream',
|
|
||||||
'pastelRoyalBlue', 'lavenderDream', 'dustyNeutral'
|
|
||||||
];
|
|
||||||
return [{name: 'noir', palette: {}}].concat(
|
|
||||||
colors.map(name => ({
|
|
||||||
name,
|
|
||||||
palette: presetPalette[name] ?? {}
|
|
||||||
}))
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
updateColors(event: Event, type: 'primary' | 'surface', color: { name: string; palette?: ColorPalette }) {
|
|
||||||
this.configService.appState.update((state) => ({
|
|
||||||
...state,
|
|
||||||
[type]: color.name
|
|
||||||
}));
|
|
||||||
event.stopPropagation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user