Files
laraundfelix/app/Domain/Cms/Sections/SectionStyle.php
T
LarsandClaude Opus 5.5 89fd95b243
CI Feature / test (push) Successful in 46s
Deploy Test / test (push) Successful in 37s
Deploy Test / deploy (push) Successful in 27s
Mache jede Seite in der Liste auffindbar, binde die freigegebene Wortmarke ein und erlaube Abstand oben.
- Seitenliste: zuletzt bearbeitete Seiten zuerst, „Zuletzt bearbeitet“
  in deutscher Zeit (jede Revision und Veröffentlichung aktualisiert
  die Seite), Pfad und Datum sortierbar, 25/50/100 je Seite. Bisher
  stand eine neue Seite ohne Suche auf einer späteren Listenseite.
- Kopfzeile und Fußbereich zeigen die freigegebene Lara-&-Felix-
  Wortmarke (Kompaktfassung aus Brand-UI-Kit 08) als zugeschnittene
  WebP-Ableitung mit festen Maßen; Ausgangszustand ≈ 80 px, kompakt
  60 px, Smartphone 48 px. Mitgliederbereich unverändert.
- Abschnittsgestaltung „Abstand oben“ (wie Abstand / gering / kein):
  Der erste Abschnitt kann direkt unter der Kopfzeile beginnen; der
  Abstand unten und alle anderen Abschnitte bleiben unverändert.

Tests: Erwartung an die Wortmarke bewusst angepasst (brand-logo statt
brand-lockup); neue Tests für Liste, Bearbeitungsdatum und Abstand oben.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 11:54:10 +01:00

169 lines
5.0 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' => 'Lesebereich',
'standard' => 'Standard',
'wide' => 'Breit',
'full' => 'Vollbreite',
];
/** @var array<string, string> */
public const SPACINGS = [
'compact' => 'Kompakt',
'normal' => 'Normal',
'large' => 'Großzügig',
];
/**
* Abweichender Abstand oben, zum Beispiel damit ein Einstieg direkt unter der Kopfzeile beginnt.
* Ergänzt „Abstand oben und unten“, ersetzt ihn nicht; der Abstand unten bleibt unverändert.
*
* @var array<string, string>
*/
public const SPACINGS_TOP = [
'same' => 'Wie „Abstand oben und unten“',
'small' => 'Gering',
'none' => 'Kein Abstand',
];
/** @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',
'spacing_top' => 'same',
'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,
'spacing_top' => self::SPACINGS_TOP,
'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, spacing_top: 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['spacing_top'] !== 'same') {
$parts[] = 'oben '.mb_strtolower(self::SPACINGS_TOP[$style['spacing_top']]);
}
if ($style['divider'] !== 'none') {
$parts[] = 'Trenner: '.self::DIVIDERS[$style['divider']];
}
return implode(' · ', $parts);
}
}