Führe Abschnitte mit Raster, gemeinsames Designsystem und globales Website-Gerüst ein.
CI Feature / test (push) Failing after 20s

- 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 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Opus 5.5 committed 2026-11-17 20:34:06 +01:00
1 parent db4bd30319
commit 480d55989b
57 files changed
+4730 -818

No files matched your search

@@ -0,0 +1,87 @@
<?php
namespace App\Console\Commands;
use App\Domain\Cms\Page;
use App\Domain\Cms\PageRevision;
use Carbon\CarbonImmutable;
use Illuminate\Console\Command;
use Throwable;
/**
* Wiederherstellungsweg vor einem Code-Rollback (docs/architektur/cms-widget-registry.md, Abschnitt Rollback).
*
* Setzt die veröffentlichte Revision jeder Seite auf die letzte Revision, die vor dem angegebenen Zeitpunkt
* gespeichert wurde. Revisionen werden weder geändert noch gelöscht; nur der Veröffentlichungszeiger wechselt.
* Ohne --apply wird nur angezeigt, was geschähe.
*/
class RevertPublishedPages extends Command
{
protected $signature = 'cms:revert-published
{--before= : Zeitpunkt des Deployments, zum Beispiel "2026-11-17 18:00" (Zeitzone der Anwendung)}
{--apply : Änderung tatsächlich ausführen}';
protected $description = 'Setzt veröffentlichte Seiten auf ihren Stand vor einem Zeitpunkt zurück (nur Veröffentlichungszeiger).';
public function handle(): int
{
try {
$before = blank($this->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;
}
}
+54 -2
View File
@@ -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<NavigationItem> $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;
}
}
+17 -4
View File
@@ -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<array<string, mixed>>
*/
public function sections(): array
{
return app(PageSections::class)->read($this->sections, $this->blocks);
}
/**
* Widgets in Lesereihenfolge als aktuelle Hüllen.
*
* @return list<array<string, mixed>>
*/
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());
}
}
+45 -11
View File
@@ -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<int|string, mixed> $blocks Bausteine im Altformat oder als Widget-Hülle
* @param array<int|string, mixed> $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<int|string, mixed> $blocks
* @param array<int|string, mixed> $blocks flache Widget-Liste (Rollback-Fassung)
* @param array<int|string, mixed>|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);
}
+345
View File
@@ -0,0 +1,345 @@
<?php
namespace App\Domain\Cms\Sections;
use App\Domain\Cms\Widgets\Support\PublicMedia;
use App\Domain\Cms\Widgets\WidgetRegistry;
use Illuminate\Support\Str;
use Illuminate\Validation\ValidationException;
/**
* Abschnitts- und Slotmodell einer Seite: Seite → Abschnitte → Slots → Widget-Instanzen.
*
* Gespeicherte Hülle eines Abschnitts (Version 1):
* {id, v, layout, style: {background, image, focus, overlay, width, spacing, divider}, slots: [Widget-Hülle|null, …]}
*
* Jeder Slot enthält höchstens ein Widget aus dem zentralen Widget-Register. Abschnitte sind nicht verschachtelbar.
* Revisionen ohne Abschnitte (Bestand vor dieser Fassung) werden beim Lesen als einspaltige Abschnitte gelesen.
*/
class PageSections
{
public const VERSION = 1;
public const MAX_SECTIONS = 30;
public const MAX_WIDGETS = 60;
public function __construct(private readonly WidgetRegistry $widgets) {}
/**
* Lesepfad. Unbekannte Werte fallen auf Vorgaben zurück, unbekannte Widget-Arten entfallen.
*
* @param array<int|string, mixed>|null $sections gespeicherte Abschnitte (Spalte sections)
* @param array<int|string, mixed>|null $blocks flache Bausteinliste (Spalte blocks), nur ohne Abschnitte verwendet
* @return list<array{id: ?string, v: int, layout: string, style: array<string, mixed>, slots: list<array<string, mixed>|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<int|string, mixed> $content
* @return list<array{id: string, v: int, layout: string, style: array<string, mixed>, slots: list<array<string, mixed>|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<array<string, mixed>> $sections
* @return list<array<string, mixed>>
*/
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<array<string, mixed>> $sections
* @return list<string>
*/
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<array<string, mixed>> $sections
*/
public function pageTitle(array $sections): ?string
{
return $this->widgets->pageTitle($this->flatten($sections));
}
/**
* @param array<int|string, mixed> $blocks
* @return list<array{id: ?string, v: int, layout: string, style: array<string, mixed>, slots: list<array<string, mixed>|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<string, mixed> $section
* @return array{id: ?string, v: int, layout: string, style: array<string, mixed>, slots: list<array<string, mixed>|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<string, mixed> $section
* @param array<string, list<string>> $errors
* @param array<string, true> $seenSectionIds
* @param array<string, true> $seenWidgetIds
* @return array{id: string, v: int, layout: string, style: array<string, mixed>, slots: list<array<string, mixed>|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<string, mixed> $style
* @param array<string, list<string>> $errors
* @return array<string, mixed>
*/
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;
}
}
+130
View File
@@ -0,0 +1,130 @@
<?php
namespace App\Domain\Cms\Sections;
/**
* Freigegebene Abschnittsraster. Ein Raster teilt die Abschnittsbreite in höchstens vier logische Einheiten.
* Die Kennungen sind gespeichert und ändern sich nie; neue Raster werden ergänzt, nicht umbenannt.
*
* Die Einheiten werden nicht als eigenes CSS-Grundraster umgesetzt, sondern als Spaltenverhältnis (fr)
* des Abschnittsrasters. Leere Slots entfallen auf der veröffentlichten Seite; die übrigen Slots teilen
* sich die Breite im Verhältnis ihrer Einheiten.
*/
final class SectionLayouts
{
public const DEFAULT = 'u4';
/** @var array<string, list<int>> */
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<string, string> */
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<int>
*/
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<string, string>
*/
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<int> $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('<rect x="%d" y="4" width="%d" height="20" rx="1.5"/>', $x, $w);
$x += $w + $gap;
}
return '<svg class="luf-layout-schematic" viewBox="0 0 60 28" width="60" height="28" aria-hidden="true" focusable="false">'.$rects.'</svg>';
}
}
+127
View File
@@ -0,0 +1,127 @@
<?php
namespace App\Domain\Cms\Sections;
use App\Domain\Cms\Widgets\RenderContext;
use App\Domain\Cms\Widgets\Support\PublicMedia;
use App\Domain\Cms\Widgets\WidgetRenderer;
use Illuminate\Support\HtmlString;
/**
* Einziger Darstellungsweg für Abschnitte: öffentliche Seite und Seitenvorschau rufen denselben Renderer auf.
*
* Regeln:
* - Leere Slots erzeugen keine Leerfläche; die übrigen Slots teilen sich die Breite im Verhältnis ihrer Einheiten.
* - Ein Abschnitt ohne darstellbares Widget entfällt samt Hintergrund und Trenner.
* - Das erste dargestellte Widget der Seite ist der Seiteneinstieg (Überschrift erster Ordnung).
* - Trenner stehen zwischen Abschnitten, nie nach dem letzten.
*/
class SectionRenderer
{
public function __construct(private readonly WidgetRenderer $widgets) {}
/**
* @param list<array<string, mixed>> $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 .= '<div class="section-divider section-divider-'.$divider.'" aria-hidden="true"><span></span></div>';
}
}
return new HtmlString($html);
}
/**
* @param array<string, mixed> $section
* @param list<array{units: int, html: string}> $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 = '<div class="'.e(implode(' ', $classes)).'"'.$id.'>';
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 .= '<img class="page-section-image" src="'.e(PublicMedia::url($style['image'])).'" alt="" '.$loading.' decoding="async"'
.' style="object-position: '.e(SectionStyle::FOCUS_POSITIONS[$style['focus']]).'">';
}
$html .= '<div class="page-section-inner"><div class="section-grid" data-slots="'.count($cells).'"'
.' style="--section-cols-lg: '.e($columns['lg']).'; --section-cols-md: '.e($columns['md']).'">';
foreach ($cells as $cell) {
$html .= '<div class="section-slot" data-units="'.$cell['units'].'">'.$cell['html'].'</div>';
}
return $html.'</div></div></div>';
}
}
+150
View File
@@ -0,0 +1,150 @@
<?php
namespace App\Domain\Cms\Sections;
/**
* Semantische Abschnittsgestaltung. Jeder Wert ist eine Aufzählung, die auf zentrale Design-Tokens
* abgebildet wird (resources/css/app.css, Abschnitt „Abschnitte“). Keine freie CSS- oder Farbangabe.
*/
final class SectionStyle
{
/** @var array<string, string> */
public const BACKGROUNDS = [
'default' => 'Standard (ohne eigene Fläche)',
'light' => 'Helle Markenfläche',
'dark' => 'Dunkle Markenfläche',
'accent' => 'Markenakzent',
'image' => 'Hintergrundbild',
];
/** @var array<string, string> */
public const WIDTHS = [
'narrow' => 'Schmal (Lesebreite)',
'standard' => 'Standard',
'wide' => 'Breit',
'full' => 'Volle Breite',
];
/** @var array<string, string> */
public const SPACINGS = [
'compact' => 'Kompakt',
'normal' => 'Normal',
'large' => 'Großzügig',
];
/** @var array<string, string> */
public const DIVIDERS = [
'none' => 'Kein Trenner',
'space' => 'Zusätzlicher Abstand',
'line' => 'Dezente Linie',
'accent' => 'Markenakzent',
];
/** @var array<string, string> */
public const OVERLAYS = [
'light' => 'Helle Überlagerung (dunkle Schrift)',
'dark' => 'Dunkle Überlagerung (helle Schrift)',
'none' => 'Keine Überlagerung',
];
/** @var array<string, string> */
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<string, array<string, string>>
*/
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<string, mixed> $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);
}
}
+104
View File
@@ -0,0 +1,104 @@
<?php
namespace App\Domain\Cms;
use Illuminate\Support\Collection;
/**
* Baut Kopf- und Fußnavigation aus dem CMS-Navigationsmodell. Keine fest codierten Menüpunkte.
*
* Die Ausgabe hängt nur von der Navigation und dem angefragten Pfad ab, nie vom Anmeldestatus,
* damit öffentliche Seiten für alle Besucher gleich ausgeliefert werden können (ADR-32).
*/
final class SiteNavigation
{
/**
* @param Collection<int, NavigationItem> $items sichtbare Einträge, sortiert
*/
public function __construct(private readonly Collection $items, private readonly string $currentPath) {}
/**
* @param Collection<int, NavigationItem> $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<array{id: int, label: string, href: ?string, current: bool, activeTrail: bool, children: list<array{id: int, label: string, href: string, current: bool}>}>
*/
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<array{key: string, heading: string, links: list<array{label: string, href: string, current: bool}>}>
*/
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;
}
}
@@ -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';
@@ -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';
@@ -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';
@@ -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';
@@ -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';
@@ -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';
@@ -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;
@@ -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';
+49 -34
View File
@@ -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<int|string, mixed> $blocks
* @return list<array{id: string, type: string, v: int, variant: string, settings: array<string, mixed>, data: array<string, mixed>, refs: array<string, mixed>}>
@@ -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<string, true> $seenIds
* @return array{id: string, type: string, v: int, variant: string, settings: array<string, mixed>, data: array<string, mixed>, refs: array<string, mixed>}
*/
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<string, true> $seenIds
* @return array{id: string, type: string, v: int, variant: string, settings: array<string, mixed>, data: array<string, mixed>, refs: array<string, mixed>}
*/
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);
+26
View File
@@ -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<string, string>
*/
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
{
@@ -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.'),
]);
}
+38 -5
View File
@@ -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
@@ -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'] ?? []),
);
}
}
@@ -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'] ?? []),
);
}
@@ -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')
@@ -0,0 +1,35 @@
<?php
namespace App\Filament\Support;
use Illuminate\Validation\ValidationException;
/**
* Macht Feldfehler aus Widget-Dialogen am Abschnitt sichtbar. Die Felder eines Widgets liegen in seinem Dialog;
* schlägt die Formularprüfung beim Speichern fehl, erscheint eine Meldung mit Abschnitt, Platz und Widget-Art,
* und das Platzraster des Abschnitts trägt eine Zusammenfassung.
*/
trait ReportsSectionErrors
{
protected function onValidationError(ValidationException $exception): void
{
parent::onValidationError($exception);
$state = is_array($this->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);
}
}
}
}
}
+516
View File
@@ -0,0 +1,516 @@
<?php
namespace App\Filament\Support;
use App\Domain\Cms\Sections\PageSections;
use App\Domain\Cms\Sections\SectionLayouts;
use App\Domain\Cms\Sections\SectionStyle;
use App\Domain\Cms\Widgets\Support\PublicMedia;
use App\Domain\Cms\Widgets\WidgetRegistry;
use Filament\Actions\Action;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\Repeater;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\ToggleButtons;
use Filament\Notifications\Notification;
use Filament\Schemas\Components\Group;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Components\Utilities\Set;
use Illuminate\Support\HtmlString;
use Illuminate\Support\Str;
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
/**
* Seiteneditor für Abschnitte und Slots.
*
* Aufbau: Abschnitte (Repeater) → Raster (grafische Auswahl) → Gestaltung (eingeklappt) → Plätze (Repeater im
* Rasterverhältnis) → je Platz ein Widget (Builder mit höchstens einem Eintrag, Auswahl aus dem Widget-Register).
* Abschnittseinstellungen stehen im Abschnitt, Widget-Einstellungen im Widget-Dialog: eine Dialogebene.
*
* Formularzustand eines Abschnitts: {id, layout, style: {...}, slots: {uuid: {widget: {uuid: Builder-Eintrag}}}}.
*/
class SectionEditor
{
public static function repeater(string $name = 'sections'): Repeater
{
return Repeater::make($name)
->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<mixed>
*/
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<mixed>
*/
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<array<string, mixed>> $sections
* @return list<array<string, mixed>>
*/
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<int|string, mixed>|null $state
* @return list<array<string, mixed>>
*/
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<string, mixed> $errors
* @param array<int|string, mixed> $state roher Formularzustand der Abschnitte
* @return array<string, mixed>
*/
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<string, mixed> $errors
* @param array<int|string, mixed> $state
* @return array<string, list<string>>
*/
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<string, list<string>> $errors
* @param array<int|string, mixed> $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<string, array{widget: array<string, mixed>}>
*/
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<string, HtmlString>
*/
private static function layoutOptions(): array
{
$options = [];
foreach (SectionLayouts::UNITS as $key => $units) {
$options[$key] = new HtmlString(
'<span class="luf-layout-option">'.SectionLayouts::schematicSvg($key)
.'<span class="luf-layout-option-text">'.e(SectionLayouts::short($key)).'</span>'
.'<span class="fi-sr-only">'.e(SectionLayouts::LABELS[$key]).'</span></span>'
);
}
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<string, mixed> $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<string, mixed> $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<array<string, mixed>> $items
* @return array<string, array<string, mixed>>
*/
private static function keyed(array $items): array
{
$keyed = [];
foreach ($items as $item) {
$keyed[(string) Str::uuid()] = $item;
}
return $keyed;
}
}
+37 -1
View File
@@ -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
'<span class="luf-widget-pick">'
.self::schematicSvg($type)
.'<span class="luf-widget-pick-text"><span class="luf-widget-pick-name">'.e($type->label()).'</span>'
.'<span class="luf-widget-pick-desc">'.e($type->description()).'</span></span></span>'
.'<span class="luf-widget-pick-desc">'.e($type->description()).'</span>'
.'<span class="luf-widget-pick-units">'.e(self::unitsHint($type)).'</span></span></span>'
);
}
private static function unitsHint(WidgetType $type): string
{
return $type->minUnits() === 1
? 'Passt in jeden Platz'
: 'Braucht einen Platz ab '.$type->minUnits().' Rastereinheiten';
}
/**
* @param array<string, mixed> $state
*/
+3 -2
View File
@@ -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,
]);
}
}
+9
View File
@@ -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'),
],
];
@@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Ergänzend und abwärtskompatibel: Abschnitte mit Raster und Gestaltung liegen in einer neuen Spalte.
* Die Spalte blocks bleibt bestehen und erhält bei jeder neuen Revision die Widgets in Lesereihenfolge,
* damit ein Code-Rollback weiterhin alle Inhalte darstellt. Bestehende Revisionen bleiben unverändert (sections = null).
*/
return new class extends Migration
{
public function up(): void
{
Schema::table('page_revisions', function (Blueprint $table) {
$table->json('sections')->nullable();
});
}
public function down(): void
{
Schema::table('page_revisions', function (Blueprint $table) {
$table->dropColumn('sections');
});
}
};
@@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Ergänzend und abwärtskompatibel: eine Ebene Untermenü für die Hauptnavigation.
* Bestehende Einträge bleiben oberste Ebene (parent_id = null). Wird ein übergeordneter Eintrag gelöscht,
* rücken seine Untereinträge in die oberste Ebene, statt mitgelöscht zu werden.
*/
return new class extends Migration
{
public function up(): void
{
Schema::table('navigation_items', function (Blueprint $table) {
$table->foreignId('parent_id')->nullable()->constrained('navigation_items')->nullOnDelete();
});
}
public function down(): void
{
Schema::table('navigation_items', function (Blueprint $table) {
$table->dropConstrainedForeignId('parent_id');
});
}
};
+48 -626
View File
@@ -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;
}
+145
View File
@@ -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;
}
}
+288
View File
@@ -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;
}
+163
View File
@@ -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);
}
+416
View File
@@ -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;
}
+168
View File
@@ -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);
}
+331
View File
@@ -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);
}
+1
View File
@@ -1,4 +1,5 @@
import Hls from 'hls.js';
import './site-nav.js';
function attachPlayback(video) {
if (!(video instanceof HTMLVideoElement) || video.dataset.playbackReady === '1') {
+137
View File
@@ -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);
});
@@ -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])
<div {{ $attributes->class(['wordmark', 'wordmark-compact' => $compact]) }}>
<a href="{{ route('home') }}"><strong>Lara &amp; Felix</strong></a>
<span>Stark im Alltag</span>
</div>
@props(['href' => null, 'claim' => 'Stark im Alltag'])
<a {{ $attributes->class(['brand']) }} href="{{ $href ?? route('home') }}" data-brand-status="vorlaeufig">
<span class="brand-name">Lara &amp; Felix</span>
<span class="brand-claim">{{ $claim }}</span>
</a>
@@ -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')))
<a class="site-icon-link" href="{{ config('cms.cart.url') }}">
<x-heroicon-o-shopping-bag aria-hidden="true" />
<span class="site-account-label">Warenkorb</span>
</a>
@endif
@@ -1,13 +1,33 @@
@props(['navigation'])
<footer class="site-footer">
<div class="site-footer-inner">
<x-site.brand compact />
<nav aria-label="Rechtliches und Service">
@foreach ($navigation->where('placement', 'footer') as $item)
@if ($item->href())
<a href="{{ $item->href() }}">{{ $item->label }}</a>
@endif
@endforeach
</nav>
@props(['navigation', 'path' => null])
@php
$groups = \App\Domain\Cms\SiteNavigation::forPath($navigation, $path ?? request()->path())->footerGroups();
$themes = \App\Domain\Catalog\Pillar::query()->published()->get(['id', 'name', 'slug']);
@endphp
{{-- Fußbereich: Links aus der CMS-Navigation (Plätze „Fußbereich: …“) und die veröffentlichten Themenbereiche. Keine erfundenen Kontakt- oder Rechtstexte. --}}
<footer class="site-footer scope-dark">
<div class="site-footer-inner ui-container">
<div class="site-footer-brand">
<x-site.brand />
</div>
@if ($themes->isNotEmpty())
<nav aria-labelledby="fuss-themen">
<h2 id="fuss-themen">Themenbereiche</h2>
<ul>
@foreach ($themes as $theme)
<li><a href="{{ $theme->publicUrl() }}">{{ $theme->name }}</a></li>
@endforeach
</ul>
</nav>
@endif
@foreach ($groups as $group)
<nav aria-labelledby="fuss-{{ $group['key'] }}">
<h2 id="fuss-{{ $group['key'] }}">{{ $group['heading'] }}</h2>
<ul>
@foreach ($group['links'] as $link)
<li><a href="{{ $link['href'] }}" @if ($link['current']) aria-current="page" @endif>{{ $link['label'] }}</a></li>
@endforeach
</ul>
</nav>
@endforeach
</div>
</footer>
@@ -1,18 +1,46 @@
@props(['navigation', 'page' => null])
<header class="masthead">
<div class="masthead-inner">
@props(['navigation', 'path' => null])
@php
$entries = \App\Domain\Cms\SiteNavigation::forPath($navigation, $path ?? request()->path())->header();
@endphp
{{-- Gleiche Ausgabe für Gäste und Mitglieder (ADR-32): Der Kontozugang führt zum Mitgliederbereich, der bei Bedarf zur Anmeldung leitet. --}}
<header class="site-header" data-site-header>
<div class="site-header-inner ui-container ui-container-wide">
<x-site.brand />
<nav class="site-nav" aria-label="Hauptnavigation">
@foreach ($navigation->where('placement', 'header') as $item)
@if ($item->href())
<a href="{{ $item->href() }}" @if($page !== null && $item->page_id === $page->id) aria-current="page" @endif>{{ $item->label }}</a>
@endif
@endforeach
@auth('web')
<a href="{{ route('member.dashboard') }}">Mitgliederbereich</a>
@else
<a href="{{ route('register') }}">Registrieren</a>
@endauth
<nav class="site-nav" id="site-nav" aria-label="Hauptnavigation">
<ul class="site-nav-list">
@foreach ($entries as $entry)
<li @class(['site-nav-item', 'has-children' => $entry['children'] !== [], 'is-active-trail' => $entry['activeTrail']])>
@if ($entry['href'])
<a href="{{ $entry['href'] }}" @if ($entry['current']) aria-current="page" @endif>{{ $entry['label'] }}</a>
@else
<a href="#untermenue-{{ $entry['id'] }}" data-site-subnav-label>{{ $entry['label'] }}</a>
@endif
@if ($entry['children'] !== [])
<button type="button" class="site-nav-toggle" aria-expanded="false" aria-controls="untermenue-{{ $entry['id'] }}" data-site-subnav-toggle>
<x-heroicon-o-chevron-down aria-hidden="true" />
<span class="visually-hidden">Untermenü {{ $entry['label'] }}</span>
</button>
<ul class="site-subnav" id="untermenue-{{ $entry['id'] }}">
@foreach ($entry['children'] as $child)
<li><a href="{{ $child['href'] }}" @if ($child['current']) aria-current="page" @endif>{{ $child['label'] }}</a></li>
@endforeach
</ul>
@endif
</li>
@endforeach
</ul>
</nav>
<div class="site-header-actions">
<a class="site-icon-link" href="{{ route('member.dashboard') }}">
<x-heroicon-o-user-circle aria-hidden="true" />
<span class="site-account-label">Mitgliederbereich</span>
</a>
<x-site.cart-link />
<button type="button" class="site-menu-button" aria-expanded="false" aria-controls="site-nav" data-site-menu-button>
<x-heroicon-o-bars-3 aria-hidden="true" data-icon-open />
<x-heroicon-o-x-mark aria-hidden="true" data-icon-close hidden />
<span data-menu-label>Menü</span>
</button>
</div>
</div>
</header>
+62 -1
View File
@@ -1,9 +1,70 @@
<style>
/* Widget-Auswahl */
.luf-widget-pick { display: flex; gap: .75rem; align-items: flex-start; text-align: start; white-space: normal; }
.luf-widget-pick-schematic { flex: none; border: 1px solid rgb(0 0 0 / 12%); border-radius: 3px; }
.luf-widget-pick-text { display: flex; flex-direction: column; gap: .15rem; }
.luf-widget-pick-name { font-weight: 600; }
.luf-widget-pick-desc { font-size: .8rem; line-height: 1.3; opacity: .8; }
.luf-widget-preview-frame { display: block; width: 100%; min-height: 4rem; border: 0; pointer-events: none; background: #f7faf8; }
.luf-widget-pick-units { font-size: .75rem; line-height: 1.3; opacity: .7; font-style: italic; }
/* Widget-Vorschau: kompakt, ohne eigene Bildlaufleiste; lange Inhalte werden gekürzt angezeigt. */
.luf-widget-preview { position: relative; }
.luf-widget-preview-frame { display: block; width: 100%; min-height: 3rem; max-height: 22rem; border: 0; overflow: hidden; pointer-events: none; background: #fff; }
.luf-widget-preview.is-clipped::after {
content: 'Vorschau gekürzt – vollständig in der Seitenvorschau';
position: absolute; inset: auto 0 0 0; padding: 2.5rem .75rem .5rem;
font-size: .75rem; font-weight: 600; text-align: center; color: #15243a;
background: linear-gradient(to bottom, rgb(255 255 255 / 0), rgb(255 255 255 / .96) 55%);
}
.luf-widget-preview-empty { margin: 0; padding: 1rem; font-size: .875rem; opacity: .75; }
/* Abschnitte: breite Arbeitsfläche, deutlich abgesetzte Abschnitte */
.luf-sections > .fi-fo-repeater-items { gap: 1.25rem; }
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item { border-left: 4px solid rgb(3 37 81 / 70%); }
.luf-sections .fi-fo-repeater-item-header-label { font-weight: 600; white-space: normal; }
/* Rasterauswahl als grafische Kacheln */
.luf-layout-picker .fi-btn-group { flex-wrap: wrap; gap: .5rem; }
.luf-layout-picker .fi-btn { min-height: 3.25rem; padding: .35rem .6rem; border-radius: .5rem !important; }
.luf-layout-option { display: inline-flex; align-items: center; gap: .5rem; }
.luf-layout-schematic { fill: currentColor; opacity: .55; }
.luf-layout-picker .fi-btn[aria-pressed='true'] .luf-layout-schematic,
.luf-layout-picker input:checked + label .luf-layout-schematic { opacity: 1; }
.luf-layout-option-text { font-variant-numeric: tabular-nums; font-weight: 600; }
/* Plätze im Verhältnis des Desktop-Rasters; auf schmalen Bildschirmen untereinander. */
.luf-slots > .fi-fo-repeater-items { display: grid; gap: .75rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 64rem) {
.luf-slots > .fi-fo-repeater-items { grid-template-columns: var(--luf-slot-cols, minmax(0, 1fr)); }
}
.luf-slots .fi-fo-repeater-item { background: rgb(247 246 242 / 60%); border-style: dashed; }
.luf-slots .fi-fo-repeater-item-header { padding-block: .4rem; }
.luf-slots .fi-fo-repeater-item-header-label { font-size: .8rem; font-weight: 600; }
.luf-slots .fi-fo-builder-add-action-ctn,
.luf-slots .fi-fo-builder .fi-fo-builder-add-btn-ctn { justify-content: center; }
/* Aktionen gut sichtbar und mit ausreichender Trefferfläche */
.luf-sections .fi-fo-repeater-item-header .fi-icon-btn,
.luf-sections .fi-fo-builder-item-header .fi-icon-btn { min-width: 2.25rem; min-height: 2.25rem; opacity: 1; }
.luf-sections .fi-fo-builder-item-header { flex-wrap: wrap; }
</style>
<script>
// Vorschau-Iframes an ihren Inhalt anpassen (nach Bildern und Schriften erneut), Höhe begrenzen.
window.lufFitPreview = window.lufFitPreview || function (frame) {
const max = 352;
const fit = () => {
const doc = frame.contentDocument;
if (!doc || !doc.documentElement) return;
const height = doc.documentElement.scrollHeight;
frame.style.height = Math.min(height, max) + 'px';
frame.parentElement?.classList.toggle('is-clipped', height > max + 4);
};
fit();
try {
const doc = frame.contentDocument;
doc.fonts?.ready.then(fit);
doc.querySelectorAll('img').forEach((img) => img.complete || img.addEventListener('load', fit, { once: true }));
if (window.ResizeObserver) new ResizeObserver(fit).observe(doc.body);
} catch (error) {}
};
</script>
@@ -1,22 +1,25 @@
{{--
Blockvorschau im Seiteneditor. Das Widget wird mit derselben Ansicht wie auf der öffentlichen Seite gerendert
und in einem eigenen Dokument angezeigt, damit Website- und Verwaltungsstile sich nicht überlagern.
Widget-Vorschau im Seiteneditor. Das Widget wird mit derselben Ansicht wie auf der öffentlichen Seite gerendert
und in einem eigenen Dokument angezeigt, damit Website- und Verwaltungsstile sich nicht überlagern. Das Dokument
hat die Breite des Platzes; Container-Abfragen der Widgets greifen dadurch wie auf der Website.
--}}
@php
$document = '<!DOCTYPE html><html lang="de"><head><meta charset="utf-8"><base target="_blank">'
.$stylesheets
.'<style>html{background:var(--color-sheet,#f7faf8)}body{margin:0;padding:1.25rem 1.5rem;min-height:0}main{display:block}</style>'
.'</head><body><main class="sheet-preview">'.$html.'</main></body></html>';
.'<style>html,body{background:#fff;overflow:hidden}body{margin:0;padding:1rem 1.25rem;min-height:0}main{display:block}</style>'
.'</head><body><main class="sheet-preview"><div class="section-slot">'.$html.'</div></main></body></html>';
@endphp
@if (trim($html) === '')
<p class="luf-widget-preview-empty">Dieser Abschnitt zeigt öffentlich nichts an. Bitte Inhalte ergänzen.</p>
<p class="luf-widget-preview-empty">Dieses Widget zeigt öffentlich nichts an. Bitte Inhalte ergänzen.</p>
@else
<iframe
class="luf-widget-preview-frame"
title="Vorschau des Abschnitts"
tabindex="-1"
srcdoc="{{ $document }}"
loading="lazy"
onload="this.style.height = (this.contentDocument?.documentElement?.scrollHeight ?? 200) + 'px'"
></iframe>
<div class="luf-widget-preview">
<iframe
class="luf-widget-preview-frame"
title="Vorschau des Widgets"
tabindex="-1"
scrolling="no"
srcdoc="{{ $document }}"
onload="window.lufFitPreview && window.lufFitPreview(this)"
></iframe>
</div>
@endif
+3 -8
View File
@@ -4,6 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>@yield('title', 'Mitgliederbereich')</title>
<script>document.documentElement.classList.add('js');</script>
@fonts
@vite(['resources/css/app.css', 'resources/js/app.js'])
</head>
@@ -11,10 +12,7 @@
<a class="skip" href="#inhalt">Zum Inhalt</a>
<div class="member-shell">
<aside class="member-side">
<a class="member-mark" href="{{ route('member.dashboard') }}">
<strong>Lara &amp; Felix</strong>
<span>Mitgliederbereich</span>
</a>
<x-site.brand class="member-mark" :href="route('member.dashboard')" claim="Mitgliederbereich" />
@include('member.partials.nav')
<form class="member-logout" method="post" action="{{ route('logout') }}">
@csrf
@@ -23,10 +21,7 @@
</aside>
<div class="member-main">
<header class="member-top">
<a class="member-mark member-mark-compact" href="{{ route('member.dashboard') }}">
<strong>Lara &amp; Felix</strong>
<span>Mitgliederbereich</span>
</a>
<x-site.brand class="member-mark member-mark-compact" :href="route('member.dashboard')" claim="Mitgliederbereich" />
<nav class="member-quick" aria-label="Konto">
<a href="{{ route('member.offers') }}">Angebote</a>
<a href="{{ route('member.profile') }}">Profil</a>
+5 -3
View File
@@ -10,18 +10,20 @@
@hasSection('canonical')
<link rel="canonical" href="@yield('canonical')">
@endif
@stack('head')
<script>document.documentElement.classList.add('js');</script>
@fonts
@vite(['resources/css/app.css', 'resources/js/app.js'])
</head>
<body>
<a class="skip" href="#inhalt">Zum Inhalt</a>
<x-site.header :navigation="$navigation ?? collect()" :page="$page ?? null" />
<main id="inhalt" class="sheet">
<x-site.header :navigation="$navigation ?? collect()" :path="$activePath ?? null" />
<main id="inhalt" class="@yield('main_class', 'sheet')">
@if (session('status'))
<p class="status" role="status">{{ session('status') }}</p>
@endif
@yield('content')
</main>
<x-site.footer :navigation="$navigation ?? collect()" />
<x-site.footer :navigation="$navigation ?? collect()" :path="$activePath ?? null" />
</body>
</html>
+7
View File
@@ -3,6 +3,13 @@
@section('title', $documentTitle)
@section('description', $documentDescription ?? '')
@section('canonical', $page->publicUrl())
@section('main_class', 'site-main page-sections')
@push('head')
@if ($preview)
<meta name="robots" content="noindex, nofollow">
@endif
@endpush
@section('content')
@if ($preview)
@@ -1,10 +1,12 @@
{{-- Seitenvorlage „standard“: Widgets in voller Inhaltsbreite untereinander. --}}
<div class="page-template page-template-standard">
{{ $content }}
@if ($page->path === '/' && $themes->isNotEmpty())
<section class="block">
<h2>Themenbereiche</h2>
@include('public.themes.list', ['themes' => $themes])
</section>
@endif
</div>
{{-- Seitenvorlage „standard“: Abschnitte untereinander; jeder Abschnitt bestimmt Raster, Fläche und Breite selbst. --}}
{{ $content }}
@if ($page->path === '/' && $themes->isNotEmpty())
<div class="page-section section-bg-default section-width-standard section-space-normal">
<div class="page-section-inner">
<section class="block">
<h2>Themenbereiche</h2>
@include('public.themes.list', ['themes' => $themes])
</section>
</div>
</div>
@endif
@@ -4,6 +4,6 @@
<p>{{ $data['text'] }}</p>
@endif
@if (\App\Domain\Cms\Widgets\Support\SafeUrl::isSafe($data['url'] ?? null))
<a href="{{ $data['url'] }}">{{ $data['label'] ?? '' }}</a>
<a class="button" href="{{ $data['url'] }}">{{ $data['label'] ?? '' }}</a>
@endif
</div>
+221 -42
View File
@@ -8,6 +8,7 @@
use App\Filament\Resources\NavigationItems\Pages\ManageNavigationItems;
use App\Filament\Resources\Pages\Pages\CreatePage;
use App\Filament\Resources\Pages\Pages\EditPage;
use App\Filament\Resources\Pages\Pages\ListPages;
use App\Filament\Support\WidgetEditor;
use App\Models\User;
use Filament\Actions\Testing\TestAction;
@@ -19,6 +20,11 @@
use Tests\Support\BuildsCatalog;
use Tests\TestCase;
/**
* Seiteneditor mit Abschnitten und Plätzen. Der Formularzustand ist seit dem Abschnittsraster
* {sections: {uuid: {id, layout, style, slots: {uuid: {widget: {uuid: Builder-Eintrag}}}}}}
* statt einer flachen Bausteinliste; die Prüfungen der ersten Iteration gelten unverändert für die Widgets darin.
*/
class CmsEditorTest extends TestCase
{
use BuildsCatalog;
@@ -31,35 +37,48 @@ protected function setUp(): void
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
}
public function test_editor_creates_a_page_from_registered_widgets_without_publishing_it(): void
public function test_editor_creates_a_page_with_sections_and_registered_widgets_without_publishing_it(): void
{
$program = $this->composition('Programm Abstand', 'programm');
$editor = $this->editor();
Livewire::actingAs($editor, 'staff')
Livewire::actingAs($this->editor(), 'staff')
->test(CreatePage::class)
->fillForm([
'path' => '/themen-test',
'seo_title' => 'Themenseite',
'blocks' => $this->keyed([
['type' => 'hero', 'data' => ['variant' => 'highlight', 'data' => ['heading' => 'Stark im Alltag', 'text' => 'Einstieg']]],
['type' => 'image_text', 'data' => ['variant' => 'image_right', 'data' => ['title' => 'Worum es geht', 'body' => '<p>Text mit <strong>Betonung</strong></p>'], 'refs' => []]],
['type' => 'cards', 'data' => ['variant' => 'compact', 'data' => ['items' => $this->keyed([['title' => 'Prävention', 'url' => '/praevention']])]]],
['type' => 'catalog_cards', 'data' => ['variant' => 'standard', 'data' => ['heading' => 'Programme'], 'refs' => ['items' => $this->keyed([['type' => 'composition', 'id' => $program->composition_id]])]]],
]),
'sections' => [
$this->sectionState('u4', [
['type' => 'hero', 'data' => ['variant' => 'highlight', 'data' => ['heading' => 'Stark im Alltag', 'text' => 'Einstieg']]],
], ['background' => 'dark', 'divider' => 'accent']),
$this->sectionState('u1_3', [
['type' => 'cards', 'data' => ['variant' => 'compact', 'data' => ['items' => $this->keyed([['title' => 'Prävention', 'url' => '/praevention']])]]],
['type' => 'image_text', 'data' => ['variant' => 'image_right', 'data' => ['title' => 'Worum es geht', 'body' => '<p>Text mit <strong>Betonung</strong></p>'], 'refs' => []]],
], ['width' => 'wide']),
$this->sectionState('u2_2', [
['type' => 'catalog_cards', 'data' => ['variant' => 'standard', 'data' => ['heading' => 'Programme'], 'refs' => ['items' => $this->keyed([['type' => 'composition', 'id' => $program->composition_id]])]]],
null,
]),
],
])
->call('create')
->assertHasNoFormErrors();
$page = Page::query()->where('path', '/themen-test')->firstOrFail();
$blocks = $page->latestRevision->blocks;
$revision = $page->latestRevision;
$sections = $revision->sections;
$blocks = $revision->blocks;
$this->assertNull($page->published_revision_id);
$this->assertSame(['hero', 'image_text', 'cards', 'catalog_cards'], array_column($blocks, 'type'));
$this->assertSame(['highlight', 'image_right', 'compact', 'standard'], array_column($blocks, 'variant'));
$this->assertSame([2], array_values(array_unique([$blocks[1]['v']])));
$this->assertStringContainsString('<strong>Betonung</strong>', $blocks[1]['data']['body']);
$this->assertSame([['title' => 'Prävention', 'text' => null, 'url' => '/praevention', 'image' => null]], $blocks[2]['data']['items']);
$this->assertSame(['u4', 'u1_3', 'u2_2'], array_column($sections, 'layout'));
$this->assertSame('dark', $sections[0]['style']['background']);
$this->assertSame('accent', $sections[0]['style']['divider']);
$this->assertSame('wide', $sections[1]['style']['width']);
$this->assertNull($sections[2]['slots'][1], 'Ein leerer Platz bleibt als Platz erhalten.');
$this->assertSame(['hero', 'cards', 'image_text', 'catalog_cards'], array_column($blocks, 'type'), 'Die Rollback-Spalte enthält alle Widgets in Lesereihenfolge.');
$this->assertSame(['highlight', 'compact', 'image_right', 'standard'], array_column($blocks, 'variant'));
$this->assertSame(2, $blocks[2]['v']);
$this->assertStringContainsString('<strong>Betonung</strong>', $blocks[2]['data']['body']);
$this->assertSame([['title' => 'Prävention', 'text' => null, 'url' => '/praevention', 'image' => null]], $blocks[1]['data']['items']);
$this->assertSame([['type' => 'composition', 'id' => $program->composition_id]], $blocks[3]['refs']['items']);
$this->get('/themen-test')->assertNotFound();
}
@@ -73,8 +92,8 @@ public function test_existing_page_opens_in_the_editor_and_saves_without_changin
$component = Livewire::actingAs($this->editor(), 'staff')
->test(EditPage::class, ['record' => $page->id]);
$state = $component->get('data.blocks');
$this->assertSame(['heading', 'prose', 'cards', 'call_to_action'], array_column(array_values($state), 'type'));
$this->assertSame(['heading', 'prose', 'cards', 'call_to_action'], $this->widgetTypes($component->get('data.sections')));
$this->assertSame(['u4', 'u4', 'u4', 'u4'], array_column(array_values($component->get('data.sections')), 'layout'), 'Bestand wird als einspaltige Abschnitte geöffnet.');
$component->call('save')->assertHasNoFormErrors();
@@ -82,6 +101,7 @@ public function test_existing_page_opens_in_the_editor_and_saves_without_changin
$this->assertSame($live, $page->published_revision_id);
$this->assertNotSame($live, $page->latestRevision->id);
$this->assertSame(['heading', 'prose', 'cards', 'call_to_action'], array_column($page->latestRevision->blocks, 'type'));
$this->assertCount(4, $page->latestRevision->sections);
$this->assertSame($before, $this->mainText($this->get('/')->getContent()));
Livewire::actingAs($this->editor(), 'staff')
@@ -100,17 +120,76 @@ public function test_editor_reorders_and_duplicates_sections(): void
$page = Page::query()->where('path', '/')->firstOrFail();
$component = Livewire::actingAs($this->editor(), 'staff')->test(EditPage::class, ['record' => $page->id]);
$state = $component->get('data.blocks');
$state = $component->get('data.sections');
$keys = array_keys($state);
$reordered = [$keys[3] => $state[$keys[3]], $keys[0] => $state[$keys[0]], $keys[1] => $state[$keys[1]], $keys[2] => $state[$keys[2]]];
$copy = $state[$keys[1]];
$reordered[(string) Str::uuid()] = $copy;
$reordered[(string) Str::uuid()] = $state[$keys[1]];
$component->set('data.blocks', $reordered)->call('save')->assertHasNoFormErrors();
$component->set('data.sections', $reordered)->call('save')->assertHasNoFormErrors();
$blocks = $page->fresh()->latestRevision->blocks;
$this->assertSame(['call_to_action', 'heading', 'prose', 'cards', 'prose'], array_column($blocks, 'type'));
$this->assertCount(5, array_unique(array_column($blocks, 'id')), 'Ein dupliziertes Widget erhält eine eigene Kennung.');
$revision = $page->fresh()->latestRevision;
$this->assertSame(['call_to_action', 'heading', 'prose', 'cards', 'prose'], array_column($revision->blocks, 'type'));
$this->assertCount(5, array_unique(array_column($revision->blocks, 'id')), 'Ein dupliziertes Widget erhält eine eigene Kennung.');
$this->assertCount(5, array_unique(array_column($revision->sections, 'id')), 'Ein duplizierter Abschnitt erhält eine eigene Kennung.');
}
public function test_layout_change_keeps_widgets_and_rejects_layouts_with_too_few_slots(): void
{
$page = Page::query()->where('path', '/')->firstOrFail();
$component = Livewire::actingAs($this->editor(), 'staff')->test(EditPage::class, ['record' => $page->id]);
$state = $component->get('data.sections');
$keys = array_keys($state);
// Raster wechseln: fehlende Plätze entstehen, das vorhandene Widget bleibt im ersten Platz.
$component->set("data.sections.{$keys[0]}.layout", 'u1_1_1_1');
$slots = $component->get("data.sections.{$keys[0]}.slots");
$this->assertCount(4, $slots);
$this->assertSame(['heading'], $this->widgetTypes([['slots' => $slots]]));
// Zweites Widget in Platz 2 setzen und auf zwei Plätze wechseln: leere Plätze entfallen, Widgets bleiben.
$slotKeys = array_keys($slots);
$secondWidget = $state[$keys[1]]['slots'][array_key_first($state[$keys[1]]['slots'])]['widget'];
$component->set("data.sections.{$keys[0]}.slots.{$slotKeys[1]}.widget", $secondWidget);
$component->set("data.sections.{$keys[0]}.layout", 'u2_2');
$this->assertCount(2, $component->get("data.sections.{$keys[0]}.slots"));
$this->assertSame(['heading', 'prose'], $this->widgetTypes([['slots' => $component->get("data.sections.{$keys[0]}.slots")]]));
// Ein Raster mit nur einem Platz ist gesperrt, solange zwei Widgets eingesetzt sind; kein Widget geht verloren.
$component->set("data.sections.{$keys[0]}.layout", 'u4');
$this->assertCount(2, $component->get("data.sections.{$keys[0]}.slots"));
$component->call('save')->assertHasErrors(["data.sections.{$keys[0]}.layout"]);
$component->set("data.sections.{$keys[0]}.layout", 'u2_2');
$remaining = $component->get('data.sections');
unset($remaining[$keys[1]]);
$component->set('data.sections', $remaining)->call('save')->assertHasNoFormErrors();
$sections = $page->fresh()->latestRevision->sections;
$this->assertCount(3, $sections);
$this->assertSame('u2_2', $sections[0]['layout']);
$this->assertSame(['heading', 'prose'], array_column($sections[0]['slots'], 'type'));
}
public function test_widget_too_wide_for_its_slot_is_reported_at_the_section(): void
{
$component = Livewire::actingAs($this->editor(), 'staff')
->test(CreatePage::class)
->fillForm([
'path' => '/raster-pruefung',
'sections' => [
$this->sectionState('u1_3', [
['type' => 'hero', 'data' => ['variant' => 'standard', 'data' => ['heading' => 'Zu schmal']]],
null,
], ['background' => 'accent', 'spacing' => 'large', 'divider' => 'line']),
],
])
->call('create')
->assertNotified('Nicht gespeichert');
$key = array_key_first($component->get('data.sections'));
$component->assertHasErrors(["data.sections.$key.slots"]);
$this->assertNull(Page::query()->where('path', '/raster-pruefung')->first());
}
public function test_unsafe_link_is_reported_at_the_section_and_nothing_is_saved(): void
@@ -119,11 +198,17 @@ public function test_unsafe_link_is_reported_at_the_section_and_nothing_is_saved
$revisions = $page->revisions()->count();
$component = Livewire::actingAs($this->editor(), 'staff')->test(EditPage::class, ['record' => $page->id]);
$key = array_keys($component->get('data.blocks'))[3];
$sectionKey = array_keys($component->get('data.sections'))[3];
$slotKey = array_key_first($component->get("data.sections.$sectionKey.slots"));
$widgetKey = array_key_first($component->get("data.sections.$sectionKey.slots.$slotKey.widget"));
$component->set("data.blocks.$key.data.data.url", 'javascript:alert(1)')
$component->set("data.sections.$sectionKey.slots.$slotKey.widget.$widgetKey.data.data.url", 'javascript:alert(1)')
->call('save')
->assertHasErrors(["data.blocks.$key.data.data.url"]);
->assertHasErrors([
"data.sections.$sectionKey.slots.$slotKey.widget.$widgetKey.data.data.url",
"data.sections.$sectionKey.slots",
])
->assertNotified('Nicht gespeichert');
$this->assertSame($revisions, $page->revisions()->count());
}
@@ -136,23 +221,74 @@ public function test_errors_found_only_by_the_registry_are_announced_with_the_se
$page = Page::query()->where('path', '/')->firstOrFail();
$revisions = $page->revisions()->count();
$component = Livewire::actingAs($this->editor(), 'staff')->test(EditPage::class, ['record' => $page->id]);
$state = $component->get('data.blocks');
$state[(string) Str::uuid()] = ['type' => 'hero', 'data' => ['variant' => 'standard', 'data' => ['heading' => 'Mit Bild'], 'refs' => ['image' => 'cms/bild.jpg']]];
$state = $component->get('data.sections');
$state[(string) Str::uuid()] = $this->sectionState('u4', [
['type' => 'hero', 'data' => ['variant' => 'standard', 'data' => ['heading' => 'Mit Bild'], 'refs' => ['image' => 'cms/bild.jpg']]],
]);
$component->set('data.blocks', $state)
$component->set('data.sections', $state)
->call('save')
->assertNotified('Nicht gespeichert');
$this->assertSame($revisions, $page->revisions()->count());
}
public function test_section_background_image_is_saved_and_published_from_the_public_area(): void
{
Storage::fake('media_public');
Storage::fake('cms_incoming');
Storage::disk('media_public')->put('cms/flaeche.jpg', 'bild');
Livewire::actingAs($this->editor(), 'staff')
->test(CreatePage::class)
->fillForm([
'path' => '/flaechen',
'sections' => [
$this->sectionState('u2_2', [
['type' => 'heading', 'data' => ['variant' => 'standard', 'data' => ['heading' => 'Auf Bild']]],
['type' => 'prose', 'data' => ['variant' => 'standard', 'data' => ['body' => 'Text']]],
], ['background' => 'image', 'image' => 'cms/flaeche.jpg', 'focus' => 'top', 'overlay' => 'dark']),
],
])
->call('create')
->assertHasNoFormErrors();
$style = Page::query()->where('path', '/flaechen')->firstOrFail()->latestRevision->sections[0]['style'];
$this->assertSame(['background' => 'image', 'image' => 'cms/flaeche.jpg', 'focus' => 'top', 'overlay' => 'dark'], array_intersect_key($style, array_flip(['background', 'image', 'focus', 'overlay'])));
}
public function test_page_can_be_duplicated_as_an_unpublished_draft_without_changing_the_source(): void
{
$source = Page::query()->where('path', '/praevention')->firstOrFail();
$sourceRevision = $source->latestRevision->id;
$editor = $this->editor();
Livewire::actingAs($editor, 'staff')
->test(ListPages::class)
->callAction(TestAction::make('duplicate')->table($source), ['path' => '/praevention'])
->assertHasActionErrors(['path']);
Livewire::actingAs($editor, 'staff')
->test(ListPages::class)
->callAction(TestAction::make('duplicate')->table($source), ['path' => '/neue-landingpage'])
->assertHasNoActionErrors();
$copy = Page::query()->where('path', '/neue-landingpage')->firstOrFail();
$this->assertNull($copy->published_revision_id);
$this->assertSame(
array_column($source->latestRevision->widgets(), 'type'),
array_column($copy->latestRevision->widgets(), 'type'),
);
$this->assertSame($sourceRevision, $source->fresh()->latestRevision->id, 'Die Vorlage bleibt unverändert.');
}
public function test_new_page_keeps_the_selected_pillars(): void
{
$pillar = app(PillarService::class)->create('Grenzen');
Livewire::actingAs($this->editor(), 'staff')
->test(CreatePage::class)
->fillForm(['path' => '/grenzen-thema', 'pillars' => [$pillar->id], 'blocks' => []])
->fillForm(['path' => '/grenzen-thema', 'pillars' => [$pillar->id], 'sections' => []])
->call('create')
->assertHasNoFormErrors();
@@ -163,29 +299,30 @@ public function test_duplicated_section_keeps_its_new_id_across_saves(): void
{
$page = Page::query()->where('path', '/')->firstOrFail();
$component = Livewire::actingAs($this->editor(), 'staff')->test(EditPage::class, ['record' => $page->id]);
$state = $component->get('data.blocks');
$state = $component->get('data.sections');
$state[(string) Str::uuid()] = $state[array_key_first($state)];
$component->set('data.blocks', $state)->call('save')->assertHasNoFormErrors();
$component->set('data.sections', $state)->call('save')->assertHasNoFormErrors();
$first = array_column($page->fresh()->latestRevision->blocks, 'id');
$firstSections = array_column($page->fresh()->latestRevision->sections, 'id');
$component->call('save')->assertHasNoFormErrors();
$second = array_column($page->fresh()->latestRevision->blocks, 'id');
$this->assertCount(5, array_unique($first));
$this->assertSame($first, $second);
$this->assertSame($first, array_column($page->fresh()->latestRevision->blocks, 'id'));
$this->assertSame($firstSections, array_column($page->fresh()->latestRevision->sections, 'id'));
}
public function test_invalid_or_taken_paths_are_shown_at_the_path_field(): void
{
Livewire::actingAs($this->editor(), 'staff')
->test(CreatePage::class)
->fillForm(['path' => '/praevention', 'blocks' => []])
->fillForm(['path' => '/praevention', 'sections' => []])
->call('create')
->assertHasErrors(['data.path']);
Livewire::actingAs($this->editor(), 'staff')
->test(CreatePage::class)
->fillForm(['path' => 'C:/Program Files/x', 'blocks' => []])
->fillForm(['path' => 'C:/Program Files/x', 'sections' => []])
->call('create')
->assertHasErrors(['data.path']);
@@ -215,15 +352,21 @@ public function test_block_preview_uses_the_public_widget_view_with_unsaved_stat
$this->assertStringContainsString('Karte B', $cards);
}
public function test_editor_offers_every_registered_widget_with_description(): void
public function test_editor_offers_every_registered_widget_layouts_and_section_design(): void
{
$page = Page::query()->where('path', '/')->firstOrFail();
$component = Livewire::actingAs($this->editor(), 'staff')->test(EditPage::class, ['record' => $page->id]);
$first = array_key_first($component->get('data.sections'));
Livewire::actingAs($this->editor(), 'staff')
->test(EditPage::class, ['record' => $page->id])
// Die Widget-Auswahl erscheint an jedem freien Platz.
$component->set("data.sections.$first.layout", 'u2_2')
->assertSee('Einstieg (Hero)')
->assertSee('Programm- und Modulkarten')
->assertSee('Titel und Beschreibung kommen automatisch aus den Fachdaten')
->assertSee('Braucht einen Platz ab 2 Rastereinheiten')
->assertSee('Gestaltung des Abschnitts')
->assertSee('1 + 2 + 1')
->assertSee('Widget einsetzen')
->assertSee('Entwurf speichern');
}
@@ -248,8 +391,9 @@ public function test_preview_with_device_widths_is_only_available_to_staff(): vo
->get(route('pages.preview', $revision))
->assertOk()
->assertSee('Vorschau einer unveröffentlichten Revision')
->assertSee('Registrieren')
->assertDontSee('Mitgliederbereich</a>', false);
->assertSee('<meta name="robots" content="noindex, nofollow">', false)
->assertSee('class="site-header"', false)
->assertSee('class="site-footer scope-dark"', false);
}
public function test_navigation_items_can_be_edited_hidden_reordered_and_removed(): void
@@ -299,6 +443,41 @@ private function editor(): User
return $editor;
}
/**
* Formularzustand eines Abschnitts; null steht für einen leeren Platz.
*
* @param list<array<string, mixed>|null> $widgets
* @param array<string, mixed> $style
* @return array<string, mixed>
*/
private function sectionState(string $layout, array $widgets, array $style = []): array
{
$slots = [];
foreach ($widgets as $widget) {
$slots[(string) Str::uuid()] = ['widget' => $widget === null ? [] : $this->keyed([$widget])];
}
return ['id' => null, 'layout' => $layout, 'style' => $style, 'slots' => $slots];
}
/**
* @param array<int|string, mixed> $sections
* @return list<string>
*/
private function widgetTypes(array $sections): array
{
$types = [];
foreach ($sections as $section) {
foreach ($section['slots'] ?? [] as $slot) {
foreach ($slot['widget'] ?? [] as $item) {
$types[] = $item['type'];
}
}
}
return $types;
}
/**
* @param list<array<string, mixed>> $items
* @return array<string, array<string, mixed>>
+45
View File
@@ -0,0 +1,45 @@
<?php
namespace Tests\Feature;
use App\Domain\Cms\Page;
use App\Domain\Cms\PageService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Carbon;
use Tests\TestCase;
class CmsRollbackCommandTest extends TestCase
{
use RefreshDatabase;
public function test_published_pages_return_to_their_state_before_a_deployment_only_with_apply(): void
{
$service = app(PageService::class);
$page = Page::query()->where('path', '/praevention')->firstOrFail();
$before = $page->published_revision_id;
Carbon::setTestNow('2030-01-01 12:00:00');
$new = $service->saveRevision($page, [['layout' => 'u2_2', 'style' => [], 'slots' => [
['type' => 'heading', 'v' => 1, 'data' => ['heading' => 'Neu']],
null,
]]], null, null, null);
$service->publish($page, $new);
$created = Page::query()->create(['path' => '/neu-nach-deploy']);
$service->publish($created, $service->saveRevision($created, [['type' => 'heading', 'v' => 1, 'data' => ['heading' => 'Ganz neu']]], null, null, null));
Carbon::setTestNow();
$this->artisan('cms:revert-published', ['--before' => '2030-01-01 11:00'])->assertSuccessful();
$this->assertSame($new->id, $page->fresh()->published_revision_id, 'Ohne --apply ändert sich nichts.');
$this->artisan('cms:revert-published', ['--before' => '2030-01-01 11:00', '--apply' => true])->assertSuccessful();
$this->assertSame($before, $page->fresh()->published_revision_id);
$this->assertNull($created->fresh()->published_revision_id, 'Eine erst danach angelegte Seite wird zurückgezogen.');
$this->assertNotNull($new->fresh(), 'Revisionen bleiben erhalten.');
}
public function test_missing_time_is_rejected(): void
{
$this->artisan('cms:revert-published')->assertFailed();
}
}
+259
View File
@@ -0,0 +1,259 @@
<?php
namespace Tests\Feature;
use App\Domain\Cms\NavigationItem;
use App\Domain\Cms\Page;
use App\Domain\Cms\PageService;
use App\Domain\Cms\Widgets\RenderContext;
use App\Domain\Cms\Widgets\WidgetRenderer;
use App\Jobs\PublishPublicMedia;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Queue;
use Tests\Support\BuildsCatalog;
use Tests\TestCase;
/**
* Öffentliche Darstellung der Abschnitte, globales Website-Gerüst und Rückfallweg.
*/
class CmsSectionRenderingTest extends TestCase
{
use BuildsCatalog;
use RefreshDatabase;
/**
* @return array<string, mixed>
*/
private function heading(string $text): array
{
return ['type' => 'heading', 'v' => 1, 'data' => ['heading' => $text]];
}
/**
* @return array<string, mixed>
*/
private function prose(string $text): array
{
return ['type' => 'prose', 'v' => 1, 'data' => ['body' => $text]];
}
/**
* @param list<array<string, mixed>> $sections
*/
private function publish(string $path, array $sections): Page
{
$service = app(PageService::class);
$page = Page::query()->create(['path' => $path]);
$service->publish($page, $service->saveRevision($page, $sections, null, null, null));
return $page->fresh();
}
public function test_sections_render_grid_ratios_backgrounds_and_dividers(): void
{
$this->publish('/raster', [
['layout' => 'u4', 'style' => ['background' => 'dark', 'divider' => 'accent'], 'slots' => [$this->heading('Einstieg')]],
['layout' => 'u1_3', 'style' => ['background' => 'light', 'width' => 'wide', 'divider' => 'line'], 'slots' => [$this->prose('Schmal'), $this->prose('Breit')]],
['layout' => 'u1_1_1_1', 'style' => ['background' => 'accent', 'spacing' => 'large'], 'slots' => [$this->prose('A'), $this->prose('B'), $this->prose('C'), $this->prose('D')]],
['layout' => 'u2_2', 'style' => ['divider' => 'line'], 'slots' => [$this->prose('Letzter')]],
]);
$html = $this->get('/raster')->assertOk()->getContent();
$this->assertStringContainsString('page-section section-bg-dark section-width-standard section-space-normal section-layout-u4 scope-dark', $html);
$this->assertStringContainsString('section-bg-light section-width-wide', $html);
$this->assertStringContainsString('--section-cols-lg: minmax(0, 1fr) minmax(0, 3fr); --section-cols-md: minmax(0, 1fr)', $html);
$this->assertStringContainsString('--section-cols-md: repeat(2, minmax(0, 1fr))', $html, 'Vier gleiche Plätze stehen auf dem Tablet als 2 × 2.');
$this->assertStringContainsString('section-bg-accent section-width-standard section-space-large section-layout-u1-1-1-1 scope-accent', $html);
$this->assertStringContainsString('section-divider section-divider-accent', $html);
$this->assertSame(1, substr_count($html, 'section-divider section-divider-line'), 'Nach dem letzten Abschnitt steht kein Trenner.');
$this->assertSame(1, substr_count($html, '<h1>'), 'Nur das erste Widget der Seite ist Überschrift erster Ordnung.');
$this->assertLessThan(strpos($html, 'Breit'), strpos($html, 'Schmal'), 'Lese- und Fokusreihenfolge folgt den Plätzen.');
}
public function test_empty_slots_and_empty_sections_leave_no_gaps(): void
{
$this->publish('/luecken', [
['layout' => 'u1_2_1', 'style' => [], 'slots' => [$this->prose('Links'), null, $this->prose('Rechts')]],
['layout' => 'u2_2', 'style' => ['background' => 'dark'], 'slots' => [null, null]],
['layout' => 'u1_3', 'style' => [], 'slots' => [null, $this->prose('Allein')]],
]);
$html = $this->get('/luecken')->assertOk()->getContent();
$this->assertStringContainsString('data-slots="2" style="--section-cols-lg: minmax(0, 1fr) minmax(0, 1fr)', $html, 'Die übrigen Plätze teilen sich die Breite im Verhältnis ihrer Einheiten.');
$this->assertStringContainsString('data-slots="1" style="--section-cols-lg: minmax(0, 1fr)', $html);
$this->assertStringNotContainsString('section-bg-dark', $html, 'Ein Abschnitt ohne Inhalt entfällt samt Fläche.');
}
public function test_background_image_comes_from_the_public_area_with_focus_and_overlay(): void
{
Queue::fake();
$this->publish('/bild', [
['layout' => 'u4', 'style' => ['background' => 'image', 'image' => 'cms/flaeche.jpg', 'focus' => 'top_left', 'overlay' => 'dark'], 'slots' => [$this->heading('Auf Bild')]],
['layout' => 'u4', 'style' => ['background' => 'image', 'image' => 'cms/zweites.jpg', 'overlay' => 'light'], 'slots' => [$this->prose('Hell')]],
]);
$html = $this->get('/bild')->assertOk()->getContent();
$this->assertStringContainsString('section-bg-image', $html);
$this->assertStringContainsString('section-overlay-dark scope-dark', $html);
$this->assertStringContainsString('section-overlay-light scope-light', $html);
$this->assertMatchesRegularExpression('#<img class="page-section-image" src="[^"]*cms/flaeche\.jpg" alt="" loading="eager" fetchpriority="high"[^>]*object-position: 0% 0%#', $html);
$this->assertMatchesRegularExpression('#<img class="page-section-image" src="[^"]*cms/zweites\.jpg" alt="" loading="lazy"#', $html);
Queue::assertPushed(PublishPublicMedia::class, 2);
}
public function test_preview_uses_the_same_renderer_as_the_public_page(): void
{
$page = $this->publish('/gleich', [
['layout' => 'u2_2', 'style' => ['background' => 'light'], 'slots' => [$this->heading('Links'), $this->prose('Rechts')]],
]);
$editor = User::factory()->redakteur()->create();
$public = $this->get('/gleich')->getContent();
$preview = $this->actingAs($editor, 'staff')->get(route('pages.preview', $page->published_revision_id))->getContent();
$this->assertSame($this->sectionsMarkup($public), $this->sectionsMarkup($preview));
$this->assertStringContainsString('Vorschau einer unveröffentlichten Revision', $preview);
}
public function test_public_page_is_identical_for_guests_and_members(): void
{
// Schrift-Vorabladehinweise gibt der Rahmen je Prozess nur einmal aus; sie hängen nicht vom Besucher ab.
$withoutPreload = fn (string $html): string => preg_replace('#<link rel="preload" as="font"[^>]*>\s*#', '', $html);
$guest = $withoutPreload($this->get('/praevention')->assertOk()->getContent());
$member = $withoutPreload($this->actingAs(User::factory()->create())->get('/praevention')->assertOk()->getContent());
$this->assertSame($guest, $member, 'Öffentliche Seiten hängen nicht vom Anmeldestatus ab (ADR-32).');
$this->assertStringContainsString('href="'.route('member.dashboard').'"', $guest);
$this->assertStringContainsString('Mitgliederbereich', $guest);
}
public function test_global_layout_has_header_navigation_mobile_menu_and_footer(): void
{
$html = $this->get('/praevention')->assertOk()->getContent();
$this->assertStringContainsString('<a class="skip" href="#inhalt">', $html);
$this->assertStringContainsString('class="brand" href="'.route('home').'" data-brand-status="vorlaeufig"', $html);
$this->assertStringContainsString('aria-label="Hauptnavigation"', $html);
$this->assertMatchesRegularExpression('#<a href="[^"]*/praevention"\s+aria-current="page"\s*>Prävention</a>#', $html);
$this->assertStringContainsString('data-site-menu-button', $html);
$this->assertStringContainsString('aria-controls="site-nav"', $html);
$this->assertStringContainsString('class="site-footer scope-dark"', $html);
$this->assertStringContainsString('<h2 id="fuss-footer">Service</h2>', $html);
$this->assertStringContainsString('Impressum', $html);
$this->assertStringNotContainsString('Warenkorb', $html, 'Ohne Warenkorb erscheint kein funktionsloser Kaufknopf.');
$this->assertStringNotContainsString('fonts.bunny.net', $html);
$this->assertStringNotContainsString('fonts.googleapis.com', $html);
}
public function test_cart_entry_appears_only_when_enabled(): void
{
config(['cms.cart.enabled' => true, 'cms.cart.url' => '/warenkorb']);
$this->get('/praevention')->assertSee('Warenkorb')->assertSee('href="/warenkorb"', false);
}
public function test_submenus_footer_groups_and_hidden_parents(): void
{
$parent = NavigationItem::query()->where('label', 'Prävention')->firstOrFail();
NavigationItem::query()->create(['label' => 'Grenzen', 'url' => '/themen/grenzen', 'placement' => 'header', 'parent_id' => $parent->id, 'sort_order' => 1]);
NavigationItem::query()->create(['label' => 'Kontaktformular', 'url' => '/kontakt', 'placement' => 'footer_contact', 'sort_order' => 1]);
NavigationItem::query()->create(['label' => 'Fußkind', 'url' => '/x', 'placement' => 'footer', 'parent_id' => $parent->id, 'sort_order' => 2]);
$html = $this->get('/praevention')->getContent();
$this->assertStringContainsString('site-nav-item has-children is-active-trail', $html);
$this->assertStringContainsString('aria-controls="untermenue-'.$parent->id.'"', $html);
$this->assertStringContainsString('Untermenü Prävention', $html);
$this->assertMatchesRegularExpression('#<ul class="site-subnav" id="untermenue-'.$parent->id.'">\s*<li><a href="[^"]*/themen/grenzen"\s*>Grenzen</a></li>#', $html);
$this->assertStringContainsString('<h2 id="fuss-footer_contact">Kontakt</h2>', $html);
$this->assertNull(NavigationItem::query()->where('label', 'Fußkind')->value('parent_id'), 'Untermenüs gibt es nur in der Hauptnavigation.');
$parent->update(['is_visible' => false]);
$this->assertStringNotContainsString('Grenzen', $this->get('/praevention')->getContent(), 'Mit dem Eintrag ist auch sein Untermenü ausgeblendet.');
}
public function test_deleting_a_parent_moves_its_children_to_the_top_level(): void
{
$parent = NavigationItem::query()->where('label', 'Prävention')->firstOrFail();
$child = NavigationItem::query()->create(['label' => 'Grenzen', 'url' => '/themen/grenzen', 'placement' => 'header', 'parent_id' => $parent->id]);
$parent->delete();
$this->assertNull($child->fresh()->parent_id);
$this->get('/ueber')->assertSee('Grenzen');
}
public function test_member_area_uses_the_shared_wordmark_and_tokens(): void
{
$member = User::factory()->create();
$this->actingAs($member)
->get(route('member.dashboard'))
->assertOk()
->assertSee('class="brand member-mark"', false)
->assertSee('<span class="brand-claim">Mitgliederbereich</span>', false)
->assertSee('class="member-dock"', false);
}
public function test_rollback_column_lets_the_previous_renderer_show_every_widget(): void
{
$page = $this->publish('/rueckfall', [
['layout' => 'u1_1_1_1', 'style' => ['background' => 'dark'], 'slots' => [$this->heading('Erstens'), $this->prose('Zweitens'), null, $this->prose('Viertens')]],
]);
// Darstellung wie in der Fassung vor dem Abschnittsraster: flache Liste aus der Spalte blocks.
$html = app(WidgetRenderer::class)->renderAll($page->publishedRevision->blocks, RenderContext::publicPage())->toHtml();
foreach (['Erstens', 'Zweitens', 'Viertens'] as $text) {
$this->assertStringContainsString($text, $html);
}
}
public function test_restore_copies_sections_and_rollback_column_unchanged(): void
{
$page = $this->publish('/wieder', [
['layout' => 'u2_2', 'style' => ['background' => 'light'], 'slots' => [$this->heading('Früher'), $this->prose('Stand')]],
]);
$first = $page->publishedRevision;
$service = app(PageService::class);
$service->publish($page, $service->saveRevision($page, [['layout' => 'u4', 'style' => [], 'slots' => [$this->heading('Später')]]], null, null, null));
$restored = $service->restore($page->fresh(), $first, null);
$service->publish($page->fresh(), $restored);
$this->assertSame($first->sections, $restored->fresh()->sections);
$this->assertSame($first->blocks, $restored->fresh()->blocks);
$this->get('/wieder')->assertSee('Früher')->assertDontSee('Später');
}
public function test_program_reference_in_a_narrow_slot_reads_catalog_data(): void
{
$program = $this->composition('Programm Abstand', 'programm', summary: 'Kurzbeschreibung aus den Fachdaten');
$this->publish('/programme-schmal', [
['layout' => 'u3_1', 'style' => [], 'slots' => [
$this->prose('Hauptinhalt'),
['type' => 'catalog_cards', 'v' => 1, 'variant' => 'compact', 'data' => [], 'refs' => ['items' => [['type' => 'composition', 'id' => $program->composition_id]]]],
]],
]);
$this->get('/programme-schmal')
->assertOk()
->assertSee('Programm Abstand')
->assertSee('catalog-cards catalog-cards-compact', false)
->assertSee('data-units="1"', false);
}
private function sectionsMarkup(string $html): string
{
preg_match('#<main[^>]*>(.*)</main>#s', $html, $match);
$markup = preg_replace('#<p class="preview-banner".*?</p>#s', '', $match[1] ?? '');
return trim(preg_replace('/\s+/', ' ', $markup));
}
}
+262
View File
@@ -0,0 +1,262 @@
<?php
namespace Tests\Unit;
use App\Domain\Cms\Sections\PageSections;
use App\Domain\Cms\Sections\SectionLayouts;
use App\Domain\Cms\Sections\SectionStyle;
use App\Domain\Cms\Widgets\WidgetRegistry;
use App\Filament\Support\SectionEditor;
use Illuminate\Validation\ValidationException;
use Tests\TestCase;
class PageSectionsTest extends TestCase
{
private function sections(): PageSections
{
return app(PageSections::class);
}
/**
* @param list<array<string, mixed>|null> $slots
* @param array<string, mixed> $style
* @return array<string, mixed>
*/
private function section(string $layout, array $slots, array $style = []): array
{
return ['layout' => $layout, 'style' => $style, 'slots' => $slots];
}
/**
* @return array<string, mixed>
*/
private function heading(string $text): array
{
return ['type' => 'heading', 'v' => 1, 'data' => ['heading' => $text]];
}
public function test_required_layouts_exist_with_at_most_four_units(): void
{
$this->assertSame(['u4', 'u2_2', 'u1_3', 'u3_1', 'u1_2_1', 'u1_1_1_1'], array_keys(SectionLayouts::UNITS));
foreach (SectionLayouts::UNITS as $key => $units) {
$this->assertSame(4, array_sum($units), $key);
$this->assertLessThanOrEqual(4, count($units), $key);
}
$this->assertSame('1 + 2 + 1', SectionLayouts::short('u1_2_1'));
}
public function test_columns_follow_the_units_and_stack_unequal_layouts_on_tablets(): void
{
$this->assertSame(['lg' => 'minmax(0, 1fr) minmax(0, 3fr)', 'md' => 'minmax(0, 1fr)'], SectionLayouts::columns([1, 3]));
$this->assertSame('repeat(2, minmax(0, 1fr))', SectionLayouts::columns([1, 1, 1, 1])['md']);
$this->assertSame('repeat(3, minmax(0, 1fr))', SectionLayouts::columns([1, 1, 1])['md']);
$this->assertSame('repeat(2, minmax(0, 1fr))', SectionLayouts::columns([2, 2])['md']);
$this->assertSame(['lg' => 'minmax(0, 1fr)', 'md' => 'minmax(0, 1fr)'], SectionLayouts::columns([3]));
}
public function test_sections_are_normalized_with_slots_matching_the_layout(): void
{
$stored = $this->sections()->normalize([
$this->section('u1_3', [$this->heading('Links'), $this->heading('Rechts')], ['background' => 'dark', 'divider' => 'line']),
$this->section('u1_1_1_1', [$this->heading('Eins'), null, $this->heading('Drei')]),
]);
$this->assertCount(2, $stored);
$this->assertSame('u1_3', $stored[0]['layout']);
$this->assertSame(1, $stored[0]['v']);
$this->assertSame('dark', $stored[0]['style']['background']);
$this->assertSame('line', $stored[0]['style']['divider']);
$this->assertSame('standard', $stored[0]['style']['width']);
$this->assertCount(4, $stored[1]['slots'], 'Fehlende Plätze werden als leere Plätze ergänzt.');
$this->assertNull($stored[1]['slots'][1]);
$this->assertNull($stored[1]['slots'][3]);
$this->assertNotEmpty($stored[0]['id']);
}
public function test_flat_widgets_are_taken_over_as_full_width_sections(): void
{
$stored = $this->sections()->normalize([
['type' => 'heading', 'heading' => 'Altformat'],
$this->heading('Hülle'),
]);
$this->assertSame(['u4', 'u4'], array_column($stored, 'layout'));
$this->assertSame('Altformat', $stored[0]['slots'][0]['data']['heading']);
}
public function test_more_widgets_than_slots_are_rejected_instead_of_dropped(): void
{
try {
$this->sections()->normalize([
$this->section('u2_2', [$this->heading('A'), $this->heading('B'), $this->heading('C')]),
]);
$this->fail('Überzähliges Widget wurde angenommen.');
} catch (ValidationException $exception) {
$this->assertArrayHasKey('sections.0.slots', $exception->errors());
$this->assertStringContainsString('2 Plätze', $exception->errors()['sections.0.slots'][0]);
}
}
public function test_surplus_empty_slots_are_compacted_without_losing_widgets(): void
{
$stored = $this->sections()->normalize([
$this->section('u2_2', [$this->heading('A'), null, $this->heading('C'), null]),
]);
$this->assertSame(['A', 'C'], array_map(fn ($slot) => $slot['data']['heading'], $stored[0]['slots']));
}
public function test_widget_minimum_width_is_enforced_per_slot(): void
{
$hero = ['type' => 'hero', 'v' => 1, 'data' => ['heading' => 'Einstieg']];
try {
$this->sections()->normalize([$this->section('u1_3', [$hero, null])]);
$this->fail('Einstieg im schmalen Platz wurde angenommen.');
} catch (ValidationException $exception) {
$this->assertArrayHasKey('sections.0.slots.0.units', $exception->errors());
}
$stored = $this->sections()->normalize([$this->section('u1_3', [null, $hero])]);
$this->assertSame('hero', $stored[0]['slots'][1]['type']);
$this->assertSame(2, app(WidgetRegistry::class)->get('hero')->minUnits());
}
public function test_free_style_values_and_unknown_layouts_are_rejected(): void
{
foreach ([
[['layout' => 'u5', 'slots' => []], 'sections.0.layout'],
[$this->section('u4', [], ['background' => '#ff00ff']), 'sections.0.style.background'],
[$this->section('u4', [], ['css' => 'color: red']), 'sections.0.style.css'],
[$this->section('u4', [], ['spacing' => 'riesig']), 'sections.0.style.spacing'],
] as [$section, $key]) {
try {
$this->sections()->normalize([$section]);
$this->fail('Freier Wert wurde angenommen: '.$key);
} catch (ValidationException $exception) {
$this->assertArrayHasKey($key, $exception->errors());
}
}
}
public function test_background_image_must_be_public_and_is_dropped_for_other_backgrounds(): void
{
try {
$this->sections()->normalize([$this->section('u4', [$this->heading('A')], ['background' => 'image', 'image' => 'bibliothek/standbild.jpg'])]);
$this->fail('Geschütztes Bild wurde als Hintergrund angenommen.');
} catch (ValidationException $exception) {
$this->assertArrayHasKey('sections.0.style.image', $exception->errors());
}
try {
$this->sections()->normalize([$this->section('u4', [$this->heading('A')], ['background' => 'image'])]);
$this->fail('Hintergrundbild ohne Bild wurde angenommen.');
} catch (ValidationException $exception) {
$this->assertArrayHasKey('sections.0.style.image', $exception->errors());
}
$stored = $this->sections()->normalize([
$this->section('u4', [$this->heading('A')], ['background' => 'image', 'image' => 'cms/flaeche.jpg', 'focus' => 'top', 'overlay' => 'dark']),
$this->section('u4', [$this->heading('B')], ['background' => 'light', 'image' => 'cms/flaeche.jpg']),
]);
$this->assertSame('cms/flaeche.jpg', $stored[0]['style']['image']);
$this->assertNull($stored[1]['style']['image']);
$this->assertSame(['cms/flaeche.jpg'], $this->sections()->mediaPaths($stored));
}
public function test_ids_are_unique_across_the_whole_page_after_duplicating_a_section(): void
{
$section = ['id' => 'abschnitt-a'] + $this->section('u2_2', [
['id' => 'widget-a'] + $this->heading('A'),
['id' => 'widget-b'] + $this->heading('B'),
]);
$stored = $this->sections()->normalize([$section, $section]);
$this->assertSame('abschnitt-a', $stored[0]['id']);
$this->assertNotSame('abschnitt-a', $stored[1]['id']);
$widgetIds = array_column(array_merge($stored[0]['slots'], $stored[1]['slots']), 'id');
$this->assertCount(4, array_unique($widgetIds));
$this->assertSame(['widget-a', 'widget-b'], array_slice($widgetIds, 0, 2));
}
public function test_all_errors_of_a_page_are_reported_together(): void
{
try {
$this->sections()->normalize([
$this->section('u2_2', [['type' => 'heading', 'v' => 1, 'data' => []], null]),
$this->section('u4', [['type' => 'call_to_action', 'v' => 1, 'data' => ['heading' => 'X', 'label' => 'Los', 'url' => 'javascript:alert(1)']]]),
]);
$this->fail('Fehlerhafte Seite wurde angenommen.');
} catch (ValidationException $exception) {
$this->assertArrayHasKey('sections.0.slots.0.data.heading', $exception->errors());
$this->assertArrayHasKey('sections.1.slots.0.data.url', $exception->errors());
}
}
public function test_reading_without_sections_wraps_legacy_blocks_in_single_column_sections(): void
{
$sections = $this->sections()->read(null, [
['type' => 'heading', 'heading' => 'Alt'],
['type' => 'gibt_es_nicht'],
['type' => 'prose', 'v' => 1, 'data' => ['body' => 'Text']],
]);
$this->assertCount(2, $sections);
$this->assertSame('u4', $sections[0]['layout']);
$this->assertSame('compact', $sections[0]['style']['spacing']);
$this->assertSame('Alt', $sections[0]['slots'][0]['data']['heading']);
$this->assertSame('prose', $sections[1]['slots'][0]['type']);
}
public function test_reading_is_lenient_with_unknown_stored_values(): void
{
$sections = $this->sections()->read([
['id' => 'x', 'layout' => 'u9', 'style' => ['background' => 'pink', 'width' => 'wide'], 'slots' => [['type' => 'heading', 'v' => 1, 'data' => ['heading' => 'A']]]],
]);
$this->assertSame('u4', $sections[0]['layout']);
$this->assertSame('default', $sections[0]['style']['background']);
$this->assertSame('wide', $sections[0]['style']['width']);
}
public function test_flatten_keeps_reading_order_for_the_rollback_column(): void
{
$stored = $this->sections()->normalize([
$this->section('u1_1_1_1', [$this->heading('1'), null, $this->heading('3'), $this->heading('4')]),
$this->section('u4', [$this->heading('5')]),
]);
$this->assertSame(['1', '3', '4', '5'], array_map(fn ($widget) => $widget['data']['heading'], $this->sections()->flatten($stored)));
$this->assertSame('1', $this->sections()->pageTitle($stored));
}
public function test_style_summary_names_background_and_divider(): void
{
$this->assertSame('Dunkle Markenfläche · Breit · Trenner: Dezente Linie', SectionStyle::summary(['background' => 'dark', 'width' => 'wide', 'divider' => 'line']));
}
public function test_layout_change_in_the_editor_never_drops_a_widget(): void
{
$slots = [
'a' => ['widget' => ['w1' => ['type' => 'heading']]],
'b' => ['widget' => []],
'c' => ['widget' => ['w3' => ['type' => 'prose']]],
'd' => ['widget' => []],
];
$two = SectionEditor::arrangeSlots($slots, 'u2_2');
$this->assertSame(['a', 'c'], array_keys($two));
$one = SectionEditor::arrangeSlots($two, 'u4');
$this->assertCount(2, $one, 'Passen die Widgets nicht, bleiben alle erhalten; das Speichern weist die Seite ab.');
$four = SectionEditor::arrangeSlots($two, 'u1_1_1_1');
$this->assertCount(4, $four);
$this->assertSame(['a', 'c'], array_slice(array_keys($four), 0, 2));
$this->assertSame(2, SectionEditor::filledCount($four));
}
}
+14
View File
@@ -66,6 +66,20 @@ public function test_registration_rejects_keys_that_are_not_stable_identifiers()
new WidgetRegistry([$this->customWidget('Teaser Box')]);
}
public function test_every_widget_declares_a_minimum_width_within_four_units(): void
{
foreach ($this->registry()->all() as $key => $type) {
$this->assertGreaterThanOrEqual(1, $type->minUnits(), $key);
$this->assertLessThanOrEqual($type->preferredUnits(), $type->minUnits(), $key);
$this->assertLessThanOrEqual(4, $type->preferredUnits(), $key);
$this->assertNotEmpty($type->stages(), $key);
}
$this->assertSame(2, $this->registry()->get('hero')->minUnits());
$this->assertSame(2, $this->registry()->get('image_text')->minUnits());
$this->assertSame(1, $this->registry()->get('catalog_cards')->minUnits());
}
public function test_a_new_widget_type_works_through_the_contract_alone(): void
{
$registry = new WidgetRegistry([$this->customWidget('teaser')]);
+3 -2
View File
@@ -9,8 +9,9 @@ export default defineConfig({
input: ['resources/css/app.css', 'resources/js/app.js'],
refresh: true,
fonts: [
bunny('Source Serif 4', {
weights: [500, 600],
// Vorläufige Markenschriften (Website-Zielkonzept 7.2, nicht freigegeben); beim Build lokal abgelegt.
bunny('Nunito', {
weights: [700, 800],
optimizedFallbacks: false,
}),
bunny('Source Sans 3', {