From 480d55989b2a62a5fa276c0339471450b622e367 Mon Sep 17 00:00:00 2001 From: Lars Date: Tue, 17 Nov 2026 20:34:06 +0100 Subject: [PATCH] =?UTF-8?q?F=C3=BChre=20Abschnitte=20mit=20Raster,=20gemei?= =?UTF-8?q?nsames=20Designsystem=20und=20globales=20Website-Ger=C3=BCst=20?= =?UTF-8?q?ein.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Seite → Abschnitte → Plätze → Widgets: sechs Raster mit höchstens vier Einheiten, Hintergrund, Breite, Abstand und Trenner als Aufzählungswerte; je Platz ein Widget aus dem bestehenden Register. Neue Spalte page_revisions.sections (ergänzend); blocks erhält weiterhin alle Widgets in Lesereihenfolge als Rollback-Fassung. - Widgets erhalten Mindest- und Vorzugsbreite; Darstellung über Container-Abfragen. - Editor: Abschnitts-Repeater mit grafischer Rasterauswahl, Plätzen im Rasterverhältnis, breiter Arbeitsfläche, kompakten Vorschauen ohne Bildlaufleiste, Meldungen mit Abschnitt und Platz; Rasterwechsel entfernt nie ein Widget. Seite duplizieren. - Designsystem: Marken- und Bedeutungs-Tokens (vorläufig), gemeinsame Grundkomponenten, Nunito/Source Sans 3 lokal; Mitgliederbereich nutzt dieselben Tokens und die Wortmarke. - Kopfzeile, mobile Navigation, Untermenü (parent_id, ergänzend), Fußbereichsgruppen, vorbereiteter Warenkorbzugang (abgeschaltet). Öffentliche Seiten gleich für alle Besucher. - cms:revert-published als Wiederherstellungsweg vor einem Code-Rollback. Die Editor-Tests der ersten Iteration sind bewusst auf den neuen Formularzustand (sections statt blocks) umgestellt; ihre Prüfungen gelten unverändert für die Widgets. Der Vorschautest erwartet keine anmeldeabhängige Kopfzeile mehr (ADR-32). Co-Authored-By: Claude Opus 5.5 --- app/Console/Commands/RevertPublishedPages.php | 87 +++ app/Domain/Cms/NavigationItem.php | 56 +- app/Domain/Cms/PageRevision.php | 21 +- app/Domain/Cms/PageService.php | 56 +- app/Domain/Cms/Sections/PageSections.php | 345 +++++++++ app/Domain/Cms/Sections/SectionLayouts.php | 130 ++++ app/Domain/Cms/Sections/SectionRenderer.php | 127 ++++ app/Domain/Cms/Sections/SectionStyle.php | 150 ++++ app/Domain/Cms/SiteNavigation.php | 104 +++ .../Cms/Widgets/Types/CallToActionWidget.php | 17 + app/Domain/Cms/Widgets/Types/CardsWidget.php | 18 + .../Cms/Widgets/Types/CatalogCardsWidget.php | 18 + app/Domain/Cms/Widgets/Types/FaqWidget.php | 17 + .../Cms/Widgets/Types/HeadingWidget.php | 17 + app/Domain/Cms/Widgets/Types/HeroWidget.php | 18 + .../Cms/Widgets/Types/ImageTextWidget.php | 18 + app/Domain/Cms/Widgets/Types/ProseWidget.php | 17 + app/Domain/Cms/Widgets/WidgetRegistry.php | 83 ++- app/Domain/Cms/Widgets/WidgetType.php | 26 + .../NavigationItemResource.php | 43 +- app/Filament/Resources/Pages/PageResource.php | 43 +- .../Resources/Pages/Pages/CreatePage.php | 19 +- .../Resources/Pages/Pages/EditPage.php | 19 +- .../RevisionsRelationManager.php | 5 +- app/Filament/Support/ReportsSectionErrors.php | 35 + app/Filament/Support/SectionEditor.php | 516 ++++++++++++++ app/Filament/Support/WidgetEditor.php | 38 +- app/Http/Controllers/PageController.php | 5 +- config/cms.php | 9 + ..._110000_add_sections_to_page_revisions.php | 27 + ..._120000_add_parent_to_navigation_items.php | 27 + resources/css/app.css | 674 ++---------------- resources/css/base.css | 145 ++++ resources/css/components.css | 288 ++++++++ resources/css/sections.css | 163 +++++ resources/css/site.css | 416 +++++++++++ resources/css/tokens.css | 168 +++++ resources/css/widgets.css | 331 +++++++++ resources/js/app.js | 1 + resources/js/site-nav.js | 137 ++++ .../views/components/site/brand.blade.php | 16 +- .../views/components/site/cart-link.blade.php | 10 + .../views/components/site/footer.blade.php | 42 +- .../views/components/site/header.blade.php | 56 +- resources/views/filament/cms/styles.blade.php | 63 +- .../filament/cms/widget-preview.blade.php | 29 +- resources/views/layouts/member.blade.php | 11 +- resources/views/layouts/site.blade.php | 8 +- resources/views/public/page.blade.php | 7 + .../views/site/templates/standard.blade.php | 22 +- .../views/widgets/call_to_action.blade.php | 2 +- tests/Feature/CmsEditorTest.php | 263 +++++-- tests/Feature/CmsRollbackCommandTest.php | 45 ++ tests/Feature/CmsSectionRenderingTest.php | 259 +++++++ tests/Unit/PageSectionsTest.php | 262 +++++++ tests/Unit/WidgetRegistryTest.php | 14 + vite.config.js | 5 +- 57 files changed, 4730 insertions(+), 818 deletions(-) create mode 100644 app/Console/Commands/RevertPublishedPages.php create mode 100644 app/Domain/Cms/Sections/PageSections.php create mode 100644 app/Domain/Cms/Sections/SectionLayouts.php create mode 100644 app/Domain/Cms/Sections/SectionRenderer.php create mode 100644 app/Domain/Cms/Sections/SectionStyle.php create mode 100644 app/Domain/Cms/SiteNavigation.php create mode 100644 app/Filament/Support/ReportsSectionErrors.php create mode 100644 app/Filament/Support/SectionEditor.php create mode 100644 database/migrations/2026_11_17_110000_add_sections_to_page_revisions.php create mode 100644 database/migrations/2026_11_17_120000_add_parent_to_navigation_items.php create mode 100644 resources/css/base.css create mode 100644 resources/css/components.css create mode 100644 resources/css/sections.css create mode 100644 resources/css/site.css create mode 100644 resources/css/tokens.css create mode 100644 resources/css/widgets.css create mode 100644 resources/js/site-nav.js create mode 100644 resources/views/components/site/cart-link.blade.php create mode 100644 tests/Feature/CmsRollbackCommandTest.php create mode 100644 tests/Feature/CmsSectionRenderingTest.php create mode 100644 tests/Unit/PageSectionsTest.php diff --git a/app/Console/Commands/RevertPublishedPages.php b/app/Console/Commands/RevertPublishedPages.php new file mode 100644 index 0000000..82f9797 --- /dev/null +++ b/app/Console/Commands/RevertPublishedPages.php @@ -0,0 +1,87 @@ +option('before')) ? null : CarbonImmutable::parse((string) $this->option('before')); + } catch (Throwable) { + $before = null; + } + + if ($before === null) { + $this->error('Bitte --before mit einem gültigen Zeitpunkt angeben.'); + + return self::FAILURE; + } + + $apply = (bool) $this->option('apply'); + $rows = []; + + foreach (Page::query()->whereNotNull('published_revision_id')->with('publishedRevision')->orderBy('path')->get() as $page) { + $current = $page->publishedRevision; + + if ($current === null || $current->created_at < $before) { + continue; + } + + $previous = PageRevision::query() + ->where('page_id', $page->id) + ->where('created_at', '<', $before) + ->latest('id') + ->first(); + + if ($previous === null) { + $rows[] = [$page->path, $current->id, '–', 'keine ältere Revision: Seite wird zurückgezogen']; + if ($apply) { + $page->published_revision_id = null; + $page->save(); + } + + continue; + } + + $rows[] = [$page->path, $current->id, $previous->id, $apply ? 'zurückgesetzt' : 'würde zurückgesetzt']; + if ($apply) { + $page->published_revision_id = $previous->id; + $page->save(); + } + } + + if ($rows === []) { + $this->info('Keine veröffentlichte Seite stammt aus der Zeit ab '.$before->format('d.m.Y H:i').'.'); + + return self::SUCCESS; + } + + $this->table(['Pfad', 'veröffentlicht', 'neu veröffentlicht', 'Ergebnis'], $rows); + + if (! $apply) { + $this->warn('Probelauf. Mit --apply ausführen.'); + } + + return self::SUCCESS; + } +} diff --git a/app/Domain/Cms/NavigationItem.php b/app/Domain/Cms/NavigationItem.php index 1b42fae..80dd1b4 100644 --- a/app/Domain/Cms/NavigationItem.php +++ b/app/Domain/Cms/NavigationItem.php @@ -6,12 +6,25 @@ use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasMany; class NavigationItem extends Model { + /** + * Plätze im globalen Website-Gerüst. Die drei Fußbereichsgruppen ersetzen eine eigene Footer-Verwaltung. + */ public const PLACEMENTS = [ - 'header' => 'Kopfzeile', - 'footer' => 'Fußzeile', + 'header' => 'Kopfzeile (Hauptnavigation)', + 'footer' => 'Fußbereich: Service', + 'footer_contact' => 'Fußbereich: Kontakt', + 'footer_legal' => 'Fußbereich: Rechtliches', + ]; + + /** Spaltenüberschriften im Fußbereich. */ + public const FOOTER_GROUPS = [ + 'footer' => 'Service', + 'footer_contact' => 'Kontakt', + 'footer_legal' => 'Rechtliches', ]; protected $fillable = [ @@ -21,8 +34,19 @@ class NavigationItem extends Model 'placement', 'sort_order', 'is_visible', + 'parent_id', ]; + protected static function booted(): void + { + // Untermenüs gibt es nur in der Hauptnavigation. + static::saving(function (NavigationItem $item): void { + if ($item->placement !== 'header' && $item->getAttribute('parent_id') !== null) { + $item->parent_id = null; + } + }); + } + protected function casts(): array { return [ @@ -35,6 +59,16 @@ public function page(): BelongsTo return $this->belongsTo(Page::class); } + public function parent(): BelongsTo + { + return $this->belongsTo(self::class, 'parent_id'); + } + + public function children(): HasMany + { + return $this->hasMany(self::class, 'parent_id')->orderBy('sort_order')->orderBy('id'); + } + /** * @param Builder $query */ @@ -59,4 +93,22 @@ public function href(): ?string return $this->url; } + + /** + * Pfad des Ziels innerhalb der Website (für die Kennzeichnung des aktiven Eintrags); null bei externen Zielen. + */ + public function targetPath(): ?string + { + if ($this->page !== null) { + return $this->page->path; + } + + if (is_string($this->url) && str_starts_with($this->url, '/') && ! str_starts_with($this->url, '//')) { + $path = parse_url($this->url, PHP_URL_PATH); + + return is_string($path) ? '/'.trim($path, '/') : null; + } + + return null; + } } diff --git a/app/Domain/Cms/PageRevision.php b/app/Domain/Cms/PageRevision.php index c51778b..ec1b34f 100644 --- a/app/Domain/Cms/PageRevision.php +++ b/app/Domain/Cms/PageRevision.php @@ -2,7 +2,7 @@ namespace App\Domain\Cms; -use App\Domain\Cms\Widgets\WidgetRegistry; +use App\Domain\Cms\Sections\PageSections; use App\Models\User; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -14,6 +14,7 @@ class PageRevision extends Model protected $fillable = [ 'page_id', 'blocks', + 'sections', 'seo_title', 'seo_description', 'created_by', @@ -23,6 +24,7 @@ protected function casts(): array { return [ 'blocks' => 'array', + 'sections' => 'array', 'created_at' => 'datetime', ]; } @@ -38,13 +40,24 @@ public function author(): BelongsTo } /** - * Bausteine als aktuelle Widget-Hüllen. Die gespeicherten Daten bleiben unverändert. + * Abschnitte als aktuelle Hüllen. Revisionen ohne Abschnitte (vor Einführung des Rasters) werden als + * einspaltige Abschnitte gelesen. Die gespeicherten Daten bleiben unverändert. + * + * @return list> + */ + public function sections(): array + { + return app(PageSections::class)->read($this->sections, $this->blocks); + } + + /** + * Widgets in Lesereihenfolge als aktuelle Hüllen. * * @return list> */ public function widgets(): array { - return app(WidgetRegistry::class)->read($this->blocks); + return app(PageSections::class)->flatten($this->sections()); } /** @@ -52,6 +65,6 @@ public function widgets(): array */ public function contentTitle(): ?string { - return app(WidgetRegistry::class)->pageTitle($this->blocks); + return app(PageSections::class)->pageTitle($this->sections()); } } diff --git a/app/Domain/Cms/PageService.php b/app/Domain/Cms/PageService.php index 9715a8a..760af6d 100644 --- a/app/Domain/Cms/PageService.php +++ b/app/Domain/Cms/PageService.php @@ -2,23 +2,27 @@ namespace App\Domain\Cms; -use App\Domain\Cms\Widgets\WidgetRegistry; +use App\Domain\Cms\Sections\PageSections; use App\Jobs\PublishPublicMedia; use App\Models\User; +use Illuminate\Support\Facades\Schema; use Illuminate\Validation\ValidationException; class PageService { - public function __construct(private readonly WidgetRegistry $widgets) {} + public function __construct(private readonly PageSections $sections) {} /** * Speichert einen Entwurf als neue Revision. Veröffentlicht nichts. * - * @param array $blocks Bausteine im Altformat oder als Widget-Hülle + * @param array $content Abschnitte mit Slots; flache Widgets (Altformat oder Hülle) + * werden als einspaltige Abschnitte übernommen */ - public function saveRevision(Page $page, array $blocks, ?string $seoTitle, ?string $seoDescription, ?User $author): PageRevision + public function saveRevision(Page $page, array $content, ?string $seoTitle, ?string $seoDescription, ?User $author): PageRevision { - return $this->storeRevision($page, $this->widgets->normalize($blocks), $seoTitle, $seoDescription, $author); + $sections = $this->sections->normalize($content); + + return $this->storeRevision($page, $this->sections->flatten($sections), $sections, $seoTitle, $seoDescription, $author); } public function publish(Page $page, PageRevision $revision): void @@ -34,7 +38,7 @@ public function publish(Page $page, PageRevision $revision): void } /** - * Legt den Stand einer früheren Revision unverändert als neue Revision an. Die gespeicherten Bausteine + * Legt den Stand einer früheren Revision unverändert als neue Revision an. Abschnitte und Bausteine * werden nicht umgeschrieben; ältere Formate werden erst beim Lesen angehoben. */ public function restore(Page $page, PageRevision $source, ?User $author): PageRevision @@ -48,12 +52,33 @@ public function restore(Page $page, PageRevision $source, ?User $author): PageRe return $this->storeRevision( $page, $source->blocks ?? [], + $source->sections, $source->seo_title, $source->seo_description, $author, ); } + /** + * Legt eine neue, unveröffentlichte Seite mit dem zuletzt gespeicherten Stand einer vorhandenen Seite an. + * Die Vorlage bleibt unverändert; spätere Änderungen wirken nicht auf die Kopie. + */ + public function duplicate(Page $source, string $path, ?User $author): Page + { + $revision = $source->latestRevision ?? $source->publishedRevision; + $page = Page::query()->create(['path' => $this->availablePath($path)]); + + $this->saveRevision( + $page, + $revision?->sections() ?? [], + $revision?->seo_title, + $revision?->seo_description, + $author, + ); + + return $page; + } + /** * Normalisiert den Pfad und prüft, dass keine andere Seite ihn verwendet. */ @@ -95,18 +120,27 @@ public function normalizePath(string $path): string } /** - * @param array $blocks + * @param array $blocks flache Widget-Liste (Rollback-Fassung) + * @param array|null $sections Abschnitte; null bei Revisionen aus der Zeit vor dem Raster */ - private function storeRevision(Page $page, array $blocks, ?string $seoTitle, ?string $seoDescription, ?User $author): PageRevision + private function storeRevision(Page $page, array $blocks, ?array $sections, ?string $seoTitle, ?string $seoDescription, ?User $author): PageRevision { - $revision = $page->revisions()->create([ + $attributes = [ 'blocks' => array_values($blocks), 'seo_title' => $seoTitle !== null && $seoTitle !== '' ? $seoTitle : null, 'seo_description' => $seoDescription !== null && $seoDescription !== '' ? $seoDescription : null, 'created_by' => $author?->id, - ]); + ]; - foreach ($this->widgets->mediaPaths($revision->blocks) as $path) { + // Die Erstbefüllung der Website läuft innerhalb einer frühen Migration, bevor die Spalte existiert. + // Solche Revisionen haben keine Abschnitte und werden beim Lesen als einspaltige Abschnitte gelesen. + if ($sections !== null && Schema::hasColumn('page_revisions', 'sections')) { + $attributes['sections'] = array_values($sections); + } + + $revision = $page->revisions()->create($attributes); + + foreach ($this->sections->mediaPaths($revision->sections()) as $path) { PublishPublicMedia::dispatch($path); } diff --git a/app/Domain/Cms/Sections/PageSections.php b/app/Domain/Cms/Sections/PageSections.php new file mode 100644 index 0000000..29b90c7 --- /dev/null +++ b/app/Domain/Cms/Sections/PageSections.php @@ -0,0 +1,345 @@ +|null $sections gespeicherte Abschnitte (Spalte sections) + * @param array|null $blocks flache Bausteinliste (Spalte blocks), nur ohne Abschnitte verwendet + * @return list, slots: list|null>}> + */ + public function read(?array $sections, ?array $blocks = null): array + { + if ($sections === null) { + return $this->wrapWidgets($blocks ?? []); + } + + $result = []; + + foreach (array_values($sections) as $section) { + if (is_array($section)) { + $result[] = $this->upcastSection($section); + } + } + + return $result; + } + + /** + * Schreibpfad: prüft und bereinigt Abschnitte für eine neue Revision. Flache Widgets (ohne „slots“) werden + * als einspaltige Abschnitte übernommen. Alle Fehler der Seite werden gesammelt gemeldet; Schlüssel: + * „sections.N.layout“, „sections.N.style.image“, „sections.N.slots“, „sections.N.slots.M.data.feld“. + * + * @param array $content + * @return list, slots: list|null>}> + */ + public function normalize(array $content): array + { + $items = array_values($content); + + if (count($items) > self::MAX_SECTIONS) { + throw ValidationException::withMessages([ + 'sections' => 'Eine Seite hat höchstens '.self::MAX_SECTIONS.' Abschnitte.', + ]); + } + + $errors = []; + $sections = []; + $seenSectionIds = []; + $seenWidgetIds = []; + $widgetCount = 0; + + foreach ($items as $index => $item) { + if (! is_array($item)) { + $errors["sections.$index"] = ['Ein Abschnitt ist unvollständig.']; + + continue; + } + + if (! array_key_exists('slots', $item)) { + $item = ['id' => null, 'layout' => SectionLayouts::DEFAULT, 'style' => [], 'slots' => [$item]]; + } + + $sections[] = $this->normalizeSection($item, $index, $errors, $seenSectionIds, $seenWidgetIds, $widgetCount); + } + + if ($widgetCount > self::MAX_WIDGETS) { + $errors['sections'] = ['Eine Seite enthält höchstens '.self::MAX_WIDGETS.' Widgets.']; + } + + if ($errors !== []) { + throw ValidationException::withMessages($errors); + } + + return $sections; + } + + /** + * Widgets in Lesereihenfolge (Abschnitt für Abschnitt, Slot für Slot). Wird zusätzlich als flache + * Bausteinliste gespeichert, damit ein Code-Rollback auf die Fassung vor den Abschnitten die Inhalte + * weiterhin untereinander darstellt. + * + * @param list> $sections + * @return list> + */ + public function flatten(array $sections): array + { + $widgets = []; + + foreach ($sections as $section) { + $count = SectionLayouts::slotCount($section['layout']); + + foreach (array_slice($section['slots'], 0, $count) as $widget) { + if (is_array($widget)) { + $widgets[] = $widget; + } + } + } + + return $widgets; + } + + /** + * Öffentliche Medien der Seite: Widget-Bilder und Hintergrundbilder der Abschnitte. + * + * @param list> $sections + * @return list + */ + public function mediaPaths(array $sections): array + { + $paths = []; + + foreach ($sections as $section) { + $style = SectionStyle::fromStored($section['style'] ?? []); + if ($style['image'] !== null && PublicMedia::isPublicPath($style['image'])) { + $paths[] = $style['image']; + } + } + + foreach ($this->widgets->mediaPaths($this->flatten($sections)) as $path) { + $paths[] = $path; + } + + return array_values(array_unique($paths)); + } + + /** + * @param list> $sections + */ + public function pageTitle(array $sections): ?string + { + return $this->widgets->pageTitle($this->flatten($sections)); + } + + /** + * @param array $blocks + * @return list, slots: list|null>}> + */ + private function wrapWidgets(array $blocks): array + { + $sections = []; + + foreach ($this->widgets->read($blocks) as $widget) { + $sections[] = [ + 'id' => null, + 'v' => self::VERSION, + 'layout' => SectionLayouts::DEFAULT, + // Bestand vor dem Raster stand in einem durchgehenden Blatt: kompakte Abstände kommen dem am nächsten. + 'style' => ['spacing' => 'compact'] + SectionStyle::DEFAULTS, + 'slots' => [$widget], + ]; + } + + return $sections; + } + + /** + * @param array $section + * @return array{id: ?string, v: int, layout: string, style: array, slots: list|null>} + */ + private function upcastSection(array $section): array + { + $layout = SectionLayouts::has($section['layout'] ?? null) ? $section['layout'] : SectionLayouts::DEFAULT; + $slots = []; + + foreach (array_values(is_array($section['slots'] ?? null) ? $section['slots'] : []) as $slot) { + $slots[] = is_array($slot) ? $this->widgets->upcast($slot) : null; + } + + while (count($slots) < SectionLayouts::slotCount($layout)) { + $slots[] = null; + } + + return [ + 'id' => is_string($section['id'] ?? null) ? $section['id'] : null, + 'v' => self::VERSION, + 'layout' => $layout, + 'style' => SectionStyle::fromStored($section['style'] ?? []), + 'slots' => $slots, + ]; + } + + /** + * @param array $section + * @param array> $errors + * @param array $seenSectionIds + * @param array $seenWidgetIds + * @return array{id: string, v: int, layout: string, style: array, slots: list|null>} + */ + private function normalizeSection(array $section, int $index, array &$errors, array &$seenSectionIds, array &$seenWidgetIds, int &$widgetCount): array + { + $prefix = "sections.$index"; + + $layout = $section['layout'] ?? SectionLayouts::DEFAULT; + if (! SectionLayouts::has($layout)) { + $errors["$prefix.layout"] = ['Dieses Abschnittsraster ist nicht freigegeben.']; + $layout = SectionLayouts::DEFAULT; + } + + $style = $this->normalizeStyle(is_array($section['style'] ?? null) ? $section['style'] : [], $prefix, $errors); + + $units = SectionLayouts::units($layout); + $rawSlots = array_values(is_array($section['slots'] ?? null) ? $section['slots'] : []); + $filled = count(array_filter($rawSlots, fn ($slot): bool => is_array($slot))); + + if ($filled > count($units)) { + $errors["$prefix.slots"] = [sprintf( + 'Das Raster „%s“ hat %d %s, der Abschnitt enthält aber %d Widgets. Entfernen Sie ein Widget oder wählen Sie ein Raster mit mehr Plätzen.', + SectionLayouts::short($layout), + count($units), + count($units) === 1 ? 'Platz' : 'Plätze', + $filled, + )]; + } elseif (count($rawSlots) > count($units)) { + // Überzählige Plätze sind leer: Widgets rücken in Reihenfolge nach vorn, leere Plätze entfallen. + $rawSlots = array_values(array_filter($rawSlots, fn ($slot): bool => is_array($slot))); + } + + $slots = []; + foreach ($units as $position => $slotUnits) { + $block = $rawSlots[$position] ?? null; + + if (! is_array($block)) { + $slots[] = null; + + continue; + } + + $widgetCount++; + + try { + $widget = $this->widgets->normalizeWidget($block, "$prefix.slots.$position", $seenWidgetIds); + } catch (ValidationException $exception) { + foreach ($exception->errors() as $key => $messages) { + $errors[$key] = $messages; + } + $slots[] = null; + + continue; + } + + $type = $this->widgets->get($widget['type']); + if ($slotUnits < $type->minUnits()) { + $errors["$prefix.slots.$position.units"] = [sprintf( + '„%s“ braucht mindestens %d Rastereinheiten; dieser Platz hat %d. Wählen Sie ein breiteres Raster oder einen breiteren Platz.', + $type->label(), + $type->minUnits(), + $slotUnits, + )]; + } + + $slots[] = $widget; + } + + $id = $section['id'] ?? null; + if (! is_string($id) || preg_match('/^[A-Za-z0-9-]{1,64}$/', $id) !== 1 || isset($seenSectionIds[$id])) { + $id = (string) Str::uuid(); + } + $seenSectionIds[$id] = true; + + return [ + 'id' => $id, + 'v' => self::VERSION, + 'layout' => $layout, + 'style' => $style, + 'slots' => $slots, + ]; + } + + /** + * @param array $style + * @param array> $errors + * @return array + */ + private function normalizeStyle(array $style, string $prefix, array &$errors): array + { + $result = SectionStyle::DEFAULTS; + $enums = SectionStyle::enums(); + + foreach ($style as $key => $value) { + if ($key === 'image' || str_starts_with((string) $key, '_')) { + continue; + } + + if (! isset($enums[$key])) { + $errors["$prefix.style.$key"] = ['Diese Gestaltungsoption ist nicht freigegeben.']; + + continue; + } + + if ($value === null || $value === '') { + continue; + } + + if (! is_string($value) || ! array_key_exists($value, $enums[$key])) { + $errors["$prefix.style.$key"] = ['Dieser Gestaltungswert ist nicht freigegeben.']; + + continue; + } + + $result[$key] = $value; + } + + $upload = PublicMedia::fromUploadState($style['_upload'] ?? null); + $image = $upload ?? PublicMedia::fromUploadState($style['image'] ?? null); + + if ($result['background'] === 'image') { + if ($image === null) { + $errors["$prefix.style.image"] = ['Bitte ein Hintergrundbild wählen oder hochladen.']; + } elseif (! PublicMedia::isPublicPath($image)) { + $errors["$prefix.style.image"] = ['Das Hintergrundbild liegt nicht im öffentlichen Medienbereich.']; + } + + $result['image'] = $image; + } else { + $result['image'] = null; + } + + return $result; + } +} diff --git a/app/Domain/Cms/Sections/SectionLayouts.php b/app/Domain/Cms/Sections/SectionLayouts.php new file mode 100644 index 0000000..5f604bd --- /dev/null +++ b/app/Domain/Cms/Sections/SectionLayouts.php @@ -0,0 +1,130 @@ +> */ + public const UNITS = [ + 'u4' => [4], + 'u2_2' => [2, 2], + 'u1_3' => [1, 3], + 'u3_1' => [3, 1], + 'u1_2_1' => [1, 2, 1], + 'u1_1_1_1' => [1, 1, 1, 1], + ]; + + /** @var array */ + public const LABELS = [ + 'u4' => 'Volle Breite', + 'u2_2' => 'Zwei gleich breit', + 'u1_3' => 'Schmal und breit', + 'u3_1' => 'Breit und schmal', + 'u1_2_1' => 'Mitte betont', + 'u1_1_1_1' => 'Vier gleich breit', + ]; + + public static function has(mixed $key): bool + { + return is_string($key) && isset(self::UNITS[$key]); + } + + /** + * @return list + */ + public static function units(string $key): array + { + return self::UNITS[$key] ?? self::UNITS[self::DEFAULT]; + } + + public static function slotCount(string $key): int + { + return count(self::units($key)); + } + + /** Kurzform wie „1 + 3“. */ + public static function short(string $key): string + { + return implode(' + ', self::units($key)); + } + + public static function label(string $key): string + { + return (self::LABELS[$key] ?? self::LABELS[self::DEFAULT]).' ('.self::short($key).')'; + } + + /** + * @return array + */ + public static function options(): array + { + $options = []; + foreach (array_keys(self::UNITS) as $key) { + $options[$key] = self::label($key); + } + + return $options; + } + + /** + * Spaltenvorlagen für die Slots, die tatsächlich etwas darstellen. + * + * - Desktop (Abschnitt ab 60rem): Verhältnis der Einheiten. + * - Tablet (ab 40rem): gleich breite Slots bleiben nebeneinander (zwei oder drei Spalten, vier Slots als 2 × 2); + * ungleiche Raster stapeln, damit kein Slot unter etwa 13rem fällt. + * - Smartphone: immer eine Spalte. Die Lese- und Fokusreihenfolge bleibt die Reihenfolge der Slots. + * + * @param list $units + * @return array{lg: string, md: string} + */ + public static function columns(array $units): array + { + $units = array_values(array_filter($units, fn ($unit): bool => is_int($unit) && $unit > 0)); + $count = count($units); + + if ($count <= 1) { + return ['lg' => 'minmax(0, 1fr)', 'md' => 'minmax(0, 1fr)']; + } + + $lg = implode(' ', array_map(fn (int $unit): string => "minmax(0, {$unit}fr)", $units)); + $equal = count(array_unique($units)) === 1; + + $md = match (true) { + ! $equal => 'minmax(0, 1fr)', + $count === 3 => 'repeat(3, minmax(0, 1fr))', + default => 'repeat(2, minmax(0, 1fr))', + }; + + return ['lg' => $lg, 'md' => $md]; + } + + /** + * Symbolbild des Rasters für die grafische Auswahl im Editor (rein dekorativ). + */ + public static function schematicSvg(string $key): string + { + $units = self::units($key); + $gap = 2; + $width = 56 - $gap * (count($units) - 1); + $x = 2; + $rects = ''; + + foreach ($units as $unit) { + $w = (int) round($width * $unit / 4); + $rects .= sprintf('', $x, $w); + $x += $w + $gap; + } + + return ''; + } +} diff --git a/app/Domain/Cms/Sections/SectionRenderer.php b/app/Domain/Cms/Sections/SectionRenderer.php new file mode 100644 index 0000000..bc71a60 --- /dev/null +++ b/app/Domain/Cms/Sections/SectionRenderer.php @@ -0,0 +1,127 @@ +> $sections gelesene Abschnitte (PageSections::read) + */ + public function renderAll(array $sections, RenderContext $context): HtmlString + { + $rendered = []; + $first = true; + + foreach ($sections as $section) { + $cells = []; + $units = SectionLayouts::units($section['layout']); + + foreach ($units as $position => $slotUnits) { + $widget = $section['slots'][$position] ?? null; + + if (! is_array($widget)) { + continue; + } + + $html = $this->widgets->renderWidget($widget, $context, $first); + + if ($html !== '') { + $first = false; + $cells[] = ['units' => $slotUnits, 'html' => $html]; + } + } + + if ($cells !== []) { + $rendered[] = ['section' => $section, 'cells' => $cells]; + } + } + + $html = ''; + $last = count($rendered) - 1; + + foreach ($rendered as $index => $item) { + $html .= $this->renderSection($item['section'], $item['cells'], $index); + + $divider = $item['section']['style']['divider'] ?? 'none'; + if ($index < $last && in_array($divider, ['line', 'accent'], true)) { + $html .= ''; + } + } + + return new HtmlString($html); + } + + /** + * @param array $section + * @param list $cells + */ + private function renderSection(array $section, array $cells, int $index): string + { + $style = SectionStyle::fromStored($section['style'] ?? []); + $columns = SectionLayouts::columns(array_column($cells, 'units')); + $hasImage = $style['background'] === 'image' && $style['image'] !== null && PublicMedia::isPublicPath($style['image']); + + $classes = [ + 'page-section', + 'section-bg-'.($hasImage ? 'image' : ($style['background'] === 'image' ? 'default' : $style['background'])), + 'section-width-'.$style['width'], + 'section-space-'.$style['spacing'], + 'section-layout-'.str_replace('_', '-', $section['layout']), + ]; + + if ($hasImage) { + $classes[] = 'section-overlay-'.$style['overlay']; + } + + // Bedeutungswerte der Fläche (tokens.css): helle Schrift auf dunklen Flächen, gelber Fokus. + $scope = match (true) { + $hasImage && $style['overlay'] === 'dark' => 'scope-dark', + $hasImage => 'scope-light', + $style['background'] === 'dark' => 'scope-dark', + $style['background'] === 'accent' => 'scope-accent', + default => null, + }; + if ($scope !== null) { + $classes[] = $scope; + } + + if ($style['divider'] === 'space') { + $classes[] = 'section-divider-space'; + } + + $id = is_string($section['id'] ?? null) ? ' id="bereich-'.e($section['id']).'"' : ''; + $html = '
'; + + if ($hasImage) { + // Das Bild des ersten Abschnitts ist meist das größte sichtbare Element und wird nicht verzögert geladen. + $loading = $index === 0 ? 'loading="eager" fetchpriority="high"' : 'loading="lazy"'; + $html .= ''; + } + + $html .= '
'; + + foreach ($cells as $cell) { + $html .= '
'.$cell['html'].'
'; + } + + return $html.'
'; + } +} diff --git a/app/Domain/Cms/Sections/SectionStyle.php b/app/Domain/Cms/Sections/SectionStyle.php new file mode 100644 index 0000000..4ff9ed8 --- /dev/null +++ b/app/Domain/Cms/Sections/SectionStyle.php @@ -0,0 +1,150 @@ + */ + public const BACKGROUNDS = [ + 'default' => 'Standard (ohne eigene Fläche)', + 'light' => 'Helle Markenfläche', + 'dark' => 'Dunkle Markenfläche', + 'accent' => 'Markenakzent', + 'image' => 'Hintergrundbild', + ]; + + /** @var array */ + public const WIDTHS = [ + 'narrow' => 'Schmal (Lesebreite)', + 'standard' => 'Standard', + 'wide' => 'Breit', + 'full' => 'Volle Breite', + ]; + + /** @var array */ + public const SPACINGS = [ + 'compact' => 'Kompakt', + 'normal' => 'Normal', + 'large' => 'Großzügig', + ]; + + /** @var array */ + public const DIVIDERS = [ + 'none' => 'Kein Trenner', + 'space' => 'Zusätzlicher Abstand', + 'line' => 'Dezente Linie', + 'accent' => 'Markenakzent', + ]; + + /** @var array */ + public const OVERLAYS = [ + 'light' => 'Helle Überlagerung (dunkle Schrift)', + 'dark' => 'Dunkle Überlagerung (helle Schrift)', + 'none' => 'Keine Überlagerung', + ]; + + /** @var array */ + public const FOCUS = [ + 'center' => 'Mitte', + 'top' => 'Oben', + 'bottom' => 'Unten', + 'left' => 'Links', + 'right' => 'Rechts', + 'top_left' => 'Oben links', + 'top_right' => 'Oben rechts', + 'bottom_left' => 'Unten links', + 'bottom_right' => 'Unten rechts', + ]; + + /** Fokuspunkt als Objektposition des Bildes; bestimmt den Zuschnitt auf schmalen Bildschirmen. */ + public const FOCUS_POSITIONS = [ + 'center' => '50% 50%', + 'top' => '50% 0%', + 'bottom' => '50% 100%', + 'left' => '0% 50%', + 'right' => '100% 50%', + 'top_left' => '0% 0%', + 'top_right' => '100% 0%', + 'bottom_left' => '0% 100%', + 'bottom_right' => '100% 100%', + ]; + + public const DEFAULTS = [ + 'background' => 'default', + 'image' => null, + 'focus' => 'center', + 'overlay' => 'light', + 'width' => 'standard', + 'spacing' => 'normal', + 'divider' => 'none', + ]; + + /** + * Aufzählungsfelder und ihre zulässigen Werte. + * + * @return array> + */ + public static function enums(): array + { + return [ + 'background' => self::BACKGROUNDS, + 'focus' => self::FOCUS, + 'overlay' => self::OVERLAYS, + 'width' => self::WIDTHS, + 'spacing' => self::SPACINGS, + 'divider' => self::DIVIDERS, + ]; + } + + /** + * Lesepfad: gespeicherte Werte; Unbekanntes fällt auf die Vorgabe zurück, damit alte oder fremde Daten + * nie eine Seite brechen. + * + * @return array{background: string, image: ?string, focus: string, overlay: string, width: string, spacing: string, divider: string} + */ + public static function fromStored(mixed $style): array + { + $style = is_array($style) ? $style : []; + $result = self::DEFAULTS; + + foreach (self::enums() as $key => $options) { + $value = $style[$key] ?? null; + if (is_string($value) && array_key_exists($value, $options)) { + $result[$key] = $value; + } + } + + $result['image'] = $result['background'] === 'image' && is_string($style['image'] ?? null) ? $style['image'] : null; + + return $result; + } + + /** + * Kurzbeschreibung für die Abschnittsliste im Editor. + * + * @param array $style + */ + public static function summary(array $style): string + { + $style = self::fromStored($style); + $parts = [self::BACKGROUNDS[$style['background']]]; + + if ($style['width'] !== 'standard') { + $parts[] = self::WIDTHS[$style['width']]; + } + + if ($style['spacing'] !== 'normal') { + $parts[] = 'Abstand '.mb_strtolower(self::SPACINGS[$style['spacing']]); + } + + if ($style['divider'] !== 'none') { + $parts[] = 'Trenner: '.self::DIVIDERS[$style['divider']]; + } + + return implode(' · ', $parts); + } +} diff --git a/app/Domain/Cms/SiteNavigation.php b/app/Domain/Cms/SiteNavigation.php new file mode 100644 index 0000000..f7c4595 --- /dev/null +++ b/app/Domain/Cms/SiteNavigation.php @@ -0,0 +1,104 @@ + $items sichtbare Einträge, sortiert + */ + public function __construct(private readonly Collection $items, private readonly string $currentPath) {} + + /** + * @param Collection $items + */ + public static function forPath(Collection $items, string $path): self + { + return new self($items, '/'.trim($path, '/')); + } + + /** + * Hauptnavigation mit einer Ebene Untermenü. Untereinträge eines ausgeblendeten Eintrags sind ebenfalls verborgen. + * + * @return list}> + */ + public function header(): array + { + $topLevel = $this->items->where('placement', 'header')->whereNull('parent_id'); + $entries = []; + + foreach ($topLevel as $item) { + $children = []; + + foreach ($this->items->where('parent_id', $item->id) as $child) { + $href = $child->href(); + if ($href !== null) { + $children[] = [ + 'id' => $child->id, + 'label' => $child->label, + 'href' => $href, + 'current' => $this->isCurrent($child), + ]; + } + } + + $href = $item->href(); + if ($href === null && $children === []) { + continue; + } + + $current = $href !== null && $this->isCurrent($item); + + $entries[] = [ + 'id' => $item->id, + 'label' => $item->label, + 'href' => $href, + 'current' => $current, + 'activeTrail' => $current || in_array(true, array_column($children, 'current'), true), + 'children' => $children, + ]; + } + + return $entries; + } + + /** + * Spalten des Fußbereichs in fester Reihenfolge; Gruppen ohne Einträge entfallen. + * + * @return list}> + */ + public function footerGroups(): array + { + $groups = []; + + foreach (NavigationItem::FOOTER_GROUPS as $placement => $heading) { + $links = []; + + foreach ($this->items->where('placement', $placement) as $item) { + $href = $item->href(); + if ($href !== null) { + $links[] = ['label' => $item->label, 'href' => $href, 'current' => $this->isCurrent($item)]; + } + } + + if ($links !== []) { + $groups[] = ['key' => $placement, 'heading' => $heading, 'links' => $links]; + } + } + + return $groups; + } + + private function isCurrent(NavigationItem $item): bool + { + return $item->targetPath() === $this->currentPath; + } +} diff --git a/app/Domain/Cms/Widgets/Types/CallToActionWidget.php b/app/Domain/Cms/Widgets/Types/CallToActionWidget.php index 90c4aec..3694a26 100644 --- a/app/Domain/Cms/Widgets/Types/CallToActionWidget.php +++ b/app/Domain/Cms/Widgets/Types/CallToActionWidget.php @@ -25,6 +25,23 @@ public function description(): string return 'Hervorgehobene Fläche mit Überschrift, Text und einer Schaltfläche.'; } + public function minUnits(): int + { + return 1; + } + + public function preferredUnits(): int + { + return 2; + } + + public function stages(): array + { + return [ + 'fluid' => 'Text und Schaltfläche untereinander, Schaltfläche volle Breite unter 20rem', + ]; + } + public function icon(): string { return 'heroicon-o-megaphone'; diff --git a/app/Domain/Cms/Widgets/Types/CardsWidget.php b/app/Domain/Cms/Widgets/Types/CardsWidget.php index 5eff5a7..20ceab5 100644 --- a/app/Domain/Cms/Widgets/Types/CardsWidget.php +++ b/app/Domain/Cms/Widgets/Types/CardsWidget.php @@ -35,6 +35,24 @@ public function description(): string return 'Mehrere Karten mit Titel, Text, Linkziel und optionalem Bild. Als Raster oder kompakte Liste.'; } + public function minUnits(): int + { + return 1; + } + + public function preferredUnits(): int + { + return 4; + } + + public function stages(): array + { + return [ + 'narrow' => 'eine Karte je Zeile', + 'wide' => 'so viele Karten nebeneinander, wie bei mindestens 14rem Kartenbreite passen', + ]; + } + public function icon(): string { return 'heroicon-o-squares-2x2'; diff --git a/app/Domain/Cms/Widgets/Types/CatalogCardsWidget.php b/app/Domain/Cms/Widgets/Types/CatalogCardsWidget.php index 8c0b63e..2150ab2 100644 --- a/app/Domain/Cms/Widgets/Types/CatalogCardsWidget.php +++ b/app/Domain/Cms/Widgets/Types/CatalogCardsWidget.php @@ -37,6 +37,24 @@ public function description(): string return 'Ausgewählte Programme und Module; Titel und Beschreibung kommen automatisch aus den Fachdaten.'; } + public function minUnits(): int + { + return 1; + } + + public function preferredUnits(): int + { + return 4; + } + + public function stages(): array + { + return [ + 'narrow' => 'eine Karte je Zeile, Symbolfläche über dem Text', + 'wide' => 'mehrere Karten nebeneinander ab 16rem Kartenbreite', + ]; + } + public function icon(): string { return 'heroicon-o-rectangle-stack'; diff --git a/app/Domain/Cms/Widgets/Types/FaqWidget.php b/app/Domain/Cms/Widgets/Types/FaqWidget.php index 37a6258..b8c332c 100644 --- a/app/Domain/Cms/Widgets/Types/FaqWidget.php +++ b/app/Domain/Cms/Widgets/Types/FaqWidget.php @@ -24,6 +24,23 @@ public function description(): string return 'Häufige Fragen mit Antworten.'; } + public function minUnits(): int + { + return 2; + } + + public function preferredUnits(): int + { + return 4; + } + + public function stages(): array + { + return [ + 'fluid' => 'Fragen untereinander; Antwortlänge auf Lesebreite begrenzt', + ]; + } + public function icon(): string { return 'heroicon-o-question-mark-circle'; diff --git a/app/Domain/Cms/Widgets/Types/HeadingWidget.php b/app/Domain/Cms/Widgets/Types/HeadingWidget.php index 7becae8..a8b9fa3 100644 --- a/app/Domain/Cms/Widgets/Types/HeadingWidget.php +++ b/app/Domain/Cms/Widgets/Types/HeadingWidget.php @@ -23,6 +23,23 @@ public function description(): string return 'Abschnittsüberschrift mit kurzem Einleitungstext.'; } + public function minUnits(): int + { + return 1; + } + + public function preferredUnits(): int + { + return 4; + } + + public function stages(): array + { + return [ + 'fluid' => 'Überschriftgröße folgt der Slotbreite', + ]; + } + public function icon(): string { return 'heroicon-o-h1'; diff --git a/app/Domain/Cms/Widgets/Types/HeroWidget.php b/app/Domain/Cms/Widgets/Types/HeroWidget.php index 1740703..a3e1949 100644 --- a/app/Domain/Cms/Widgets/Types/HeroWidget.php +++ b/app/Domain/Cms/Widgets/Types/HeroWidget.php @@ -30,6 +30,24 @@ public function description(): string return 'Großer Seiteneinstieg mit Überschrift, Beschreibung, optionalem Bild und optionaler Schaltfläche.'; } + public function minUnits(): int + { + return 2; + } + + public function preferredUnits(): int + { + return 4; + } + + public function stages(): array + { + return [ + 'narrow' => 'unter 48rem Slotbreite: Bild unter dem Text', + 'wide' => 'ab 48rem: Bild neben dem Text, größere Überschrift', + ]; + } + public function icon(): string { return 'heroicon-o-sparkles'; diff --git a/app/Domain/Cms/Widgets/Types/ImageTextWidget.php b/app/Domain/Cms/Widgets/Types/ImageTextWidget.php index b5d89ba..c882c35 100644 --- a/app/Domain/Cms/Widgets/Types/ImageTextWidget.php +++ b/app/Domain/Cms/Widgets/Types/ImageTextWidget.php @@ -35,6 +35,24 @@ public function description(): string return 'Bild neben formatiertem Text; Bild links oder rechts, auf dem Smartphone untereinander.'; } + public function minUnits(): int + { + return 2; + } + + public function preferredUnits(): int + { + return 4; + } + + public function stages(): array + { + return [ + 'narrow' => 'unter 36rem Slotbreite: Bild über dem Text', + 'wide' => 'ab 36rem: Bild links oder rechts neben dem Text', + ]; + } + public function version(): int { return 2; diff --git a/app/Domain/Cms/Widgets/Types/ProseWidget.php b/app/Domain/Cms/Widgets/Types/ProseWidget.php index dcb99b8..ac17ff1 100644 --- a/app/Domain/Cms/Widgets/Types/ProseWidget.php +++ b/app/Domain/Cms/Widgets/Types/ProseWidget.php @@ -23,6 +23,23 @@ public function description(): string return 'Längerer Text in Absätzen. Eine Leerzeile beginnt einen neuen Absatz.'; } + public function minUnits(): int + { + return 1; + } + + public function preferredUnits(): int + { + return 2; + } + + public function stages(): array + { + return [ + 'fluid' => 'Zeilenlänge höchstens etwa 70 Zeichen', + ]; + } + public function icon(): string { return 'heroicon-o-bars-3-bottom-left'; diff --git a/app/Domain/Cms/Widgets/WidgetRegistry.php b/app/Domain/Cms/Widgets/WidgetRegistry.php index 16db1ed..dcc505f 100644 --- a/app/Domain/Cms/Widgets/WidgetRegistry.php +++ b/app/Domain/Cms/Widgets/WidgetRegistry.php @@ -45,6 +45,10 @@ public function register(WidgetType $type): void throw new InvalidArgumentException("Widget „{$key}“ braucht eine Schemaversion ab 1."); } + if ($type->minUnits() < 1 || $type->minUnits() > 4 || $type->preferredUnits() < $type->minUnits() || $type->preferredUnits() > 4) { + throw new InvalidArgumentException("Widget „{$key}“ braucht eine Mindest- und Vorzugsbreite zwischen 1 und 4 Rastereinheiten."); + } + if ($type->variants() === []) { throw new InvalidArgumentException("Widget „{$key}“ braucht mindestens eine Darstellungsvariante."); } @@ -137,7 +141,7 @@ public function upcast(array $block): ?array } /** - * Prüft und bereinigt Bausteine für eine neue Revision. + * Prüft und bereinigt eine flache Bausteinliste (Fehlerschlüssel "blocks.N…"). * * @param array $blocks * @return list, data: array, refs: array}> @@ -148,42 +152,53 @@ public function normalize(array $blocks): array $seenIds = []; foreach (array_values($blocks) as $index => $block) { - if (! is_array($block)) { - throw ValidationException::withMessages([ - "blocks.$index" => 'Ein Baustein ist unvollständig.', - ]); - } - - if (! $this->has($block['type'] ?? null)) { - throw ValidationException::withMessages([ - "blocks.$index.type" => 'Dieser Bausteintyp ist nicht freigegeben.', - ]); - } - - $type = $this->get($block['type']); - - if (array_key_exists('v', $block) && (int) $block['v'] > $type->version()) { - throw ValidationException::withMessages([ - "blocks.$index.v" => 'Dieser Baustein stammt aus einer neueren Programmfassung und kann hier nicht gespeichert werden.', - ]); - } - - $requested = $block['variant'] ?? null; - $isCurrent = array_key_exists('v', $block) && (int) $block['v'] === $type->version(); - - if ($isCurrent && is_string($requested) && $requested !== '' && ! array_key_exists($requested, $type->variants())) { - throw ValidationException::withMessages([ - "blocks.$index.variant" => 'Diese Darstellungsvariante ist für den Baustein nicht freigegeben.', - ]); - } - - $widget = $this->upcast($block); - $normalized[] = $this->validateOne($type, $widget, $index, $seenIds); + $normalized[] = $this->normalizeWidget($block, "blocks.$index", $seenIds); } return $normalized; } + /** + * Prüft und bereinigt einen einzelnen Baustein für eine neue Revision. Der Aufrufer führt die Menge + * bereits vergebener Kennungen über die ganze Seite, damit kopierte Widgets neue Kennungen erhalten. + * + * @param array $seenIds + * @return array{id: string, type: string, v: int, variant: string, settings: array, data: array, refs: array} + */ + public function normalizeWidget(mixed $block, string $errorPrefix, array &$seenIds): array + { + if (! is_array($block)) { + throw ValidationException::withMessages([ + $errorPrefix => 'Ein Baustein ist unvollständig.', + ]); + } + + if (! $this->has($block['type'] ?? null)) { + throw ValidationException::withMessages([ + "$errorPrefix.type" => 'Dieser Bausteintyp ist nicht freigegeben.', + ]); + } + + $type = $this->get($block['type']); + + if (array_key_exists('v', $block) && (int) $block['v'] > $type->version()) { + throw ValidationException::withMessages([ + "$errorPrefix.v" => 'Dieser Baustein stammt aus einer neueren Programmfassung und kann hier nicht gespeichert werden.', + ]); + } + + $requested = $block['variant'] ?? null; + $isCurrent = array_key_exists('v', $block) && (int) $block['v'] === $type->version(); + + if ($isCurrent && is_string($requested) && $requested !== '' && ! array_key_exists($requested, $type->variants())) { + throw ValidationException::withMessages([ + "$errorPrefix.variant" => 'Diese Darstellungsvariante ist für den Baustein nicht freigegeben.', + ]); + } + + return $this->validateOne($type, $this->upcast($block), $errorPrefix, $seenIds); + } + /** * Gespeicherte Bausteine einer Revision als aktuelle Hüllen; unbekannte Arten entfallen. * @@ -241,7 +256,7 @@ public function mediaPaths(?array $blocks): array * @param array $seenIds * @return array{id: string, type: string, v: int, variant: string, settings: array, data: array, refs: array} */ - private function validateOne(WidgetType $type, array $widget, int $index, array &$seenIds): array + private function validateOne(WidgetType $type, array $widget, string $errorPrefix, array &$seenIds): array { $errors = new WidgetErrors; @@ -292,7 +307,7 @@ private function validateOne(WidgetType $type, array $widget, int $index, array if (! $errors->isEmpty()) { $messages = []; foreach ($errors->all() as $key => $list) { - $messages["blocks.$index.$key"] = $list; + $messages["$errorPrefix.$key"] = $list; } throw ValidationException::withMessages($messages); diff --git a/app/Domain/Cms/Widgets/WidgetType.php b/app/Domain/Cms/Widgets/WidgetType.php index a3acc98..b2430b5 100644 --- a/app/Domain/Cms/Widgets/WidgetType.php +++ b/app/Domain/Cms/Widgets/WidgetType.php @@ -34,6 +34,32 @@ public function version(): int return 1; } + /** + * Kleinste Slotbreite in logischen Rastereinheiten (1 bis 4), in der das Widget auf dem Desktop lesbar bleibt. + * Ein schmalerer Slot wird beim Speichern abgewiesen. Auf Tablet und Smartphone stapeln die Slots ohnehin. + */ + public function minUnits(): int + { + return 1; + } + + /** Empfohlene Slotbreite in Rastereinheiten; Hinweis in der Widget-Auswahl. */ + public function preferredUnits(): int + { + return 4; + } + + /** + * Darstellungsstufen nach verfügbarer Breite (Container-Abfragen in der Widget-Ansicht): Kennung => Beschreibung. + * Dokumentiert, wie sich das Widget an schmale und breite Slots anpasst. + * + * @return array + */ + public function stages(): array + { + return ['fluid' => 'passt sich fließend an jede Slotbreite an']; + } + /** Heroicon-Name für Auswahl und Liste im Editor. */ public function icon(): string { diff --git a/app/Filament/Resources/NavigationItems/NavigationItemResource.php b/app/Filament/Resources/NavigationItems/NavigationItemResource.php index 58a4ed2..8bbe5f5 100644 --- a/app/Filament/Resources/NavigationItems/NavigationItemResource.php +++ b/app/Filament/Resources/NavigationItems/NavigationItemResource.php @@ -40,7 +40,31 @@ public static function form(Schema $schema): Schema ->label('Platz') ->options(NavigationItem::PLACEMENTS) ->default('header') - ->required(), + ->required() + ->live() + ->helperText('Kopfzeile: Hauptnavigation. Fußbereich: drei Spalten „Service“, „Kontakt“ und „Rechtliches“.'), + Select::make('parent_id') + ->label('Untermenü von') + ->placeholder('Oberste Ebene') + ->options(fn (?NavigationItem $record): array => NavigationItem::query() + ->where('placement', 'header') + ->whereNull('parent_id') + ->when($record !== null, fn ($query) => $query->whereKeyNot($record->getKey())) + ->orderBy('sort_order') + ->pluck('label', 'id') + ->all()) + ->visible(fn (Get $get): bool => $get('placement') === 'header') + ->disabled(fn (?NavigationItem $record): bool => $record !== null && $record->children()->exists()) + ->helperText('Eine Ebene Untermenü in der Hauptnavigation. Ein Eintrag mit eigenen Untereinträgen bleibt oberste Ebene.') + ->rule(fn (?NavigationItem $record): Closure => function (string $attribute, mixed $value, Closure $fail) use ($record): void { + if (blank($value)) { + return; + } + $parent = NavigationItem::query()->find($value); + if ($parent === null || $parent->placement !== 'header' || $parent->parent_id !== null || ($record !== null && $parent->is($record))) { + $fail('Untermenüs sind nur unter einem Eintrag der obersten Ebene der Hauptnavigation möglich.'); + } + }), Select::make('page_id') ->label('Interne Seite') ->options(fn (): array => Page::query()->orderBy('path')->pluck('path', 'id')->all()) @@ -51,9 +75,10 @@ public static function form(Schema $schema): Schema ->maxLength(500) ->helperText('Nur wenn keine Seite gewählt ist: Pfad wie /anmelden oder eine vollständige http(s)-Adresse.') ->rule(SafeUrl::rule()) - ->rule(function (Get $get): Closure { - return function (string $attribute, mixed $value, Closure $fail) use ($get): void { - if (blank($get('page_id')) && blank($value)) { + ->rule(function (Get $get, ?NavigationItem $record): Closure { + return function (string $attribute, mixed $value, Closure $fail) use ($get, $record): void { + // Ein Eintrag mit Untereinträgen darf ohne eigenes Ziel nur das Untermenü öffnen. + if (blank($get('page_id')) && blank($value) && ! ($record?->children()->exists() ?? false)) { $fail('Wählen Sie eine Seite oder eine Adresse.'); } }; @@ -75,7 +100,11 @@ public static function table(Table $table): Table { return $table ->columns([ - TextColumn::make('label')->label('Beschriftung')->searchable(), + TextColumn::make('label') + ->label('Beschriftung') + ->searchable() + ->formatStateUsing(fn (string $state, NavigationItem $record): string => $record->parent_id !== null ? '↳ '.$state : $state) + ->description(fn (NavigationItem $record): ?string => $record->parent !== null ? 'Untermenü von „'.$record->parent->label.'“' : null), TextColumn::make('target') ->label('Ziel') ->state(fn (NavigationItem $record): string => $record->page?->path ?? (string) $record->url), @@ -88,7 +117,7 @@ public static function table(Table $table): Table Group::make('placement') ->label('Platz') ->getTitleFromRecordUsing(fn (NavigationItem $record): string => NavigationItem::PLACEMENTS[$record->placement] ?? $record->placement) - ->orderQueryUsing(fn ($query, string $direction) => $query->orderByRaw("CASE placement WHEN 'header' THEN 0 ELSE 1 END")) + ->orderQueryUsing(fn ($query, string $direction) => $query->orderByRaw("CASE placement WHEN 'header' THEN 0 WHEN 'footer' THEN 1 WHEN 'footer_contact' THEN 2 WHEN 'footer_legal' THEN 3 ELSE 4 END")) ->collapsible(), ) ->paginated([50, 100]) @@ -110,7 +139,7 @@ public static function table(Table $table): Table ->action(fn (NavigationItem $record) => $record->update(['is_visible' => ! $record->is_visible])), EditAction::make(), DeleteAction::make() - ->modalDescription('Der Eintrag wird aus der Navigation entfernt. Die verlinkte Seite bleibt bestehen.'), + ->modalDescription('Der Eintrag wird aus der Navigation entfernt. Die verlinkte Seite bleibt bestehen; Untereinträge rücken in die oberste Ebene.'), ]); } diff --git a/app/Filament/Resources/Pages/PageResource.php b/app/Filament/Resources/Pages/PageResource.php index ea601b3..562d878 100644 --- a/app/Filament/Resources/Pages/PageResource.php +++ b/app/Filament/Resources/Pages/PageResource.php @@ -4,11 +4,13 @@ use App\Domain\Catalog\Pillar; use App\Domain\Cms\Page; +use App\Domain\Cms\PageService; use App\Filament\Resources\Pages\Pages\CreatePage; use App\Filament\Resources\Pages\Pages\EditPage; use App\Filament\Resources\Pages\Pages\ListPages; use App\Filament\Resources\Pages\RelationManagers\RevisionsRelationManager; -use App\Filament\Support\WidgetEditor; +use App\Filament\Support\SectionEditor; +use Filament\Actions\Action; use Filament\Forms\Components\CheckboxList; use Filament\Forms\Components\Textarea; use Filament\Forms\Components\TextInput; @@ -17,6 +19,7 @@ use Filament\Schemas\Schema; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Table; +use Illuminate\Validation\ValidationException; class PageResource extends Resource { @@ -36,6 +39,8 @@ public static function form(Schema $schema): Schema Section::make('Seite und Suchmaschinen') ->description('Adresse, Titel für Suchmaschinen und Zuordnung zu Themenbereichen.') ->collapsible() + ->collapsed(fn (string $operation): bool => $operation === 'edit') + ->persistCollapsed() ->columns(2) ->columnSpanFull() ->schema([ @@ -55,13 +60,14 @@ public static function form(Schema $schema): Schema ->label('Fachliche Säulen') ->options(fn (): array => Pillar::query()->orderBy('name')->pluck('name', 'id')->all()) ->helperText('Eine veröffentlichte Seite erscheint auf den gewählten Themenbereichen der Website. Eine Seite kann mehreren Säulen zugeordnet sein.') - ->columns(1), + ->columns(['default' => 1, 'lg' => 2]), ]), Section::make('Inhalt der Seite') - ->description('Abschnitte hinzufügen, per Klick auf die Vorschau bearbeiten, mit den Pfeilen sortieren. Speichern legt einen Entwurf an; veröffentlicht wird erst über „Veröffentlichen“.') + ->description('Abschnitt hinzufügen, Raster wählen, Widgets in die Plätze einsetzen. Ein Klick auf die Vorschau eines Widgets öffnet seinen Dialog; Hintergrund, Breite, Abstand und Trenner stehen unter „Gestaltung des Abschnitts“. Speichern legt einen Entwurf an; veröffentlicht wird erst über „Veröffentlichen“.') ->columnSpanFull() + ->extraAttributes(['class' => 'luf-page-content']) ->schema([ - WidgetEditor::builder('blocks'), + SectionEditor::repeater('sections'), ]), ]); } @@ -76,7 +82,34 @@ public static function table(Table $table): Table ->formatStateUsing(fn ($state): string => $state ? 'Ja' : 'Entwurf'), TextColumn::make('updated_at')->label('Geändert')->dateTime('d.m.Y H:i'), ]) - ->recordUrl(fn (Page $record): string => static::getUrl('edit', ['record' => $record])); + ->recordUrl(fn (Page $record): string => static::getUrl('edit', ['record' => $record])) + ->recordActions([ + Action::make('duplicate') + ->label('Duplizieren') + ->icon('heroicon-o-document-duplicate') + ->color('gray') + ->tooltip('Neue, unveröffentlichte Seite mit dem zuletzt gespeicherten Stand dieser Seite anlegen') + ->authorize(fn (): bool => auth()->user()?->can('create', Page::class) ?? false) + ->modalHeading(fn (Page $record): string => 'Seite '.$record->path.' duplizieren') + ->modalDescription('Die Kopie ist ein Entwurf unter neuer Adresse. Die Vorlage bleibt unverändert.') + ->schema([ + TextInput::make('path') + ->label('Pfad der neuen Seite') + ->required() + ->maxLength(255) + ->helperText('Zum Beispiel /neue-landingpage'), + ]) + ->modalSubmitActionLabel('Duplizieren') + ->action(function (Page $record, array $data, PageService $service) { + try { + $copy = $service->duplicate($record, $data['path'], auth()->user()); + } catch (ValidationException $exception) { + throw ValidationException::withMessages(['mountedActions.0.data.path' => $exception->errors()['path'] ?? $exception->errors()]); + } + + return redirect(static::getUrl('edit', ['record' => $copy])); + }), + ]); } public static function getRelations(): array diff --git a/app/Filament/Resources/Pages/Pages/CreatePage.php b/app/Filament/Resources/Pages/Pages/CreatePage.php index 14f3b59..1084a71 100644 --- a/app/Filament/Resources/Pages/Pages/CreatePage.php +++ b/app/Filament/Resources/Pages/Pages/CreatePage.php @@ -6,16 +6,23 @@ use App\Domain\Cms\Page; use App\Domain\Cms\PageService; use App\Filament\Resources\Pages\PageResource; -use App\Filament\Support\WidgetEditor; +use App\Filament\Support\ReportsSectionErrors; +use App\Filament\Support\SectionEditor; use Filament\Resources\Pages\CreateRecord; +use Filament\Support\Enums\Width; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\DB; use Illuminate\Validation\ValidationException; class CreatePage extends CreateRecord { + use ReportsSectionErrors; + protected static string $resource = PageResource::class; + /** Breite Arbeitsfläche, damit mehrspaltige Raster im Editor erkennbar bleiben. */ + protected Width|string|null $maxContentWidth = Width::Full; + protected static bool $canCreateAnother = false; /** @@ -24,17 +31,17 @@ class CreatePage extends CreateRecord protected function handleRecordCreation(array $data): Model { $service = app(PageService::class); - $blocks = WidgetEditor::fromBuilderState($data['blocks'] ?? []); + $content = SectionEditor::fromEditorState($data['sections'] ?? []); try { - return DB::transaction(function () use ($service, $data, $blocks): Page { + return DB::transaction(function () use ($service, $data, $content): Page { $page = Page::query()->create([ 'path' => $service->availablePath($data['path']), ]); $service->saveRevision( $page, - $blocks, + $content, $data['seo_title'] ?? null, $data['seo_description'] ?? null, auth()->user(), @@ -45,10 +52,10 @@ protected function handleRecordCreation(array $data): Model return $page; }); } catch (ValidationException $exception) { - WidgetEditor::notifyErrors($exception->errors(), $blocks); + SectionEditor::notifyErrors($exception->errors(), $this->data['sections'] ?? []); throw ValidationException::withMessages( - WidgetEditor::mapErrors($exception->errors(), array_keys($this->data['blocks'] ?? [])), + SectionEditor::mapErrors($exception->errors(), $this->data['sections'] ?? []), ); } } diff --git a/app/Filament/Resources/Pages/Pages/EditPage.php b/app/Filament/Resources/Pages/Pages/EditPage.php index 9cc2a58..d6fbf84 100644 --- a/app/Filament/Resources/Pages/Pages/EditPage.php +++ b/app/Filament/Resources/Pages/Pages/EditPage.php @@ -6,17 +6,24 @@ use App\Domain\Cms\Page; use App\Domain\Cms\PageService; use App\Filament\Resources\Pages\PageResource; -use App\Filament\Support\WidgetEditor; +use App\Filament\Support\ReportsSectionErrors; +use App\Filament\Support\SectionEditor; use Filament\Actions\Action; use Filament\Notifications\Notification; use Filament\Resources\Pages\EditRecord; +use Filament\Support\Enums\Width; use Illuminate\Database\Eloquent\Model; use Illuminate\Validation\ValidationException; class EditPage extends EditRecord { + use ReportsSectionErrors; + protected static string $resource = PageResource::class; + /** Breite Arbeitsfläche, damit mehrspaltige Raster im Editor erkennbar bleiben. */ + protected Width|string|null $maxContentWidth = Width::Full; + protected function getHeaderActions(): array { return [ @@ -85,7 +92,7 @@ protected function afterSave(): void protected function mutateFormDataBeforeFill(array $data): array { $revision = $this->record->latestRevision ?? $this->record->publishedRevision; - $data['blocks'] = WidgetEditor::toBuilderState($revision?->blocks); + $data['sections'] = SectionEditor::toEditorState($revision?->sections() ?? []); $data['seo_title'] = $revision?->seo_title; $data['seo_description'] = $revision?->seo_description; $data['pillars'] = $this->record->pillars()->pluck('pillars.id')->all(); @@ -100,16 +107,16 @@ protected function handleRecordUpdate(Model $record, array $data): Model { /** @var Page $record */ $service = app(PageService::class); - $blocks = WidgetEditor::fromBuilderState($data['blocks'] ?? []); + $content = SectionEditor::fromEditorState($data['sections'] ?? []); try { $path = $service->availablePath($data['path'], $record); - $service->saveRevision($record, $blocks, $data['seo_title'] ?? null, $data['seo_description'] ?? null, auth()->user()); + $service->saveRevision($record, $content, $data['seo_title'] ?? null, $data['seo_description'] ?? null, auth()->user()); } catch (ValidationException $exception) { - WidgetEditor::notifyErrors($exception->errors(), $blocks); + SectionEditor::notifyErrors($exception->errors(), $this->data['sections'] ?? []); throw ValidationException::withMessages( - WidgetEditor::mapErrors($exception->errors(), array_keys($this->data['blocks'] ?? [])), + SectionEditor::mapErrors($exception->errors(), $this->data['sections'] ?? []), ); } diff --git a/app/Filament/Resources/Pages/RelationManagers/RevisionsRelationManager.php b/app/Filament/Resources/Pages/RelationManagers/RevisionsRelationManager.php index 79c4739..0318e80 100644 --- a/app/Filament/Resources/Pages/RelationManagers/RevisionsRelationManager.php +++ b/app/Filament/Resources/Pages/RelationManagers/RevisionsRelationManager.php @@ -24,8 +24,11 @@ public function table(Table $table): Table TextColumn::make('id')->label('Nr.'), TextColumn::make('created_at')->label('Gespeichert')->dateTime('d.m.Y H:i'), TextColumn::make('author.name')->label('Von'), - TextColumn::make('sections') + TextColumn::make('section_count') ->label('Abschnitte') + ->state(fn (PageRevision $record): int => count($record->sections())), + TextColumn::make('widget_count') + ->label('Widgets') ->state(fn (PageRevision $record): int => count($record->widgets())), TextColumn::make('published') ->label('Live') diff --git a/app/Filament/Support/ReportsSectionErrors.php b/app/Filament/Support/ReportsSectionErrors.php new file mode 100644 index 0000000..8da85e3 --- /dev/null +++ b/app/Filament/Support/ReportsSectionErrors.php @@ -0,0 +1,35 @@ +data['sections'] ?? null) ? $this->data['sections'] : []; + $sectionErrors = SectionEditor::sectionErrorsFromForm($exception->errors(), $state); + + if ($sectionErrors === []) { + return; + } + + SectionEditor::notifyErrors($sectionErrors, $state); + + foreach (SectionEditor::mapErrors($sectionErrors, $state) as $key => $messages) { + if (str_ends_with($key, '.slots')) { + foreach ((array) $messages as $message) { + $exception->validator->errors()->add($key, $message); + } + } + } + } +} diff --git a/app/Filament/Support/SectionEditor.php b/app/Filament/Support/SectionEditor.php new file mode 100644 index 0000000..340f91f --- /dev/null +++ b/app/Filament/Support/SectionEditor.php @@ -0,0 +1,516 @@ +label('Abschnitte') + ->hiddenLabel() + ->schema(self::sectionSchema()) + ->itemLabel(fn (array $state, ?int $index): string => self::sectionLabel($state, $index)) + ->addActionLabel('Abschnitt hinzufügen') + ->addBetweenActionLabel('Abschnitt hier einfügen') + ->defaultItems(0) + ->reorderableWithButtons() + ->reorderableWithDragAndDrop() + ->cloneable() + ->collapsible() + ->deletable() + ->maxItems(PageSections::MAX_SECTIONS) + ->cloneAction(fn (Action $action): Action => $action->tooltip('Abschnitt duplizieren')) + ->deleteAction(fn (Action $action): Action => $action + ->tooltip('Abschnitt löschen') + ->requiresConfirmation() + ->modalHeading('Abschnitt löschen?') + ->modalDescription('Der Abschnitt und die Widgets darin werden aus dem Entwurf entfernt. Bereits gespeicherte Revisionen bleiben erhalten.') + ->modalSubmitActionLabel('Löschen')) + ->moveUpAction(fn (Action $action): Action => $action->tooltip('Abschnitt nach oben')) + ->moveDownAction(fn (Action $action): Action => $action->tooltip('Abschnitt nach unten')) + ->reorderAction(fn (Action $action): Action => $action->tooltip('Abschnitt ziehen')) + ->collapseAction(fn (Action $action): Action => $action->tooltip('Abschnitt einklappen')) + ->expandAction(fn (Action $action): Action => $action->tooltip('Abschnitt aufklappen')) + ->extraAttributes(['class' => 'luf-sections']) + ->columnSpanFull(); + } + + /** + * @return list + */ + private static function sectionSchema(): array + { + return [ + Hidden::make('id'), + ToggleButtons::make('layout') + ->label('Raster') + ->options(self::layoutOptions()) + ->default(SectionLayouts::DEFAULT) + ->required() + ->inline() + ->live() + ->disableOptionWhen(fn (string $value, Get $get): bool => self::filledCount($get('slots')) > SectionLayouts::slotCount($value)) + ->helperText(fn (Get $get): ?string => self::filledCount($get('slots')) > 1 + ? 'Raster mit weniger Plätzen als eingesetzten Widgets sind gesperrt. Entfernen oder verschieben Sie zuerst ein Widget; beim Wechsel geht kein Widget verloren.' + : null) + ->afterStateUpdated(function (?string $state, Get $get, Set $set): void { + $set('slots', self::arrangeSlots($get('slots'), $state ?? SectionLayouts::DEFAULT)); + }) + ->extraAttributes(['class' => 'luf-layout-picker']), + Section::make('Gestaltung des Abschnitts') + ->description(fn (Get $get): string => SectionStyle::summary(is_array($get('style')) ? $get('style') : [])) + ->icon('heroicon-o-swatch') + ->collapsible() + ->collapsed() + ->compact() + ->schema([ + Group::make(self::styleFields()) + ->statePath('style') + ->columns(['default' => 1, 'md' => 2, 'xl' => 4]), + ]), + Repeater::make('slots') + ->label('Plätze im Raster') + ->hiddenLabel() + ->schema([ + WidgetEditor::slotBuilder('widget'), + ]) + ->addable(false) + ->deletable(false) + ->reorderableWithDragAndDrop() + ->reorderableWithButtons(false) + ->reorderAction(fn (Action $action): Action => $action->tooltip('Widget auf einen anderen Platz ziehen')) + ->itemLabel(fn (array $state, ?int $index, Get $get): string => self::slotLabel($state, $index, $get('layout'))) + ->default(fn (): array => self::arrangeSlots([], SectionLayouts::DEFAULT)) + ->extraAttributes(fn (Get $get): array => [ + 'class' => 'luf-slots', + 'style' => '--luf-slot-cols: '.self::editorColumns($get('layout')), + ]), + ]; + } + + /** + * @return list + */ + private static function styleFields(): array + { + return [ + Select::make('background') + ->label('Hintergrund') + ->options(SectionStyle::BACKGROUNDS) + ->default('default') + ->selectablePlaceholder(false) + ->live(), + Select::make('width') + ->label('Breite') + ->options(SectionStyle::WIDTHS) + ->default('standard') + ->selectablePlaceholder(false) + ->helperText('Ein Hintergrund reicht immer über die ganze Bildschirmbreite.'), + Select::make('spacing') + ->label('Abstand oben und unten') + ->options(SectionStyle::SPACINGS) + ->default('normal') + ->selectablePlaceholder(false), + Select::make('divider') + ->label('Trenner zum nächsten Abschnitt') + ->options(SectionStyle::DIVIDERS) + ->default('none') + ->selectablePlaceholder(false), + Select::make('image') + ->label('Hintergrundbild: vorhandenes Bild') + ->options(fn (): array => PublicMedia::imageOptions()) + ->searchable() + ->placeholder('Bitte wählen') + ->helperText('Nur Bilder aus dem öffentlichen Website-Bereich. Geschützte Filmbilder sind hier nicht wählbar.') + ->visible(fn (Get $get): bool => $get('background') === 'image') + ->columnSpan(['default' => 1, 'md' => 2]), + FileUpload::make('_upload') + ->label('Hintergrundbild: neu hochladen') + ->disk('cms_incoming') + ->directory('cms') + ->image() + ->maxSize(8192) + ->acceptedFileTypes(['image/jpeg', 'image/png', 'image/webp']) + ->getUploadedFileNameForStorageUsing(fn (TemporaryUploadedFile $file): string => Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)).'-'.Str::lower(Str::random(6)).'.'.$file->guessExtension()) + ->helperText('Ersetzt die Auswahl links. Nur Bilder mit geklärter Veröffentlichungsfreigabe hochladen.') + ->visible(fn (Get $get): bool => $get('background') === 'image') + ->columnSpan(['default' => 1, 'md' => 2]), + Select::make('focus') + ->label('Bildausschnitt (Fokuspunkt)') + ->options(SectionStyle::FOCUS) + ->default('center') + ->selectablePlaceholder(false) + ->helperText('Dieser Bereich bleibt auf schmalen Bildschirmen sichtbar.') + ->visible(fn (Get $get): bool => $get('background') === 'image'), + Select::make('overlay') + ->label('Überlagerung') + ->options(SectionStyle::OVERLAYS) + ->default('light') + ->selectablePlaceholder(false) + ->helperText('Sorgt für lesbaren Text auf dem Bild.') + ->visible(fn (Get $get): bool => $get('background') === 'image'), + ]; + } + + /** + * Gespeicherte Abschnitte (PageSections::read) als Formularzustand. + * + * @param list> $sections + * @return list> + */ + public static function toEditorState(array $sections): array + { + $state = []; + + foreach ($sections as $section) { + $slots = []; + + foreach ($section['slots'] as $widget) { + $slots[(string) Str::uuid()] = [ + 'widget' => is_array($widget) ? self::keyed(WidgetEditor::toBuilderState([$widget])) : [], + ]; + } + + $state[] = [ + 'id' => $section['id'] ?? (string) Str::uuid(), + 'layout' => $section['layout'], + 'style' => SectionStyle::fromStored($section['style'] ?? []), + 'slots' => $slots, + ]; + } + + return $state; + } + + /** + * Formularzustand als Abschnitte für PageService::saveRevision(). + * + * @param array|null $state + * @return list> + */ + public static function fromEditorState(?array $state): array + { + $sections = []; + + foreach (array_values($state ?? []) as $section) { + if (! is_array($section)) { + continue; + } + + $slots = []; + foreach (array_values(is_array($section['slots'] ?? null) ? $section['slots'] : []) as $slot) { + $items = is_array($slot['widget'] ?? null) ? $slot['widget'] : []; + $slots[] = $items === [] ? null : (WidgetEditor::fromBuilderState($items)[0] ?? null); + } + + $sections[] = [ + 'id' => $section['id'] ?? null, + 'layout' => $section['layout'] ?? SectionLayouts::DEFAULT, + 'style' => is_array($section['style'] ?? null) ? $section['style'] : [], + 'slots' => $slots, + ]; + } + + return $sections; + } + + /** + * Übersetzt Fehlerschlüssel aus PageSections ("sections.2.slots.1.data.heading") in Formularpfade. + * Widget-Fehler stehen zusätzlich als Zusammenfassung am Platzraster des Abschnitts, weil die Widget-Felder + * nach dem Schließen des Dialogs nicht sichtbar sind. + * + * @param array $errors + * @param array $state roher Formularzustand der Abschnitte + * @return array + */ + public static function mapErrors(array $errors, array $state, string $statePath = 'data.sections'): array + { + $registry = app(WidgetRegistry::class); + $sectionKeys = array_keys($state); + $mapped = []; + + foreach ($errors as $key => $messages) { + $messages = (array) $messages; + + if (preg_match('/^sections\.(\d+)(?:\.(.*))?$/', (string) $key, $match) !== 1 || ! isset($sectionKeys[(int) $match[1]])) { + $mapped[$key === 'sections' ? $statePath : 'data.'.$key] = $messages; + + continue; + } + + $sectionKey = $sectionKeys[(int) $match[1]]; + $sectionPath = "$statePath.$sectionKey"; + $rest = $match[2] ?? ''; + + if (preg_match('/^slots\.(\d+)(?:\.(.*))?$/', $rest, $slotMatch) === 1) { + $slotKeys = array_keys(is_array($state[$sectionKey]['slots'] ?? null) ? $state[$sectionKey]['slots'] : []); + $slotKey = $slotKeys[(int) $slotMatch[1]] ?? null; + $field = $slotMatch[2] ?? ''; + $position = (int) $slotMatch[1] + 1; + $widgetItems = $slotKey !== null ? ($state[$sectionKey]['slots'][$slotKey]['widget'] ?? []) : []; + $widgetKey = is_array($widgetItems) ? array_key_first($widgetItems) : null; + $type = $widgetKey !== null ? ($widgetItems[$widgetKey]['type'] ?? null) : null; + $label = $registry->has($type) ? $registry->get($type)->label() : 'Widget'; + + $summary = $mapped["$sectionPath.slots"] ?? []; + foreach ($messages as $message) { + $summary[] = "Platz $position ($label): $message"; + } + $mapped["$sectionPath.slots"] = array_values(array_unique($summary)); + + if ($slotKey !== null && $widgetKey !== null && $field !== '' && $field !== 'units') { + $field = preg_replace('/\.\d+\..*$/', '', $field); + $mapped["$sectionPath.slots.$slotKey.widget.$widgetKey.data.$field"] = $messages; + } + + continue; + } + + $mapped[$rest === '' ? $sectionPath : "$sectionPath.$rest"] = $messages; + } + + return $mapped; + } + + /** + * Formularfehler aus Widget-Dialogen ("data.sections.{uuid}.slots.{uuid}.widget.{uuid}.data.data.feld") in + * Schlüssel des Abschnittsmodells ("sections.N.slots.M.data.feld") übersetzen. + * + * @param array $errors + * @param array $state + * @return array> + */ + public static function sectionErrorsFromForm(array $errors, array $state, string $statePath = 'data.sections'): array + { + $sectionKeys = array_flip(array_map('strval', array_keys($state))); + $translated = []; + $pattern = '/^'.preg_quote($statePath, '/').'\.([^.]+)\.slots\.([^.]+)\.widget\.[^.]+\.data\.(.+)$/'; + + foreach ($errors as $key => $messages) { + if (preg_match($pattern, (string) $key, $match) !== 1 || ! isset($sectionKeys[$match[1]])) { + continue; + } + + $slotKeys = array_flip(array_map('strval', array_keys(is_array($state[$match[1]]['slots'] ?? null) ? $state[$match[1]]['slots'] : []))); + if (! isset($slotKeys[$match[2]])) { + continue; + } + + $translated['sections.'.$sectionKeys[$match[1]].'.slots.'.$slotKeys[$match[2]].'.'.$match[3]] = array_values((array) $messages); + } + + return $translated; + } + + /** + * Sichtbare Meldung mit Abschnittsnummer, Platz und Widget-Art. + * + * @param array> $errors + * @param array $state + */ + public static function notifyErrors(array $errors, array $state): void + { + $registry = app(WidgetRegistry::class); + $sections = array_values($state); + $lines = []; + + foreach ($errors as $key => $messages) { + $text = implode(' ', (array) $messages); + + if (preg_match('/^sections\.(\d+)(?:\.slots\.(\d+))?/', (string) $key, $match) === 1) { + $line = 'Abschnitt '.((int) $match[1] + 1); + + if (isset($match[2])) { + $slots = array_values(is_array($sections[(int) $match[1]]['slots'] ?? null) ? $sections[(int) $match[1]]['slots'] : []); + $items = $slots[(int) $match[2]]['widget'] ?? []; + $type = is_array($items) && $items !== [] ? (array_values($items)[0]['type'] ?? null) : null; + $line .= ', Platz '.((int) $match[2] + 1).($registry->has($type) ? ' ('.$registry->get($type)->label().')' : ''); + } + + $lines[] = $line.': '.$text; + } else { + $lines[] = $text; + } + } + + Notification::make() + ->title('Nicht gespeichert') + ->body(implode("\n", array_unique($lines))) + ->danger() + ->persistent() + ->send(); + } + + /** + * Ordnet Plätze für ein neues Raster: Widgets behalten ihre Reihenfolge, leere Plätze entfallen zuerst. + * Es wird nie ein Widget entfernt; passen nicht alle Widgets, bleiben überzählige Plätze bestehen + * (die Auswahl solcher Raster ist im Editor gesperrt, das Speichern weist sie ab). + * + * @param mixed $slots roher Zustand {uuid: {widget: {...}}} + * @return array}> + */ + public static function arrangeSlots(mixed $slots, string $layout): array + { + $slots = is_array($slots) ? $slots : []; + $count = SectionLayouts::slotCount(SectionLayouts::has($layout) ? $layout : SectionLayouts::DEFAULT); + + if (count($slots) === $count) { + return $slots; + } + + $filled = array_filter($slots, fn ($slot): bool => self::slotHasWidget($slot)); + + if (count($slots) < $count) { + $arranged = $slots; + } else { + // Leere Plätze am Ende zuerst entfernen, dann übrige leere Plätze, bis die Zahl passt. + $arranged = $slots; + foreach (array_reverse(array_keys($slots)) as $key) { + if (count($arranged) <= $count) { + break; + } + if (! self::slotHasWidget($slots[$key])) { + unset($arranged[$key]); + } + } + $arranged = count($arranged) > $count ? $filled : $arranged; + } + + while (count($arranged) < $count) { + $arranged[(string) Str::uuid()] = ['widget' => []]; + } + + return $arranged; + } + + public static function filledCount(mixed $slots): int + { + return count(array_filter(is_array($slots) ? $slots : [], fn ($slot): bool => self::slotHasWidget($slot))); + } + + private static function slotHasWidget(mixed $slot): bool + { + return is_array($slot) && is_array($slot['widget'] ?? null) && $slot['widget'] !== []; + } + + /** + * @return array + */ + private static function layoutOptions(): array + { + $options = []; + + foreach (SectionLayouts::UNITS as $key => $units) { + $options[$key] = new HtmlString( + ''.SectionLayouts::schematicSvg($key) + .''.e(SectionLayouts::short($key)).'' + .''.e(SectionLayouts::LABELS[$key]).'' + ); + } + + return $options; + } + + /** + * Spaltenverhältnis der Plätze im Editor; entspricht dem Desktop-Raster der Website. + */ + private static function editorColumns(mixed $layout): string + { + $units = SectionLayouts::units(SectionLayouts::has($layout) ? $layout : SectionLayouts::DEFAULT); + + return implode(' ', array_map(fn (int $unit): string => "minmax(0, {$unit}fr)", $units)); + } + + /** + * @param array $state + */ + private static function sectionLabel(array $state, ?int $index): string + { + $layout = SectionLayouts::has($state['layout'] ?? null) ? $state['layout'] : SectionLayouts::DEFAULT; + $registry = app(WidgetRegistry::class); + $names = []; + + foreach (is_array($state['slots'] ?? null) ? $state['slots'] : [] as $slot) { + $items = is_array($slot['widget'] ?? null) ? $slot['widget'] : []; + $type = $items !== [] ? (array_values($items)[0]['type'] ?? null) : null; + if ($registry->has($type)) { + $names[] = $registry->get($type)->label(); + } + } + + $label = 'Abschnitt '.(($index ?? 0) + 1).' · Raster '.SectionLayouts::short($layout) + .' · '.SectionStyle::summary(is_array($state['style'] ?? null) ? $state['style'] : []); + + return $names === [] ? $label.' · noch leer' : $label.' · '.implode(', ', $names); + } + + /** + * @param array $state + */ + private static function slotLabel(array $state, ?int $index, mixed $layout): string + { + $layout = SectionLayouts::has($layout) ? $layout : SectionLayouts::DEFAULT; + $units = SectionLayouts::units($layout); + $position = $index ?? 0; + $slotUnits = $units[$position] ?? null; + + if ($slotUnits === null) { + return 'Platz '.($position + 1).' · außerhalb des Rasters: Widget entfernen oder Raster mit mehr Plätzen wählen'; + } + + $label = 'Platz '.($position + 1).' · '.$slotUnits.' '.($slotUnits === 1 ? 'Einheit' : 'Einheiten'); + $items = is_array($state['widget'] ?? null) ? $state['widget'] : []; + $type = $items !== [] ? (array_values($items)[0]['type'] ?? null) : null; + $registry = app(WidgetRegistry::class); + + if ($registry->has($type) && $registry->get($type)->minUnits() > $slotUnits) { + $label .= ' · zu schmal: „'.$registry->get($type)->label().'“ braucht '.$registry->get($type)->minUnits(); + } + + return $label; + } + + /** + * @param list> $items + * @return array> + */ + private static function keyed(array $items): array + { + $keyed = []; + foreach ($items as $item) { + $keyed[(string) Str::uuid()] = $item; + } + + return $keyed; + } +} diff --git a/app/Filament/Support/WidgetEditor.php b/app/Filament/Support/WidgetEditor.php index 2242df0..37dfa22 100644 --- a/app/Filament/Support/WidgetEditor.php +++ b/app/Filament/Support/WidgetEditor.php @@ -53,6 +53,34 @@ public static function builder(string $name = 'blocks'): Builder ->columnSpanFull(); } + /** + * Ein Platz im Abschnittsraster: höchstens ein Widget. Hinzufügen öffnet die Widget-Auswahl und danach den + * Bearbeitungsdialog; die Vorschau zeigt das Widget in der tatsächlichen Platzbreite. + */ + public static function slotBuilder(string $name = 'widget'): Builder + { + $registry = app(WidgetRegistry::class); + + return Builder::make($name) + ->label('Widget') + ->hiddenLabel() + ->blocks(array_values(array_map(self::block(...), $registry->all()))) + ->blockPreviews() + ->blockPickerColumns(['default' => 1, 'md' => 2]) + ->blockPickerWidth('3xl') + ->addActionLabel('Widget einsetzen') + ->maxItems(1) + ->blockNumbers(false) + ->reorderable(false) + ->cloneable(false) + ->deletable() + ->collapsible(false) + ->addAction(fn ($action) => $action->modalHeading('Widget einrichten')->modalWidth('4xl')->icon('heroicon-o-plus')) + ->editAction(fn ($action) => $action->modalHeading('Widget bearbeiten')->modalWidth('4xl')->modalSubmitActionLabel('Übernehmen')->tooltip('Widget bearbeiten')) + ->deleteAction(fn ($action) => $action->tooltip('Widget aus diesem Platz entfernen')->requiresConfirmation()->modalHeading('Widget entfernen?')->modalDescription('Das Widget wird aus dem Entwurf entfernt. Gespeicherte Revisionen bleiben erhalten.')->modalSubmitActionLabel('Entfernen')) + ->columnSpanFull(); + } + public static function block(WidgetType $type): Block { $variants = $type->variants(); @@ -252,10 +280,18 @@ private static function pickerLabel(WidgetType $type): HtmlString '' .self::schematicSvg($type) .''.e($type->label()).'' - .''.e($type->description()).'' + .''.e($type->description()).'' + .''.e(self::unitsHint($type)).'' ); } + private static function unitsHint(WidgetType $type): string + { + return $type->minUnits() === 1 + ? 'Passt in jeden Platz' + : 'Braucht einen Platz ab '.$type->minUnits().' Rastereinheiten'; + } + /** * @param array $state */ diff --git a/app/Http/Controllers/PageController.php b/app/Http/Controllers/PageController.php index 3008ad1..d63cfe0 100644 --- a/app/Http/Controllers/PageController.php +++ b/app/Http/Controllers/PageController.php @@ -6,8 +6,8 @@ use App\Domain\Cms\Page; use App\Domain\Cms\PageRevision; use App\Domain\Cms\PageTemplates; +use App\Domain\Cms\Sections\SectionRenderer; use App\Domain\Cms\Widgets\RenderContext; -use App\Domain\Cms\Widgets\WidgetRenderer; use Illuminate\Contracts\View\View; use Illuminate\Http\Response; use Illuminate\Support\Facades\Gate; @@ -69,10 +69,11 @@ private function render(Page $page, bool $preview, ?PageRevision $revision = nul 'revision' => $revision, 'preview' => $preview, 'template' => app(PageTemplates::class)->viewFor($page), - 'content' => app(WidgetRenderer::class)->renderAll($revision->blocks, $context), + 'content' => app(SectionRenderer::class)->renderAll($revision->sections(), $context), 'documentTitle' => $revision->seo_title ?: ($revision->contentTitle() ?? config('app.name')), 'documentDescription' => $revision->seo_description, 'themes' => $page->path === '/' ? Pillar::query()->published()->get() : collect(), + 'activePath' => $page->path, ]); } } diff --git a/config/cms.php b/config/cms.php index f7c4551..8d842a4 100644 --- a/config/cms.php +++ b/config/cms.php @@ -35,4 +35,13 @@ 'standard' => 'site.templates.standard', ], + /* + | Vorbereiteter Warenkorbzugang in der Kopfzeile. Der Warenkorb ist Teil des kommerziellen Anwendungssystems + | und noch nicht umgesetzt; solange enabled false ist, erscheint kein Warenkorbsymbol. + */ + 'cart' => [ + 'enabled' => (bool) env('LUF_CART_ENABLED', false), + 'url' => env('LUF_CART_URL'), + ], + ]; diff --git a/database/migrations/2026_11_17_110000_add_sections_to_page_revisions.php b/database/migrations/2026_11_17_110000_add_sections_to_page_revisions.php new file mode 100644 index 0000000..269f758 --- /dev/null +++ b/database/migrations/2026_11_17_110000_add_sections_to_page_revisions.php @@ -0,0 +1,27 @@ +json('sections')->nullable(); + }); + } + + public function down(): void + { + Schema::table('page_revisions', function (Blueprint $table) { + $table->dropColumn('sections'); + }); + } +}; diff --git a/database/migrations/2026_11_17_120000_add_parent_to_navigation_items.php b/database/migrations/2026_11_17_120000_add_parent_to_navigation_items.php new file mode 100644 index 0000000..7c139c2 --- /dev/null +++ b/database/migrations/2026_11_17_120000_add_parent_to_navigation_items.php @@ -0,0 +1,27 @@ +foreignId('parent_id')->nullable()->constrained('navigation_items')->nullOnDelete(); + }); + } + + public function down(): void + { + Schema::table('navigation_items', function (Blueprint $table) { + $table->dropConstrainedForeignId('parent_id'); + }); + } +}; diff --git a/resources/css/app.css b/resources/css/app.css index 89089ff..bfede86 100644 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -1,632 +1,49 @@ @import 'tailwindcss'; -@theme { - --font-sans: 'Source Sans 3', 'Segoe UI', sans-serif; - --font-serif: 'Source Serif 4', Georgia, serif; - --color-ink: #1b2838; - --color-paper: #e7eee9; - --color-sheet: #f7faf8; - --color-pine: #0f6e56; - --color-line: #c5d2cb; -} - -html { - background: var(--color-paper); - color: var(--color-ink); - font-family: var(--font-sans); - font-size: 1.0625rem; - line-height: 1.6; -} - -body { - margin: 0; - min-height: 100vh; -} - -a { - color: var(--color-pine); -} - -a:hover { - text-decoration: none; -} - -:focus-visible { - outline: 3px solid #0b5cab; - outline-offset: 3px; -} - -.skip { - position: absolute; - left: 1rem; - top: -4rem; - background: white; - padding: 0.5rem 0.75rem; -} - -.skip:focus { - top: 1rem; -} - -.masthead { - background: var(--color-ink); - color: #f4f7f5; -} - -.masthead a { - color: inherit; - text-decoration: none; -} - -.masthead-inner, -.sheet, -.site-footer-inner { - width: min(72rem, calc(100% - 2rem)); - margin-inline: auto; -} - -.wordmark { - display: flex; - justify-content: space-between; - gap: 1rem; - align-items: baseline; - padding-top: 1.5rem; -} - -.wordmark strong { - font-family: var(--font-serif); - font-size: clamp(2rem, 4vw, 3.25rem); - font-weight: 600; - letter-spacing: -0.03em; - line-height: 1; -} - -.wordmark span { - font-size: 0.95rem; -} - -.site-nav { - display: flex; - flex-wrap: wrap; - gap: 0.35rem 1.1rem; - padding: 1.25rem 0 1.1rem; - border-top: 1px solid rgb(255 255 255 / 18%); - margin-top: 1.25rem; -} - -.site-nav a[aria-current='page'] { - text-decoration: underline; - text-underline-offset: 0.35rem; -} - -.sheet { - background: var(--color-sheet); - padding: clamp(1.5rem, 4vw, 3.5rem) clamp(1.25rem, 4vw, 3rem); - margin-top: -1px; -} - -.preview-banner { - background: #fff4d6; - color: #3d2e04; - padding: 0.75rem 1rem; - margin: -1rem -1rem 1.5rem; -} - -.block + .block { - margin-top: 2.25rem; -} - -main h1 { - font-family: var(--font-serif); - font-weight: 600; - letter-spacing: -0.03em; - line-height: 1.15; - font-size: clamp(2rem, 4vw, 3rem); - margin: 0 0 0.75rem; -} - -.block h1, -.block h2 { - font-family: var(--font-serif); - font-weight: 600; - letter-spacing: -0.03em; - line-height: 1.15; - margin: 0 0 0.75rem; -} - -.block h1 { - font-size: clamp(2.4rem, 6vw, 4.4rem); - max-width: 12ch; -} - -.block h2 { - font-size: clamp(1.8rem, 3vw, 2.6rem); - max-width: 18ch; -} - -.lede, -.prose, -.cta p, -.card p, -.faq dd { - max-width: 62ch; -} - -.themes { - list-style: none; - padding: 0; - margin: 1.5rem 0 0; -} - -.themes li { - border-top: 1px solid var(--color-line); - padding: 1rem 0; -} - -.themes a { - font-family: var(--font-serif); - font-size: 1.5rem; - text-decoration: none; -} - -.themes p { - max-width: 62ch; - margin: 0.35rem 0 0; -} - -.prose p { - margin: 0 0 1rem; -} - -.cards { - display: grid; - grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); - gap: 1rem; - list-style: none; - padding: 0; - margin: 0; -} - -.card { - border-top: 3px solid var(--color-pine); - background: white; - padding: 1rem 1rem 1.15rem; -} - -.card h3 { - font-family: var(--font-serif); - font-size: 1.35rem; - margin: 0 0 0.4rem; -} - -.card a { - color: inherit; - text-decoration: none; -} - -.card a:hover h3 { - text-decoration: underline; -} - -.cta { - background: var(--color-ink); - color: #f4f7f5; - padding: 1.5rem; -} - -.cta h2, -.cta p { - color: inherit; -} - -.cta a { - display: inline-block; - margin-top: 0.8rem; - background: #f4f7f5; - color: var(--color-ink); - text-decoration: none; - padding: 0.55rem 0.9rem; -} - -.image-text { - display: grid; - gap: 1.25rem; -} - -@media (min-width: 48rem) { - .image-text { - grid-template-columns: minmax(12rem, 22rem) 1fr; - align-items: start; - } - - .image-text-right { - grid-template-columns: 1fr minmax(12rem, 22rem); - } - - .image-text-right > img { - order: 2; - } - - .image-text-no-image { - grid-template-columns: 1fr; - } -} - -.image-text img { - width: 100%; - height: auto; -} - -.image-text-copy > :first-child { - margin-top: 0; -} - -.prose ul, -.prose ol { - margin: 0 0 1rem; - padding-left: 1.4rem; -} - -.prose li > p { - margin: 0; -} - -/* Widgets: Einstieg (Hero). Varianten: standard, highlight. */ -.hero { - display: grid; - gap: 1.5rem; - align-items: center; -} - -.hero .lede { - font-size: 1.2rem; -} - -.hero-image { - width: 100%; - height: auto; - display: block; -} - -@media (min-width: 48rem) { - .hero-with-image { - grid-template-columns: 1.1fr 1fr; - } -} - -.hero-highlight { - background: var(--color-ink); - color: #f4f7f5; - padding: clamp(1.5rem, 4vw, 3rem); -} - -.hero-highlight h1, -.hero-highlight h2, -.hero-highlight .lede { - color: inherit; -} - -.button { - display: inline-block; - margin-top: 0.5rem; - background: var(--color-pine); - color: #ffffff; - text-decoration: none; - padding: 0.65rem 1.05rem; - font-weight: 600; -} - -.button:hover { - text-decoration: underline; -} - -.hero-highlight .button { - background: #f4f7f5; - color: var(--color-ink); -} - -/* Widgets: redaktionelle Karten. Varianten: Raster (cards-grid), kompakte Liste (cards-compact). */ -.card-image { - display: block; - width: calc(100% + 2rem); - max-width: none; - height: auto; - aspect-ratio: 16 / 9; - object-fit: cover; - margin: -1rem -1rem 0.85rem; -} - -.cards-compact { - grid-template-columns: 1fr; - gap: 0; -} - -.cards-compact .card { - border-top: 0; - border-bottom: 1px solid var(--color-line); - background: transparent; - padding: 0.85rem 0; -} - -.cards-compact .card-image { - display: none; -} - -.cards-compact .card h3 { - font-size: 1.15rem; -} - -/* Widgets: Programm- und Modulkarten. Inhalte kommen aus den Fachdaten. */ -.catalog-list { - display: grid; - grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); - gap: 1rem; - list-style: none; - padding: 0; - margin: 1rem 0 0; -} - -.catalog-card { - background: white; - border: 1px solid var(--color-line); - display: flex; - flex-direction: column; -} - -.catalog-card-visual { - background: var(--color-paper); - border-bottom: 3px solid var(--color-pine); - min-height: 6rem; - display: flex; - align-items: flex-end; - padding: 0.75rem 1rem; -} - -.catalog-card-visual span { - font-family: var(--font-serif); - font-size: 1.1rem; - color: var(--color-pine); -} - -.catalog-card-body { - padding: 0.9rem 1rem 1.1rem; -} - -.catalog-card-body h3 { - font-family: var(--font-serif); - font-size: 1.35rem; - margin: 0 0 0.4rem; -} - -.catalog-card-body p { - margin: 0 0 0.5rem; -} - -.catalog-card-kind { - font-size: 0.85rem; - text-transform: uppercase; - letter-spacing: 0.06em; - color: #3f5248; -} - -.catalog-cards-compact .catalog-list { - grid-template-columns: 1fr; - gap: 0; -} - -.catalog-cards-compact .catalog-card { - border-width: 0 0 1px; - background: transparent; -} - -.catalog-cards-compact .catalog-card-body { - padding: 0.75rem 0; -} - -.catalog-card-internal { - border-style: dashed; -} - -.preview-note { - background: #fff4d6; - color: #3d2e04; - font-size: 0.9rem; - padding: 0.5rem 0.75rem; - margin: 0.5rem 0 0; -} - -.faq { - margin: 0; -} - -.faq dt { - font-weight: 600; - margin-top: 1rem; -} - -.faq dd { - margin: 0.25rem 0 0; -} - -.member-nav { - display: flex; - flex-wrap: wrap; - gap: 0.75rem 1.25rem; - margin-bottom: 2rem; - padding-bottom: 0.75rem; - border-bottom: 1px solid var(--color-line); -} - -.member-nav a { - color: inherit; - text-decoration: none; -} - -.member-nav a[aria-current='page'] { - text-decoration: underline; - text-underline-offset: 0.3rem; -} - -.catalog { - list-style: none; - padding: 0; - display: grid; - gap: 1rem; -} - -.catalog li { - background: white; - border: 1px solid var(--color-line); - padding: 1rem 1.1rem; - display: grid; - gap: 0.4rem; -} - -.catalog video, -.course video { - width: min(100%, 40rem); - background: #111; -} - -.course { - list-style: none; - padding: 0; - display: grid; - gap: 1.5rem; -} - -.course li { - background: white; - border: 1px solid var(--color-line); - padding: 1rem 1.1rem; -} - -.course h2 { - font-size: 1.25rem; - margin: 0 0 0.6rem; -} - -.course-actions { - display: flex; - flex-wrap: wrap; - gap: 0.5rem; -} - -.empty { - background: white; - border: 1px solid var(--color-line); - padding: 1.25rem; - max-width: 62ch; -} - -.form { - display: grid; - gap: 0.9rem; - max-width: 28rem; -} - -.form label { - display: grid; - gap: 0.3rem; - font-weight: 600; -} - -.form input { - font: inherit; - padding: 0.55rem 0.65rem; - border: 1px solid #8ea399; - background: white; - width: 100%; - box-sizing: border-box; -} - -.form button, -.button { - font: inherit; - background: var(--color-pine); - color: white; - border: 0; - padding: 0.6rem 0.9rem; - width: fit-content; - cursor: pointer; -} - -.check { - font-weight: 400; - grid-template-columns: auto 1fr; - align-items: start; -} - -.errors { - background: #fde8e4; - color: #6d2016; - padding: 0.75rem 1rem; -} - -.status { - background: #e5f4ec; - padding: 0.75rem 1rem; -} - -.site-footer { - padding: 2rem 0 3rem; -} - -.site-footer-inner { - display: flex; - flex-wrap: wrap; - gap: 1rem 2rem; - align-items: baseline; - justify-content: space-between; -} - -.wordmark-compact { - padding-top: 0; -} - -.wordmark-compact strong { - font-size: 1.5rem; -} - -.site-footer nav { - display: flex; - flex-wrap: wrap; - gap: 0.5rem 1rem; -} - -.site-footer a { - color: inherit; -} - +/* + * Lara & Felix – gemeinsames Stylesheet für Website, Anmeldung und Mitgliederbereich (ADR-36). + * Reihenfolge: Tokens → Grundelemente → Grundkomponenten → Website-Gerüst → Abschnitte → Widgets → Mitgliederbereich. + */ +@import './tokens.css'; +@import './base.css'; +@import './components.css'; +@import './site.css'; +@import './sections.css'; +@import './widgets.css'; + +/* + * Mitgliederbereich: eigene Anwendungsoberfläche mit eigener Navigation. Er verwendet die gemeinsamen + * Tokens über seine bisherigen Variablennamen; Layout und Navigation bleiben unverändert. + */ body.member { - --marke-navy: #032551; - --marke-gruen: #5b8625; - --marke-aktion: #3b7b09; - --marke-gelb: #fcd10a; - --marke-creme: #f7f6f2; - --marke-tinte: #15243a; - --text: var(--marke-tinte); - --text-leise: #3e4c5c; - --flaeche: var(--marke-creme); - --flaeche-karte: #ffffff; - --linie: #d5ddd6; - --aktion: var(--marke-aktion); - --aktion-text: #ffffff; - --akzent: var(--marke-gelb); - --fokus: #1769aa; - --erfolg: #1b5e32; - --hinweis: #6b4a00; - --fehler: #8e1b24; - --radius-karte: 14px; - --radius-flaeche: 22px; - --radius-pille: 999px; - --schatten: 0 10px 28px rgb(3 37 81 / 8%); - --schrift-lesen: var(--font-sans); - --schrift-auszeichnung: var(--font-serif); + --marke-navy: var(--lf-navy); + --marke-gruen: var(--lf-green); + --marke-aktion: var(--lf-green-deep); + --marke-gelb: var(--lf-yellow); + --marke-creme: var(--lf-cream); + --marke-tinte: var(--lf-ink); + --text: var(--color-text); + --text-leise: var(--color-text-muted); + --flaeche: var(--color-surface-subtle); + --flaeche-karte: var(--color-surface-raised); + --linie: var(--color-border); + --aktion: var(--color-action); + --aktion-text: var(--color-action-text); + --akzent: var(--color-accent); + --fokus: var(--color-focus); + --erfolg: var(--color-success); + --hinweis: var(--color-warning); + --fehler: var(--color-danger); + --radius-karte: var(--radius-card); + --radius-flaeche: var(--radius-panel); + --radius-pille: var(--radius-pill); + --schatten: var(--shadow-raised); + --schrift-lesen: var(--font-reading); + --schrift-auszeichnung: var(--font-display); background: var(--flaeche); color: var(--text); font-family: var(--schrift-lesen); - font-size: 1.0625rem; + font-size: var(--text-body); } body.member :focus-visible { @@ -636,7 +53,7 @@ body.member :focus-visible { body.member h1, body.member h2, -body.member .member-mark strong, +body.member .member-mark .brand-name, body.member .entry strong { font-family: var(--schrift-auszeichnung); letter-spacing: -0.02em; @@ -690,12 +107,12 @@ body.member .member-mark { line-height: 1.1; } -body.member .member-mark strong { +body.member .member-mark .brand-name { font-size: 1.35rem; white-space: nowrap; } -body.member .member-mark span, +body.member .member-mark .brand-claim, body.member .quiet { color: var(--text-leise); font-size: 0.9rem; @@ -1147,3 +564,8 @@ @media (prefers-reduced-motion: reduce) { scroll-behavior: auto; } } + +/* Wortmarke in der dunklen Seitenleiste: heller Zusatz für ausreichenden Kontrast. */ +body.member .member-side .member-mark .brand-claim { + color: #d3dde8; +} diff --git a/resources/css/base.css b/resources/css/base.css new file mode 100644 index 0000000..00332be --- /dev/null +++ b/resources/css/base.css @@ -0,0 +1,145 @@ +/* Grundelemente und Typografie, gemeinsam für Website, Anmeldung und Mitgliederbereich. */ + +*, +*::before, +*::after { + box-sizing: border-box; +} + +html { + background: var(--color-surface); + color: var(--color-text); + font-family: var(--font-reading); + font-size: 100%; + line-height: var(--leading-body); + -webkit-text-size-adjust: 100%; +} + +body { + margin: 0; + min-height: 100vh; + font-size: var(--text-body); + background: var(--color-surface); + color: var(--color-text); +} + +img, +video, +svg { + max-width: 100%; +} + +img { + height: auto; +} + +a { + color: var(--color-link); + text-decoration-thickness: 1px; + text-underline-offset: 0.18em; +} + +a:hover { + color: var(--color-link-hover); + text-decoration-thickness: 2px; +} + +:focus-visible { + outline: 3px solid var(--color-focus); + outline-offset: 3px; +} + +h1, +h2, +h3 { + font-family: var(--font-display); + color: var(--color-heading); + line-height: var(--leading-heading); + letter-spacing: -0.02em; + font-weight: 800; + overflow-wrap: break-word; + hyphens: auto; +} + +h1 { + font-size: var(--text-h1); + margin: 0 0 var(--space-4); +} + +h2 { + font-size: var(--text-h2); + margin: 0 0 var(--space-3); +} + +h3 { + font-size: var(--text-h3); + margin: 0 0 var(--space-2); + font-weight: 700; +} + +p { + margin: 0 0 var(--space-4); +} + +.lede { + font-size: var(--text-lede); + color: var(--color-text); + max-width: var(--measure); +} + +.prose { + max-width: var(--measure); +} + +.prose > :last-child, +.lede:last-child { + margin-bottom: 0; +} + +.prose ul, +.prose ol { + margin: 0 0 var(--space-4); + padding-left: 1.4rem; +} + +.prose li > p { + margin: 0; +} + +.visually-hidden { + position: absolute !important; + width: 1px; + height: 1px; + padding: 0; + margin: -1px; + overflow: hidden; + clip: rect(0 0 0 0); + white-space: nowrap; + border: 0; +} + +.skip { + position: absolute; + left: var(--space-4); + top: -4rem; + z-index: 100; + background: var(--lf-white); + color: var(--lf-navy); + padding: var(--space-2) var(--space-3); + border-radius: var(--radius-small); +} + +.skip:focus { + top: var(--space-4); +} + +@media (prefers-reduced-motion: reduce) { + *, + *::before, + *::after { + scroll-behavior: auto !important; + transition-duration: 0.01ms !important; + animation-duration: 0.01ms !important; + animation-iteration-count: 1 !important; + } +} diff --git a/resources/css/components.css b/resources/css/components.css new file mode 100644 index 0000000..97e4b1d --- /dev/null +++ b/resources/css/components.css @@ -0,0 +1,288 @@ +/* + * Gemeinsame Grundkomponenten (Standardmuster, nur mit Tokens eingefärbt). Sie werden von Website, + * Anmeldung und Mitgliederbereich verwendet und können später gezielt veredelt werden. + */ + +/* Container */ +.ui-container { + width: min(var(--container-standard), 100% - 2 * var(--gutter)); + margin-inline: auto; +} + +.ui-container-wide { + width: min(var(--container-wide), 100% - 2 * var(--gutter)); +} + +/* Schaltflächen und Schaltflächen-Links: Haupt, Neben, Text. Mindestgröße 44 px. */ +.button, +.ui-button { + display: inline-flex; + align-items: center; + justify-content: center; + gap: var(--space-2); + min-height: var(--touch-target); + padding: 0.55rem 1.25rem; + border: 2px solid transparent; + border-radius: var(--radius-pill); + background: var(--color-action); + color: var(--color-action-text); + font: inherit; + font-weight: 700; + line-height: 1.2; + text-decoration: none; + cursor: pointer; + transition: background-color 0.15s ease, border-color 0.15s ease; +} + +.button:hover, +.ui-button:hover { + background: var(--color-action-hover); + color: var(--color-action-text); + text-decoration: none; +} + +.button-secondary, +.ui-button-secondary { + background: transparent; + border-color: var(--color-border-strong); + color: var(--color-action-secondary-text); +} + +.button-secondary:hover, +.ui-button-secondary:hover { + background: transparent; + border-color: currentColor; + color: var(--color-action-secondary-text); +} + +.button-quiet, +.ui-button-quiet { + background: transparent; + color: var(--color-link); + padding-inline: var(--space-2); + text-decoration: underline; +} + +.button-quiet:hover, +.ui-button-quiet:hover { + background: transparent; + color: var(--color-link-hover); +} + +.button[disabled], +.ui-button[disabled], +.ui-button[aria-disabled='true'] { + background: var(--color-disabled-surface); + border-color: transparent; + color: var(--color-disabled); + cursor: not-allowed; +} + +/* Formulare: sichtbare Beschriftung, Fehlertext am Feld. */ +.form { + display: grid; + gap: var(--space-4); + max-width: 28rem; +} + +.form label, +.ui-field { + display: grid; + gap: var(--space-1); + font-weight: 600; +} + +.form input, +.form select, +.form textarea, +.ui-input { + font: inherit; + font-weight: 400; + min-height: var(--touch-target); + padding: 0.5rem 0.75rem; + border: 1px solid var(--color-border-strong); + border-radius: var(--radius-small); + background: var(--lf-white); + color: var(--lf-ink); + width: 100%; +} + +.form input[aria-invalid='true'], +.ui-input[aria-invalid='true'] { + border-color: var(--color-danger); +} + +.form button { + width: fit-content; +} + +.form button:not(.button-quiet):not(.button-secondary) { + display: inline-flex; + align-items: center; + min-height: var(--touch-target); + padding: 0.55rem 1.25rem; + border: 0; + border-radius: var(--radius-pill); + background: var(--color-action); + color: var(--color-action-text); + font: inherit; + font-weight: 700; + cursor: pointer; +} + +.check { + display: grid; + grid-template-columns: auto 1fr; + align-items: start; + gap: var(--space-2); + font-weight: 400; +} + +.check input { + width: 1.25rem; + height: 1.25rem; + min-height: 0; + margin-top: 0.2rem; +} + +.ui-field-error { + color: var(--color-danger); + font-weight: 400; + font-size: var(--text-small); +} + +/* Statusanzeigen: Farbe, Symbol und Text tragen gemeinsam (nie Farbe allein). */ +.status, +.errors, +.ui-notice { + display: block; + border-left: 4px solid currentColor; + border-radius: var(--radius-small); + padding: var(--space-3) var(--space-4); + margin: 0 0 var(--space-5); + max-width: var(--measure); +} + +.status, +.ui-notice-success { + background: var(--color-success-surface); + color: var(--color-success); +} + +.errors, +.ui-notice-danger { + background: var(--color-danger-surface); + color: var(--color-danger); +} + +.ui-notice-warning { + background: var(--color-warning-surface); + color: var(--color-warning); +} + +.ui-notice-info { + background: var(--color-info-surface); + color: var(--color-info); +} + +.ui-notice-title { + font-weight: 700; +} + +.errors ul { + margin: var(--space-2) 0 0; + padding-left: 1.2rem; +} + +/* Karten-Grundkomponente */ +.ui-card, +.empty { + background: var(--color-surface-raised); + border: 1px solid var(--color-border); + border-radius: var(--radius-card); + padding: var(--space-5); +} + +.empty { + max-width: var(--measure); +} + +/* Dialog (natives dialog-Element) */ +.ui-dialog { + border: 0; + border-radius: var(--radius-panel); + padding: var(--space-6); + max-width: min(36rem, 100% - 2rem); + background: var(--lf-white); + color: var(--lf-ink); + box-shadow: var(--shadow-raised); +} + +.ui-dialog::backdrop { + background: rgb(3 37 81 / 55%); +} + +/* Kennzeile über Überschriften */ +.ui-flag { + display: inline-flex; + align-items: center; + gap: var(--space-2); + font-size: 0.8125rem; + font-weight: 700; + letter-spacing: 0.08em; + text-transform: uppercase; + color: var(--color-text-muted); +} + +.ui-flag::before { + content: ''; + width: 1.6rem; + height: 4px; + border-radius: 4px; + background: var(--color-accent); +} + +/* Themensignatur: Nummer und Name tragen die Unterscheidung; Symbol erst nach Freigabe. */ +.ui-theme-signature { + display: inline-flex; + align-items: center; + gap: var(--space-2); + font-weight: 600; +} + +.ui-theme-signature-mark { + display: inline-grid; + place-items: center; + min-width: 2rem; + height: 2rem; + border-radius: var(--radius-small); + border: 1px solid var(--color-border-strong); + background: var(--theme-tint, var(--color-surface-subtle)); + color: var(--lf-navy); + font-family: var(--font-display); + font-weight: 800; +} + +.ui-theme-signature[data-theme='1'] { --theme-tint: var(--color-theme-1); } +.ui-theme-signature[data-theme='2'] { --theme-tint: var(--color-theme-2); } +.ui-theme-signature[data-theme='3'] { --theme-tint: var(--color-theme-3); } +.ui-theme-signature[data-theme='4'] { --theme-tint: var(--color-theme-4); } +.ui-theme-signature[data-theme='5'] { --theme-tint: var(--color-theme-5); } + +/* Redaktionelle Hinweise in der Vorschau (öffentlich nie sichtbar). */ +.preview-note, +.preview-banner { + background: var(--color-warning-surface); + color: var(--color-warning); + border-left: 4px solid currentColor; + border-radius: var(--radius-small); + font-size: var(--text-small); + padding: var(--space-2) var(--space-3); + margin: var(--space-2) 0 0; +} + +.preview-banner { + margin: 0; + border-radius: 0; + text-align: center; +} diff --git a/resources/css/sections.css b/resources/css/sections.css new file mode 100644 index 0000000..e77713f --- /dev/null +++ b/resources/css/sections.css @@ -0,0 +1,163 @@ +/* + * Abschnitte des Seiteneditors (Seite → Abschnitte → Slots → Widgets). + * Gestaltung nur über Aufzählungswerte; jede Fläche setzt die Bedeutungswerte neu (tokens.css). + * + * Responsive Regeln (siehe SectionLayouts::columns): + * - Abschnitt unter 40rem: alle Slots untereinander in Slot-Reihenfolge. + * - 40 bis 60rem: gleich breite Slots nebeneinander, ungleiche untereinander. + * - ab 60rem: Verhältnis der Rastereinheiten. + * Jeder Slot ist ein eigener Container; Widgets richten sich nach der Slotbreite, nicht nach dem Fenster. + */ + +.page-sections { + display: block; +} + +.page-section { + position: relative; + isolation: isolate; + background: var(--color-surface); + color: var(--color-text); + padding-block: var(--section-space); + --section-space: clamp(3rem, 2rem + 4vw, 6rem); +} + +.section-space-compact { + --section-space: clamp(1.5rem, 1rem + 2vw, 3rem); +} + +.section-space-large { + --section-space: clamp(4.5rem, 3rem + 5vw, 8rem); +} + +/* Aufeinanderfolgende Abschnitte ohne eigene Fläche teilen sich den Abstand, statt ihn zu verdoppeln. */ +.section-bg-default + .section-bg-default { + padding-top: 0; +} + +.section-divider-space { + margin-bottom: var(--section-space); +} + +.page-section-inner { + position: relative; + z-index: 1; + width: min(var(--section-width), 100% - 2 * var(--gutter)); + margin-inline: auto; + container-type: inline-size; + container-name: section; + --section-width: var(--container-standard); +} + +.section-width-narrow .page-section-inner { + --section-width: var(--container-narrow); +} + +.section-width-wide .page-section-inner { + --section-width: var(--container-wide); +} + +.section-width-full .page-section-inner { + --section-width: 100%; +} + +.section-grid { + display: grid; + gap: var(--grid-gap); + grid-template-columns: minmax(0, 1fr); + align-items: start; +} + +@container section (min-width: 40rem) { + .section-grid { + grid-template-columns: var(--section-cols-md, minmax(0, 1fr)); + } +} + +@container section (min-width: 60rem) { + .section-grid { + grid-template-columns: var(--section-cols-lg, minmax(0, 1fr)); + } +} + +.section-slot { + min-width: 0; + container-type: inline-size; + container-name: slot; +} + +/* Flächen */ +.section-bg-light { + --color-surface: var(--color-surface-subtle); +} + +/* Dunkle Fläche und Markenakzent: Bedeutungswerte aus .scope-dark / .scope-accent (tokens.css). */ +.section-bg-dark, +.section-bg-accent { + background: var(--color-surface); +} + +/* Hintergrundbild mit Fokuspunkt (object-position) und Überlagerung für ausreichenden Kontrast. */ +.section-bg-image { + --color-surface: var(--lf-navy); + overflow: hidden; +} + +.page-section-image { + position: absolute; + inset: 0; + z-index: -2; + width: 100%; + height: 100%; + object-fit: cover; +} + +.section-bg-image::before { + content: ''; + position: absolute; + inset: 0; + z-index: -1; + pointer-events: none; +} + +.section-overlay-light::before { + background: rgb(255 255 255 / 84%); +} + +.section-overlay-dark::before { + background: rgb(3 37 81 / 78%); +} + +/* Ohne Überlagerung bleibt die Schrift dunkel; geeignet für Widgets mit eigener heller Fläche. */ +.section-overlay-none { + --color-surface: transparent; +} + +/* Trenner zwischen Abschnitten */ +.section-divider { + width: min(var(--container-standard), 100% - 2 * var(--gutter)); + margin-inline: auto; +} + +.section-divider-line { + padding-block: var(--space-5); +} + +.section-divider-line span { + display: block; + border-top: 1px solid var(--lf-line); +} + +.section-divider-accent { + display: flex; + justify-content: center; + padding-block: var(--space-2); +} + +.section-divider-accent span { + display: block; + width: 4.5rem; + height: 5px; + border-radius: 5px; + background: var(--lf-yellow); +} diff --git a/resources/css/site.css b/resources/css/site.css new file mode 100644 index 0000000..5a01427 --- /dev/null +++ b/resources/css/site.css @@ -0,0 +1,416 @@ +/* Globales Website-Gerüst: Kopfzeile, Hauptnavigation, mobile Navigation, Fußbereich, Seitenfläche. */ + +/* Wortmarke (vorläufiger Schriftzug, bis eine freigegebene Logodatei vorliegt). */ +.brand { + display: inline-flex; + flex-direction: column; + gap: 0.1rem; + color: var(--color-heading); + text-decoration: none; + line-height: 1; + min-height: var(--touch-target); + justify-content: center; +} + +.brand:hover { + color: var(--color-heading); +} + +.brand-name { + font-family: var(--font-display); + font-weight: 800; + font-size: 1.375rem; + letter-spacing: -0.02em; + white-space: nowrap; +} + +.brand-claim { + font-size: 0.8125rem; + font-weight: 600; + color: var(--color-text-muted); + white-space: nowrap; +} + +/* Kopfzeile: kompakt und klebend; nimmt höchstens 4,5 rem ein. */ +.site-header { + position: sticky; + top: 0; + z-index: 50; + background: var(--lf-white); + border-bottom: 1px solid var(--color-border); +} + +.site-header.is-scrolled { + box-shadow: 0 6px 18px rgb(3 37 81 / 8%); +} + +.site-header-inner { + display: flex; + align-items: center; + gap: var(--space-4) var(--space-6); + min-height: var(--header-height); +} + +.site-header-actions { + display: flex; + align-items: center; + gap: var(--space-2); + margin-left: auto; +} + +.site-icon-link, +.site-menu-button { + display: inline-flex; + align-items: center; + justify-content: center; + gap: var(--space-2); + min-width: var(--touch-target); + min-height: var(--touch-target); + padding: 0 var(--space-3); + border: 1px solid var(--color-border-strong); + border-radius: var(--radius-pill); + background: transparent; + color: var(--color-heading); + font: inherit; + font-weight: 600; + text-decoration: none; + cursor: pointer; +} + +.site-icon-link:hover, +.site-menu-button:hover { + border-color: var(--color-heading); + color: var(--color-heading); +} + +.site-icon-link svg, +.site-menu-button svg { + width: 1.25rem; + height: 1.25rem; + flex: none; +} + +/* Hauptnavigation (Desktop) */ +.site-nav-list, +.site-subnav { + list-style: none; + margin: 0; + padding: 0; +} + +.site-nav { + flex: 1 1 auto; + min-width: 0; +} + +.site-nav-list { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: var(--space-1) 0; +} + +.site-nav-item { + position: relative; + display: flex; + align-items: center; +} + +.site-nav a { + display: inline-flex; + align-items: center; + min-height: var(--touch-target); + padding: 0 0.6rem; + font-size: 1rem; + color: var(--color-heading); + font-weight: 600; + text-decoration: none; + border-radius: var(--radius-small); +} + +.site-nav a:hover { + text-decoration: underline; +} + +.site-nav a[aria-current='page'], +.site-nav .is-active-trail > a { + box-shadow: inset 0 -3px 0 var(--color-accent); +} + +.site-nav-toggle { + display: inline-flex; + align-items: center; + justify-content: center; + width: 2rem; + min-height: var(--touch-target); + border: 0; + background: transparent; + color: var(--color-heading); + cursor: pointer; + border-radius: var(--radius-small); +} + +.site-nav-toggle svg { + width: 1rem; + height: 1rem; + transition: transform 0.15s ease; +} + +.site-nav-toggle[aria-expanded='true'] svg { + transform: rotate(180deg); +} + +.site-subnav { + display: none; +} + +.site-subnav a { + width: 100%; +} + +@media (min-width: 75rem) { + .site-subnav { + position: absolute; + top: 100%; + left: 0; + min-width: 15rem; + padding: var(--space-2); + background: var(--lf-white); + border: 1px solid var(--color-border); + border-radius: var(--radius-card); + box-shadow: var(--shadow-raised); + } + + .site-nav-item.is-open > .site-subnav { + display: block; + } +} + +.site-menu-button { + display: none; +} + +/* + * Mobile Navigation (unter 75 rem, nur mit JavaScript): Menü-Schaltfläche in der Kopfzeile öffnet eine + * Fläche unter der Kopfzeile. Ohne JavaScript bleibt die Navigation als umbrechende Liste sichtbar. + */ +@media (max-width: 74.99rem) { + .site-header-inner { + flex-wrap: wrap; + } + + .site-account-label { + position: absolute; + width: 1px; + height: 1px; + overflow: hidden; + clip: rect(0 0 0 0); + white-space: nowrap; + } + + html:not(.js) .site-nav { + order: 3; + flex-basis: 100%; + padding-bottom: var(--space-2); + } + + html.js .site-menu-button { + display: inline-flex; + } + + html.js .site-nav { + display: none; + position: fixed; + inset: var(--header-height) 0 0; + z-index: 49; + overflow-y: auto; + overscroll-behavior: contain; + background: var(--lf-white); + padding: var(--space-4) var(--gutter) var(--space-8); + border-top: 1px solid var(--color-border); + } + + html.js .site-header.is-menu-open .site-nav { + display: block; + } + + html.js .site-nav-list { + display: block; + } + + html.js .site-nav-item { + display: block; + border-bottom: 1px solid var(--color-border); + } + + html.js .site-nav a { + min-height: 3rem; + font-size: 1.125rem; + width: 100%; + } + + html.js .site-nav-toggle { + display: none; + } + + html.js .site-subnav { + display: block; + padding: 0 0 var(--space-2) var(--space-4); + } + + html.js .site-subnav a { + font-size: 1rem; + font-weight: 400; + min-height: var(--touch-target); + } + + body.has-open-menu { + overflow: hidden; + } +} + +/* Inhaltsfläche */ +.site-main { + display: block; + min-height: 50vh; +} + +/* Klassische Inhaltsseiten (Programme, Themen, Anmeldung): ein Blatt in Standardbreite. */ +.sheet { + width: min(var(--container-standard), 100% - 2 * var(--gutter)); + margin-inline: auto; + padding: clamp(1.5rem, 4vw, 3.5rem) 0 clamp(3rem, 6vw, 5rem); +} + +.sheet > .block + .block { + margin-top: var(--space-6); +} + +.themes { + list-style: none; + padding: 0; + margin: var(--space-5) 0 0; +} + +.themes li { + border-top: 1px solid var(--color-border); + padding: var(--space-4) 0; +} + +.themes a { + font-family: var(--font-display); + font-weight: 700; + font-size: var(--text-h3); + text-decoration: none; +} + +.themes p { + max-width: var(--measure); + margin: var(--space-1) 0 0; +} + +.catalog, +.course { + list-style: none; + padding: 0; + display: grid; + gap: var(--space-4); +} + +.catalog li, +.course li { + background: var(--color-surface-raised); + border: 1px solid var(--color-border); + border-radius: var(--radius-card); + padding: var(--space-4) var(--space-5); + display: grid; + gap: var(--space-2); +} + +.catalog video, +.course video { + width: min(100%, 40rem); + background: #111; +} + +.course h2 { + font-size: var(--text-h3); + margin: 0 0 var(--space-2); +} + +.course-actions { + display: flex; + flex-wrap: wrap; + gap: var(--space-2); +} + +/* Fußbereich */ +.site-footer { + background: var(--color-surface); + color: var(--color-text); + padding: var(--space-8) 0 var(--space-7); + margin-top: 0; +} + +.site-footer-inner { + display: grid; + gap: var(--space-6) var(--space-7); +} + +@media (min-width: 48rem) { + .site-footer-inner { + grid-template-columns: minmax(12rem, 1.2fr) repeat(auto-fit, minmax(11rem, 1fr)); + } +} + +.site-footer .brand { + color: var(--color-heading); +} + +.site-footer-brand p { + margin: var(--space-3) 0 0; + color: var(--color-text-muted); + font-size: var(--text-small); + max-width: 22rem; +} + +.site-footer h2 { + font-family: var(--font-reading); + font-size: 0.875rem; + font-weight: 700; + letter-spacing: 0.08em; + text-transform: uppercase; + color: var(--color-text-muted); + margin: 0 0 var(--space-3); +} + +.site-footer ul { + list-style: none; + margin: 0; + padding: 0; +} + +.site-footer li a { + display: inline-flex; + align-items: center; + min-height: var(--touch-target); + color: var(--color-link); +} + +.site-footer-meta { + grid-column: 1 / -1; + border-top: 1px solid var(--color-border); + padding-top: var(--space-4); + font-size: var(--text-small); + color: var(--color-text-muted); +} + +/* Fußbereich schließt auch kurze Seiten am unteren Rand ab (nicht im Mitgliederbereich). */ +body:not(.member) { + display: flex; + flex-direction: column; +} + +body:not(.member) > main { + flex: 1 0 auto; +} diff --git a/resources/css/tokens.css b/resources/css/tokens.css new file mode 100644 index 0000000..a0acff1 --- /dev/null +++ b/resources/css/tokens.css @@ -0,0 +1,168 @@ +/* + * Lara & Felix – gemeinsames Designsystem, Ebene 1 und 2 (ADR-36, Website-Zielkonzept 7.1). + * + * VORLÄUFIG: Die Markenwerte stammen aus docs/Brand-UI-Kit/02_design_tokens (Entwurf vom 15.11.2026, + * aus den Originalmotiven abgeleitet, nicht freigegeben). Schriften nach Website-Zielkonzept 7.2 + * (Empfehlung, nicht freigegeben). Eine Freigabe ändert nur diese Datei. + * + * Regeln: + * - Komponenten und Widgets verwenden ausschließlich Bedeutungswerte (--color-text, --color-surface, …). + * - Markengelb nie als Textfarbe auf hellem Grund; Markengrün #5b8625 nur für Flächen ohne Text. + * - Abschnittsflächen (.section-bg-*) und Komponenten mit eigener Fläche setzen die Bedeutungswerte neu. + */ + +@theme { + --font-sans: 'Source Sans 3', 'Segoe UI', system-ui, sans-serif; + --font-display: 'Nunito', 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif; +} + +:root { + /* Ebene 1: Markenwerte (vorläufig) */ + --lf-navy: #032551; + --lf-navy-deep: #01244c; + --lf-green: #5b8625; + --lf-green-deep: #3b7b09; + --lf-yellow: #fcd10a; + --lf-cream: #f7f6f2; + --lf-white: #ffffff; + --lf-ink: #15243a; + + /* Ergänzende UI-Werte (eigene Ableitung, Kontrast geprüft) */ + --lf-ink-muted: #3e4c5c; + --lf-line: #d5ddd6; + --lf-line-strong: #8a9a92; + --lf-focus: #1769aa; + --lf-green-tint: #e8f0de; + --lf-yellow-tint: #fff4d6; + + /* Ebene 2: Bedeutungswerte (heller Grund) */ + --color-text: var(--lf-ink); + --color-text-muted: var(--lf-ink-muted); + --color-heading: var(--lf-navy); + --color-link: var(--lf-navy); + --color-link-hover: var(--lf-green-deep); + --color-surface: var(--lf-white); + --color-surface-subtle: var(--lf-cream); + --color-surface-raised: var(--lf-white); + --color-border: var(--lf-line); + --color-border-strong: var(--lf-line-strong); + --color-focus: var(--lf-focus); + --color-accent: var(--lf-yellow); + --color-action: var(--lf-green-deep); + --color-action-hover: #2f6407; + --color-action-text: var(--lf-white); + --color-action-secondary-text: var(--lf-navy); + --color-success: #1b5e32; + --color-success-surface: #e5f4ec; + --color-warning: #6b4a00; + --color-warning-surface: var(--lf-yellow-tint); + --color-danger: #8e1b24; + --color-danger-surface: #fbe9ea; + --color-info: var(--lf-navy); + --color-info-surface: #e8eef6; + --color-disabled: #6b7682; + --color-disabled-surface: #eceeec; + + /* Themensignaturen der fünf Themenbereiche: vorbereitet, Tönungen und Symbole sind nicht freigegeben. + Bis zur Freigabe tragen Nummer und Name die Unterscheidung; alle Tönungen sind neutral. */ + --color-theme-1: var(--color-surface-subtle); + --color-theme-2: var(--color-surface-subtle); + --color-theme-3: var(--color-surface-subtle); + --color-theme-4: var(--color-surface-subtle); + --color-theme-5: var(--color-surface-subtle); + + /* Typografie (Website-Zielkonzept 7.2: Fließtext 17 → 18 px, H1 34 → 52 px) */ + --font-reading: var(--font-sans); + --text-small: 0.9375rem; + --text-body: clamp(1.0625rem, 1.03rem + 0.15vw, 1.125rem); + --text-lede: clamp(1.125rem, 1.05rem + 0.4vw, 1.3125rem); + --text-h3: clamp(1.25rem, 1.16rem + 0.4vw, 1.375rem); + --text-h2: clamp(1.625rem, 1.35rem + 1.2vw, 2.125rem); + --text-h1: clamp(2.125rem, 1.6rem + 2.4vw, 3.25rem); + --leading-body: 1.6; + --leading-heading: 1.15; + --measure: 70ch; + + /* Abstände (Grundmaß 4 px) */ + --space-1: 0.25rem; + --space-2: 0.5rem; + --space-3: 0.75rem; + --space-4: 1rem; + --space-5: 1.5rem; + --space-6: 2rem; + --space-7: 3rem; + --space-8: 4rem; + --space-9: 6rem; + + /* Rundungen und Schatten */ + --radius-small: 8px; + --radius-card: 14px; + --radius-panel: 22px; + --radius-pill: 999px; + --shadow-raised: 0 10px 28px rgb(3 37 81 / 8%); + + /* Layoutmaße */ + --gutter: clamp(1rem, 4vw, 2rem); + --grid-gap: clamp(1.25rem, 2.5vw, 2rem); + --container-narrow: 45rem; + --container-standard: 75rem; + --container-wide: 90rem; + --header-height: 4rem; + --touch-target: 2.75rem; +} + +@media (min-width: 75rem) { + :root { + --header-height: 4.5rem; + } +} + +/* Dunkle Fläche: helle Schrift, gelber Fokus (Navy/Weiß 15:1). */ +.scope-dark { + --color-text: #f4f6f8; + --color-text-muted: #d3dde8; + --color-heading: var(--lf-white); + --color-link: var(--lf-white); + --color-link-hover: var(--lf-yellow); + --color-surface: var(--lf-navy); + --color-border: rgb(255 255 255 / 28%); + --color-border-strong: rgb(255 255 255 / 55%); + --color-focus: var(--lf-yellow); + --color-action: var(--lf-yellow); + --color-action-hover: #ffe05c; + --color-action-text: var(--lf-navy); + --color-action-secondary-text: var(--lf-white); +} + +/* Markenakzent: dunkles Grün mit weißer Schrift (5,2:1). */ +.scope-accent { + --color-text: var(--lf-white); + --color-text-muted: #eef4e8; + --color-heading: var(--lf-white); + --color-link: var(--lf-white); + --color-link-hover: var(--lf-yellow); + --color-surface: var(--lf-green-deep); + --color-border: rgb(255 255 255 / 35%); + --color-border-strong: rgb(255 255 255 / 65%); + --color-focus: var(--lf-yellow); + --color-action: var(--lf-white); + --color-action-hover: var(--lf-cream); + --color-action-text: var(--lf-navy); + --color-action-secondary-text: var(--lf-white); +} + +/* Heller Grund, zum Beispiel Karten auf dunklen Abschnitten. */ +.scope-light { + --color-text: var(--lf-ink); + --color-text-muted: var(--lf-ink-muted); + --color-heading: var(--lf-navy); + --color-link: var(--lf-navy); + --color-link-hover: var(--lf-green-deep); + --color-border: var(--lf-line); + --color-border-strong: var(--lf-line-strong); + --color-focus: var(--lf-focus); + --color-action: var(--lf-green-deep); + --color-action-hover: #2f6407; + --color-action-text: var(--lf-white); + --color-action-secondary-text: var(--lf-navy); +} diff --git a/resources/css/widgets.css b/resources/css/widgets.css new file mode 100644 index 0000000..de6b302 --- /dev/null +++ b/resources/css/widgets.css @@ -0,0 +1,331 @@ +/* + * Widget-Ansichten. Jede Regel verwendet Bedeutungswerte und richtet sich nach der Slotbreite + * (Container „slot“), nicht nach dem Fenster. Die visuelle Veredelung einzelner Widgets erfolgt später; + * Struktur und Klassen bleiben dafür stabil. + */ + +.widget { + color: var(--color-text); +} + +.widget > :last-child, +.widget .prose > :last-child { + margin-bottom: 0; +} + +/* Überschrift */ +.widget-heading h1, +.widget-heading h2 { + max-width: 22ch; +} + +/* Einstieg (Hero). Varianten: standard, highlight. Stufen: schmal (Bild unter Text), breit (nebeneinander). */ +.hero { + display: grid; + gap: var(--space-5); + align-items: center; +} + +.hero h1, +.hero h2 { + font-size: clamp(2rem, 1.1rem + 4.2cqi, 3.5rem); + max-width: 16ch; +} + +.hero .lede { + max-width: 52ch; +} + +.hero .button { + margin-top: var(--space-2); +} + +.hero-image { + width: 100%; + display: block; + border-radius: var(--radius-panel); + aspect-ratio: 4 / 3; + object-fit: cover; +} + +@container slot (min-width: 48rem) { + .hero-with-image { + grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); + gap: var(--space-7); + } +} + +.hero-highlight { + padding: clamp(1.5rem, 5cqi, 3.5rem); + border-radius: var(--radius-panel); + background: var(--lf-navy); + --color-text: #f4f6f8; + --color-heading: var(--lf-white); + --color-link: var(--lf-white); + --color-focus: var(--lf-yellow); + --color-action: var(--lf-yellow); + --color-action-hover: #ffe05c; + --color-action-text: var(--lf-navy); + color: var(--color-text); +} + +/* Fließtext */ +.widget-prose .prose p { + margin: 0 0 var(--space-4); +} + +/* Bild und Text. Varianten: image_left, image_right. Stufen: schmal (gestapelt), breit (nebeneinander ab 36rem). */ +.image-text { + display: grid; + gap: var(--space-5); +} + +.image-text img { + width: 100%; + display: block; + border-radius: var(--radius-card); +} + +@container slot (min-width: 36rem) { + .image-text { + grid-template-columns: minmax(12rem, 0.8fr) minmax(0, 1.2fr); + align-items: center; + gap: var(--space-6); + } + + .image-text-right { + grid-template-columns: minmax(0, 1.2fr) minmax(12rem, 0.8fr); + } + + .image-text-right > img { + order: 2; + } + + .image-text-no-image { + grid-template-columns: minmax(0, 1fr); + } +} + +.image-text-copy > :first-child { + margin-top: 0; +} + +/* Redaktionelle Karten. Varianten: Raster (cards-grid), kompakte Liste (cards-compact). */ +.cards { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(min(14rem, 100%), 1fr)); + gap: var(--space-4); + list-style: none; + padding: 0; + margin: 0; +} + +.card { + background: var(--lf-white); + border: 1px solid var(--lf-line); + border-radius: var(--radius-card); + padding: var(--space-5); + overflow: hidden; + color: var(--lf-ink); + --color-text: var(--lf-ink); + --color-heading: var(--lf-navy); + --color-link: var(--lf-navy); + --color-focus: var(--lf-focus); +} + +.card h3 { + margin: 0 0 var(--space-2); +} + +.card p { + margin: 0; + color: var(--lf-ink-muted); +} + +.card a { + color: inherit; + text-decoration: none; + display: block; +} + +.card a:hover h3 { + text-decoration: underline; +} + +.card-image { + display: block; + width: calc(100% + 2 * var(--space-5)); + max-width: none; + aspect-ratio: 4 / 3; + object-fit: cover; + margin: calc(-1 * var(--space-5)) calc(-1 * var(--space-5)) var(--space-4); +} + +.cards-compact { + grid-template-columns: minmax(0, 1fr); + gap: 0; +} + +.cards-compact .card { + border-width: 0 0 1px; + border-radius: 0; + background: transparent; + padding: var(--space-3) 0; + color: var(--color-text); + --color-heading: inherit; + border-color: var(--color-border); +} + +.cards-compact .card p { + color: var(--color-text-muted); +} + +.cards-compact .card-image { + display: none; +} + +/* Programm- und Modulkarten. Inhalte kommen aus den Fachdaten. */ +.catalog-list { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(min(16rem, 100%), 1fr)); + gap: var(--space-4); + list-style: none; + padding: 0; + margin: var(--space-4) 0 0; +} + +.catalog-card { + background: var(--lf-white); + border: 1px solid var(--lf-line); + border-radius: var(--radius-card); + overflow: hidden; + display: flex; + flex-direction: column; + color: var(--lf-ink); + --color-text: var(--lf-ink); + --color-heading: var(--lf-navy); + --color-link: var(--lf-navy); + --color-focus: var(--lf-focus); +} + +.catalog-card-visual { + background: var(--lf-cream); + border-bottom: 4px solid var(--lf-yellow); + min-height: 6rem; + display: flex; + align-items: flex-end; + padding: var(--space-3) var(--space-4); +} + +.catalog-card-visual span { + font-family: var(--font-display); + font-weight: 800; + font-size: 1.125rem; + color: var(--lf-navy); +} + +.catalog-card-body { + padding: var(--space-4) var(--space-5) var(--space-5); +} + +.catalog-card-body h3 { + margin: 0 0 var(--space-2); +} + +.catalog-card-body p { + margin: 0 0 var(--space-2); +} + +.catalog-card-kind { + font-size: 0.8125rem; + font-weight: 700; + text-transform: uppercase; + letter-spacing: 0.08em; + color: var(--lf-ink-muted); +} + +.catalog-cards-compact .catalog-list { + grid-template-columns: minmax(0, 1fr); + gap: 0; +} + +.catalog-cards-compact .catalog-card { + border-width: 0 0 1px; + border-radius: 0; + background: transparent; + color: var(--color-text); + --color-text: inherit; + --color-heading: inherit; + --color-link: inherit; + border-color: var(--color-border); +} + +.catalog-cards-compact .catalog-card-body { + padding: var(--space-3) 0; +} + +.catalog-cards-compact .catalog-card-kind { + color: inherit; + opacity: 0.85; +} + +.catalog-card-internal { + border-style: dashed; +} + +/* Handlungsaufruf */ +.cta { + background: var(--color-surface-subtle); + border-radius: var(--radius-panel); + padding: clamp(1.25rem, 5cqi, 2.5rem); + color: var(--lf-ink); + --color-heading: var(--lf-navy); + --color-text: var(--lf-ink); + --color-link: var(--lf-navy); + --color-focus: var(--lf-focus); + --color-action: var(--lf-green-deep); + --color-action-hover: #2f6407; + --color-action-text: var(--lf-white); +} + +.cta h2 { + font-size: clamp(1.5rem, 1.1rem + 2cqi, 2.125rem); +} + +.cta p { + max-width: var(--measure); +} + +.cta a { + margin-top: var(--space-2); +} + +@container slot (max-width: 20rem) { + .cta a { + width: 100%; + } +} + +/* Häufige Fragen */ +.faq { + margin: 0; +} + +.faq dt { + font-family: var(--font-display); + font-weight: 700; + font-size: 1.125rem; + color: var(--color-heading); + padding-top: var(--space-4); + border-top: 1px solid var(--color-border); +} + +.faq dt:first-child { + border-top: 0; + padding-top: 0; +} + +.faq dd { + margin: var(--space-2) 0 var(--space-4); + max-width: var(--measure); +} diff --git a/resources/js/app.js b/resources/js/app.js index 3a6d376..3bc512a 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -1,4 +1,5 @@ import Hls from 'hls.js'; +import './site-nav.js'; function attachPlayback(video) { if (!(video instanceof HTMLVideoElement) || video.dataset.playbackReady === '1') { diff --git a/resources/js/site-nav.js b/resources/js/site-nav.js new file mode 100644 index 0000000..2bc6789 --- /dev/null +++ b/resources/js/site-nav.js @@ -0,0 +1,137 @@ +/** + * Website-Kopfzeile: mobile Navigation, Untermenüs und Schatten beim Scrollen. + * Ohne JavaScript bleibt die Navigation als umbrechende Liste bedienbar (CSS: html:not(.js)). + */ +const DESKTOP = window.matchMedia('(min-width: 75rem)'); + +function focusableIn(element) { + return [...element.querySelectorAll('a[href], button:not([disabled])')].filter((node) => node.offsetParent !== null); +} + +function setupMenu(header) { + const button = header.querySelector('[data-site-menu-button]'); + const nav = header.querySelector('#site-nav'); + + if (!button || !nav) { + return; + } + + const label = button.querySelector('[data-menu-label]'); + const iconOpen = button.querySelector('[data-icon-open]'); + const iconClose = button.querySelector('[data-icon-close]'); + + const setOpen = (open, { restoreFocus = true } = {}) => { + header.classList.toggle('is-menu-open', open); + document.body.classList.toggle('has-open-menu', open); + button.setAttribute('aria-expanded', String(open)); + if (label) { + label.textContent = open ? 'Schließen' : 'Menü'; + } + iconOpen?.toggleAttribute('hidden', open); + iconClose?.toggleAttribute('hidden', !open); + + if (open) { + focusableIn(nav)[0]?.focus(); + } else if (restoreFocus) { + button.focus(); + } + }; + + button.addEventListener('click', () => setOpen(button.getAttribute('aria-expanded') !== 'true')); + + header.addEventListener('keydown', (event) => { + if (!header.classList.contains('is-menu-open')) { + return; + } + + if (event.key === 'Escape') { + event.preventDefault(); + setOpen(false); + + return; + } + + // Fokus bleibt in Menü und Menü-Schaltfläche, solange das Menü offen ist. + if (event.key === 'Tab') { + const items = [button, ...focusableIn(nav)]; + const index = items.indexOf(document.activeElement); + const next = event.shiftKey ? index - 1 : index + 1; + + if (index === -1 || next < 0 || next >= items.length) { + event.preventDefault(); + items[event.shiftKey ? items.length - 1 : 0].focus(); + } + } + }); + + nav.addEventListener('click', (event) => { + if (event.target.closest('a[href]:not([data-site-subnav-label])') && header.classList.contains('is-menu-open')) { + setOpen(false, { restoreFocus: false }); + } + }); + + DESKTOP.addEventListener('change', (event) => { + if (event.matches && header.classList.contains('is-menu-open')) { + setOpen(false, { restoreFocus: false }); + } + }); +} + +function setupSubmenus(header) { + const items = [...header.querySelectorAll('.site-nav-item.has-children')]; + + const close = (item, focusToggle = false) => { + item.classList.remove('is-open'); + const toggle = item.querySelector('[data-site-subnav-toggle]'); + toggle?.setAttribute('aria-expanded', 'false'); + if (focusToggle) { + toggle?.focus(); + } + }; + + items.forEach((item) => { + const toggle = item.querySelector('[data-site-subnav-toggle]'); + const label = item.querySelector('[data-site-subnav-label]'); + + const open = () => { + items.filter((other) => other !== item).forEach((other) => close(other)); + item.classList.add('is-open'); + toggle?.setAttribute('aria-expanded', 'true'); + }; + + toggle?.addEventListener('click', () => (item.classList.contains('is-open') ? close(item) : open())); + label?.addEventListener('click', (event) => { + event.preventDefault(); + item.classList.contains('is-open') ? close(item) : open(); + }); + + item.addEventListener('keydown', (event) => { + if (event.key === 'Escape' && item.classList.contains('is-open')) { + event.stopPropagation(); + close(item, true); + } + }); + + item.addEventListener('focusout', (event) => { + if (DESKTOP.matches && !item.contains(event.relatedTarget)) { + close(item); + } + }); + }); + + document.addEventListener('click', (event) => { + items.filter((item) => !item.contains(event.target)).forEach((item) => close(item)); + }); +} + +function setupShadow(header) { + const update = () => header.classList.toggle('is-scrolled', window.scrollY > 8); + window.addEventListener('scroll', update, { passive: true }); + update(); +} + +document.querySelectorAll('[data-site-header]').forEach((header) => { + setupMenu(header); + setupSubmenus(header); + setupShadow(header); +}); diff --git a/resources/views/components/site/brand.blade.php b/resources/views/components/site/brand.blade.php index 15f37ed..59a97be 100644 --- a/resources/views/components/site/brand.blade.php +++ b/resources/views/components/site/brand.blade.php @@ -1,10 +1,10 @@ {{-- - Markenzeichen der Website. Solange keine freigegebene Wortmarke als Datei vorliegt - (docs/Brand-UI-Kit/README.md, Abschnitt Markenleitlinien Nr. 5), bleibt es die Textwortmarke. - Eine freigegebene Datei wird ausschließlich hier eingesetzt. + Wortmarke. VORLÄUFIG: Es liegt keine freigegebene Logodatei vor (docs/Brand-UI-Kit/README.md, Markenleitlinie 5). + Bis dahin steht hier ein schlichter Schriftzug in der vorläufigen Auszeichnungsschrift, ohne Nachbildung der + Filmwortmarke (keine Drehung, kein Unterstrich-Schwung). Eine freigegebene SVG-Datei wird ausschließlich hier eingesetzt. --}} -@props(['compact' => false]) -
class(['wordmark', 'wordmark-compact' => $compact]) }}> - Lara & Felix - Stark im Alltag -
+@props(['href' => null, 'claim' => 'Stark im Alltag']) +class(['brand']) }} href="{{ $href ?? route('home') }}" data-brand-status="vorlaeufig"> + Lara & Felix + {{ $claim }} + diff --git a/resources/views/components/site/cart-link.blade.php b/resources/views/components/site/cart-link.blade.php new file mode 100644 index 0000000..85576e3 --- /dev/null +++ b/resources/views/components/site/cart-link.blade.php @@ -0,0 +1,10 @@ +{{-- + Vorbereiteter Warenkorbzugang. Der Warenkorb gehört zum kommerziellen Anwendungssystem, nicht zum CMS. + Solange cms.cart.enabled nicht gesetzt ist, wird nichts ausgegeben: kein funktionsloser Kaufknopf. +--}} +@if (config('cms.cart.enabled') && filled(config('cms.cart.url'))) + + +@endif diff --git a/resources/views/components/site/footer.blade.php b/resources/views/components/site/footer.blade.php index 6f790e3..8bcda1e 100644 --- a/resources/views/components/site/footer.blade.php +++ b/resources/views/components/site/footer.blade.php @@ -1,13 +1,33 @@ -@props(['navigation']) -