2026-07-13 08:57:42 +04:00
|
|
|
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 { NavigationItemConfig } from '../../../shared/models/config';
|
feat(project-editor): adopt Design System primitives across editor sections
Applied app-input/app-form-field/app-button to 9 of 11 Project Editor
sections: general, branding, theme, footer, homepage, widgets, languages,
navigation, preview. header and features sections were left unchanged -
they contain only checkboxes and selects, and no Checkbox/Select primitive
exists yet.
Theme section's 8 color pickers stay native <input type=color> (app-input's
type union doesn't include 'color') but are now wrapped in app-form-field
for consistent label/hint treatment. Added app-form-field.full grid-column
rule to section.shared.scss (shared by all 11 sections) alongside the
existing label.full rule, since the custom element doesn't match that
selector.
Production build green, arch:check passes.
2026-07-15 07:55:38 +04:00
|
|
|
import { ButtonComponent } from '../../../shared/ui/button/button.component';
|
|
|
|
|
import { InputComponent } from '../../../shared/ui/input/input.component';
|
2026-07-13 08:57:42 +04:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-project-editor-navigation-section',
|
|
|
|
|
standalone: true,
|
feat(project-editor): adopt Design System primitives across editor sections
Applied app-input/app-form-field/app-button to 9 of 11 Project Editor
sections: general, branding, theme, footer, homepage, widgets, languages,
navigation, preview. header and features sections were left unchanged -
they contain only checkboxes and selects, and no Checkbox/Select primitive
exists yet.
Theme section's 8 color pickers stay native <input type=color> (app-input's
type union doesn't include 'color') but are now wrapped in app-form-field
for consistent label/hint treatment. Added app-form-field.full grid-column
rule to section.shared.scss (shared by all 11 sections) alongside the
existing label.full rule, since the custom element doesn't match that
selector.
Production build green, arch:check passes.
2026-07-15 07:55:38 +04:00
|
|
|
imports: [FormsModule, TranslatePipe, ButtonComponent, InputComponent],
|
2026-07-13 08:57:42 +04:00
|
|
|
templateUrl: './navigation-section.component.html',
|
|
|
|
|
styleUrls: ['./section.shared.scss'],
|
|
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
|
|
|
})
|
|
|
|
|
export class ProjectEditorNavigationSectionComponent {
|
|
|
|
|
private readonly facade = inject(ProjectEditorFacade);
|
|
|
|
|
readonly bootstrap = this.facade.bootstrap;
|
|
|
|
|
|
|
|
|
|
readonly headerLinks = computed(() => this.sorted(this.bootstrap()?.navigation.header ?? []));
|
|
|
|
|
readonly footerLinks = computed<NavigationItemConfig[] | null>(() => {
|
|
|
|
|
const footer = this.bootstrap()?.navigation.footer ?? [];
|
|
|
|
|
if (footer.length === 0) {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
return 'items' in footer[0] ? null : this.sorted(footer as NavigationItemConfig[]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
labelOf(item: NavigationItemConfig): string {
|
|
|
|
|
if (typeof item.label === 'string' || !item.label) {
|
|
|
|
|
return item.label ?? '';
|
|
|
|
|
}
|
|
|
|
|
const defaultLocale = this.bootstrap()?.localization.defaultLocale ?? 'en';
|
|
|
|
|
return item.label[defaultLocale] ?? Object.values(item.label)[0] ?? '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addLink(target: 'header' | 'footer'): void {
|
|
|
|
|
this.facade.addNavLink(target);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
removeLink(target: 'header' | 'footer', id: string): void {
|
|
|
|
|
this.facade.removeNavLink(target, id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
move(target: 'header' | 'footer', id: string, direction: -1 | 1): void {
|
|
|
|
|
this.facade.reorderNavLink(target, id, direction);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateLabel(target: 'header' | 'footer', id: string, value: string): void {
|
2026-07-13 15:57:39 +04:00
|
|
|
this.facade.updateNavLinkLabel(target, id, value);
|
2026-07-13 08:57:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateRoute(target: 'header' | 'footer', id: string, value: string): void {
|
|
|
|
|
this.facade.updateNavLink(target, id, { route: value });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateVisible(target: 'header' | 'footer', id: string, value: boolean): void {
|
|
|
|
|
this.facade.updateNavLink(target, id, { visible: value });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private sorted(items: NavigationItemConfig[]): NavigationItemConfig[] {
|
|
|
|
|
return [...items].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
|
|
|
|
|
}
|
|
|
|
|
}
|