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>
151 lines
4.4 KiB
PHP
151 lines
4.4 KiB
PHP
<?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);
|
|
}
|
|
}
|