chore(ui): move theme/language preferences into user profile (#1243)
This commit is contained in:
@@ -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