From ccbf8c6e5c1decd8ff04118b79b35ad76eb0a43e Mon Sep 17 00:00:00 2001 From: sdarbinyan Date: Thu, 16 Jul 2026 02:01:34 +0400 Subject: [PATCH] feat(project-editor): migrate theme section to Select/ColorPicker/SectionCard Co-Authored-By: Claude Sonnet 5 --- .../sections/theme-section.component.html | 47 +++++++------------ .../sections/theme-section.component.ts | 33 +++++++++---- 2 files changed, 39 insertions(+), 41 deletions(-) diff --git a/src/app/features/project-editor/sections/theme-section.component.html b/src/app/features/project-editor/sections/theme-section.component.html index b79bcbb..3e89de4 100644 --- a/src/app/features/project-editor/sections/theme-section.component.html +++ b/src/app/features/project-editor/sections/theme-section.component.html @@ -1,35 +1,20 @@ @if (bootstrap(); as bootstrap) { -
-

{{ 'builder.theme' | translate }}

+
- - - - - - - - - - + + + + + + + + + + + + + +
-
+ } diff --git a/src/app/features/project-editor/sections/theme-section.component.ts b/src/app/features/project-editor/sections/theme-section.component.ts index 0e52c18..c4be5c5 100644 --- a/src/app/features/project-editor/sections/theme-section.component.ts +++ b/src/app/features/project-editor/sections/theme-section.component.ts @@ -1,9 +1,13 @@ -import { ChangeDetectionStrategy, Component, inject } from '@angular/core'; +import { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { ProjectEditorFacade } from '../facade/project-editor.facade'; import { TranslatePipe } from '../../../i18n/translate.pipe'; +import { TranslateService } from '../../../i18n/translate.service'; import { PlatformLayoutType, ThemePaletteConfig } from '../../../shared/models/config'; import { FormFieldComponent } from '../../../shared/ui/form-field/form-field.component'; +import { SectionCardComponent } from '../../../shared/ui/section-card/section-card.component'; +import { SelectComponent, SelectOption } from '../../../shared/ui/select/select.component'; +import { ColorPickerComponent } from '../../../shared/ui/color-picker/color-picker.component'; export interface ThemeModeOption { value: 'light' | 'dark' | 'system'; @@ -20,13 +24,14 @@ export interface SiteLayoutOption { @Component({ selector: 'app-project-editor-theme-section', standalone: true, - imports: [FormsModule, TranslatePipe, FormFieldComponent], + imports: [FormsModule, TranslatePipe, FormFieldComponent, SectionCardComponent, SelectComponent, ColorPickerComponent], templateUrl: './theme-section.component.html', styleUrls: ['./section.shared.scss'], changeDetection: ChangeDetectionStrategy.OnPush }) export class ProjectEditorThemeSectionComponent { private readonly facade = inject(ProjectEditorFacade); + private readonly translate = inject(TranslateService); readonly bootstrap = this.facade.bootstrap; readonly themeModeOptions: ThemeModeOption[] = [ @@ -42,6 +47,22 @@ export class ProjectEditorThemeSectionComponent { { value: 'minimal', labelKey: 'builder.siteLayoutMinimal', descKey: 'builder.siteLayoutMinimalDesc' }, ]; + readonly themeModeSelectOptions = computed(() => + this.themeModeOptions.map(option => ({ + value: option.value, + label: this.translate.t(option.labelKey), + description: this.translate.t(option.descKey) + })) + ); + + readonly siteLayoutSelectOptions = computed(() => + this.siteLayoutOptions.map(option => ({ + value: option.value, + label: this.translate.t(option.labelKey), + description: this.translate.t(option.descKey) + })) + ); + updatePalette(key: K, value: string): void { this.facade.updateBootstrap(current => ({ ...current, @@ -62,12 +83,4 @@ export class ProjectEditorThemeSectionComponent { layout: { ...current.layout, type: type as PlatformLayoutType } })); } - - themeModeDescKey(mode: string): string { - return this.themeModeOptions.find(option => option.value === mode)?.descKey ?? ''; - } - - siteLayoutDescKey(type: string): string { - return this.siteLayoutOptions.find(option => option.value === type)?.descKey ?? ''; - } }