diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index 8e41226..e154ed5 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -40,12 +40,22 @@ const coreRoutes: Routes = [ loadComponent: () => import('./features/website/catalog/containers/catalog-container.component').then(m => m.CatalogContainerComponent) }, { - path: 'builder', + path: 'edit/:section', loadComponent: () => import('./features/project-editor/pages/project-editor-page.component').then(m => m.ProjectEditorPageComponent) }, + { + path: 'edit', + redirectTo: 'edit/general', + pathMatch: 'full' + }, + { + path: 'builder', + redirectTo: 'edit/general', + pathMatch: 'full' + }, { path: 'project-editor', - redirectTo: 'builder', + redirectTo: 'edit/general', pathMatch: 'full' }, { diff --git a/src/app/features/project-editor/components/project-editor-nav.component.html b/src/app/features/project-editor/components/project-editor-nav.component.html index b3ef139..c25011e 100644 --- a/src/app/features/project-editor/components/project-editor-nav.component.html +++ b/src/app/features/project-editor/components/project-editor-nav.component.html @@ -1,5 +1,9 @@ diff --git a/src/app/features/project-editor/components/project-editor-nav.component.scss b/src/app/features/project-editor/components/project-editor-nav.component.scss index 459ff96..7162534 100644 --- a/src/app/features/project-editor/components/project-editor-nav.component.scss +++ b/src/app/features/project-editor/components/project-editor-nav.component.scss @@ -4,7 +4,8 @@ gap: 10px; } -button { +button, +.editor-nav-link { min-height: 40px; border-radius: 999px; border: 1px solid var(--border-color, #d3dad9); @@ -15,8 +16,15 @@ button { cursor: pointer; } -button.active { +button.active, +.editor-nav-link.active { border-color: #497671; background: #497671; color: #fff; } + +.editor-nav-link { + text-decoration: none; + display: inline-block; + line-height: 40px; +} diff --git a/src/app/features/project-editor/components/project-editor-nav.component.ts b/src/app/features/project-editor/components/project-editor-nav.component.ts index 920e7d7..5c0c741 100644 --- a/src/app/features/project-editor/components/project-editor-nav.component.ts +++ b/src/app/features/project-editor/components/project-editor-nav.component.ts @@ -1,19 +1,18 @@ -import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; +import { RouterLink, RouterLinkActive } from '@angular/router'; import { TranslatePipe } from '../../../i18n/translate.pipe'; +import { LangRoutePipe } from '../../../pipes/lang-route.pipe'; import { ProjectEditorSectionId } from '../models/project-editor.model'; @Component({ selector: 'app-project-editor-nav', standalone: true, - imports: [TranslatePipe], + imports: [TranslatePipe, RouterLink, RouterLinkActive, LangRoutePipe], templateUrl: './project-editor-nav.component.html', styleUrls: ['./project-editor-nav.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush }) export class ProjectEditorNavComponent { - @Input() active: ProjectEditorSectionId = 'general'; - @Output() activeChange = new EventEmitter(); - readonly sections: Array<{ id: ProjectEditorSectionId; label: string }> = [ { id: 'general', label: 'builder.general' }, { id: 'branding', label: 'builder.branding' }, diff --git a/src/app/features/project-editor/pages/project-editor-page.component.html b/src/app/features/project-editor/pages/project-editor-page.component.html index 00b602d..9a6b85d 100644 --- a/src/app/features/project-editor/pages/project-editor-page.component.html +++ b/src/app/features/project-editor/pages/project-editor-page.component.html @@ -4,7 +4,7 @@

{{ 'builder.title' | translate }}

{{ 'builder.subtitle' | translate }}

- + @if (!bootstrap()) { diff --git a/src/app/features/project-editor/pages/project-editor-page.component.ts b/src/app/features/project-editor/pages/project-editor-page.component.ts index 6feced2..87d5dee 100644 --- a/src/app/features/project-editor/pages/project-editor-page.component.ts +++ b/src/app/features/project-editor/pages/project-editor-page.component.ts @@ -1,4 +1,7 @@ -import { ChangeDetectionStrategy, Component, inject } from '@angular/core'; +import { ChangeDetectionStrategy, Component, effect, inject } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { toSignal } from '@angular/core/rxjs-interop'; +import { map } from 'rxjs/operators'; import { ProjectEditorFacade } from '../facade/project-editor.facade'; import { ProjectEditorNavComponent } from '../components/project-editor-nav.component'; import { ProjectEditorGeneralSectionComponent } from '../sections/general-section.component'; @@ -12,6 +15,11 @@ import { ProjectEditorFeaturesSectionComponent } from '../sections/features-sect import { ProjectEditorPreviewSectionComponent } from '../sections/preview-section.component'; import { TranslatePipe } from '../../../i18n/translate.pipe'; import { StaticPagesEditorComponent } from '../../content-management/components/static-pages-editor.component'; +import { ProjectEditorSectionId } from '../models/project-editor.model'; + +const KNOWN_SECTIONS: ProjectEditorSectionId[] = [ + 'general', 'branding', 'theme', 'header', 'footer', 'homepage', 'widgets', 'static-pages', 'features', 'preview' +]; @Component({ selector: 'app-project-editor-page', @@ -36,10 +44,22 @@ import { StaticPagesEditorComponent } from '../../content-management/components/ }) export class ProjectEditorPageComponent { readonly facade = inject(ProjectEditorFacade); + private readonly route = inject(ActivatedRoute); readonly bootstrap = this.facade.bootstrap; readonly activeSection = this.facade.activeSection; + private readonly routeSection = toSignal( + this.route.paramMap.pipe(map(params => params.get('section') as ProjectEditorSectionId | null)), + { initialValue: null } + ); + constructor() { this.facade.loadBootstrap(); + effect(() => { + const section = this.routeSection(); + if (section && KNOWN_SECTIONS.includes(section)) { + this.facade.setActiveSection(section); + } + }); } }