Files
laraundfelix/app/Domain/Cms/Sections/SectionStyle.php
LarsandClaude Opus 5.5 33aaf64024
CI Feature / test (push) Successful in 36s
Deploy Test / test (push) Successful in 32s
Deploy Test / deploy (push) Successful in 32s
Stabilisiere den Website-Rahmen und veredele die zentralen Widgets.
Designiteration 1 auf Grundlage des Brand-UI-Kits (vorläufige Werte):
- Kopfzeile mit konstanter Box und zwei Zuständen (großzügig, kompakt
  beim Scrollen) ohne Layoutsprung; Navigation bricht nie um, sondern
  verkürzt erst den Kontozugang und schaltet dann in den Menümodus.
  Scrollbalken-Reserve, gemeinsames Breitenmodell (Lesebereich,
  Standard, Breit, Vollbreite), Wortmarke und Inhalt fluchten.
- Fokusfalle im Mobilmenü schließt auch den Weg von der
  Menü-Schaltfläche in den Inhalt.
- Fußbereich mit Grundzeile für rechtliche Links und grünem Bogen.
- Markenakzente (Unterstreichung, Strahlen, Bogen) als Komponenten.
- Hero: Varianten Markenbühne (randlos) und Editorial, zweite
  Schaltfläche, Bildausschnitt. Bild und Text: Bildformat und
  Ausschnitt. Karten: hervorgehobene erste Karte, ganze Karte klickbar.
  Programmkarten mit Markentafel. Alles additiv, ohne neue Version.

Testanpassungen: Die Website-Wortmarke trägt jetzt brand-lockup, die
erste Hero-Schaltfläche button-brand (beabsichtigte Gestaltung).

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

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' => 'Lesebereich',
'standard' => 'Standard',
'wide' => 'Breit',
'full' => 'Vollbreite',
];
/** @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);
}
}