Füge die zentrale Farbpalette und die Hintergrundbreite für Abschnitte hinzu (ADR-67)

- DesignPalette: bis zu zehn benannte Farben (Hintergrund und Schrift) in site_settings,
  stabile Kennungen, Kontrastprüfung 4,5:1 auf dem Server, Verwendungssuche
- Seite Website → Design → Farben (Systemverwalter): Kacheln, Dialog mit Live-Vorschau,
  Kontrastwarnung mit Empfehlung, Bestätigung mit betroffenen Seiten, Entfernen gesperrt bei Verwendung
- Hintergrund „Farbe aus der Palette“ als Verweis im bestehenden Feld background; farbige Kacheln im Editor
- Renderer leitet Bedeutungswerte aus Hintergrund und Schrift ab; scope-dark bei heller Schrift
- Hintergrundbreite: volle Browserbreite (Vorgabe) oder auf Abschnittsbreite begrenzt
- Test sichert die Ausgabe aller bisherigen Varianten byte-gleich; Abnahme mit Screenshots

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Sonnet 5.5 committed 2026-11-29 18:35:15 +01:00
1 parent 62f3a33541
commit 87de5a62d4
41 files changed
+2372 -14

No files matched your search

+18 -1
View File
@@ -6,6 +6,7 @@
use App\Domain\Cms\Widgets\Support\PublicMedia;
use App\Domain\Cms\Widgets\WidgetErrors;
use App\Domain\Cms\Widgets\WidgetRegistry;
use App\Domain\Design\DesignPalette;
use Illuminate\Support\Str;
use Illuminate\Validation\ValidationException;
@@ -439,7 +440,7 @@ private function normalizeStyle(array $style, string $prefix, array &$errors): a
$enums = SectionStyle::enums();
foreach ($style as $key => $value) {
if ($key === 'image' || str_starts_with((string) $key, '_')) {
if (in_array($key, ['image', 'palette_slot'], true) || str_starts_with((string) $key, '_')) {
continue;
}
@@ -469,6 +470,22 @@ private function normalizeStyle(array $style, string $prefix, array &$errors): a
}
}
// Die Breite der Fläche gilt nur mit eigenem Hintergrund.
if ($result['background'] === 'default') {
unset($result['background_width']);
}
// Farbe aus der Palette: Der Verweis steht nur bei diesem Hintergrund im gespeicherten Stand.
if ($result['background'] === 'palette') {
$slot = DesignPalette::find($style['palette_slot'] ?? null);
if ($slot === null) {
$errors["$prefix.style.palette_slot"] = ['Bitte eine Farbe aus der Palette wählen. Die gewählte Farbe gibt es nicht (mehr).'];
} else {
$result['palette_slot'] = $slot['id'];
}
}
if ($result['background'] === 'image') {
$widgetErrors = new WidgetErrors;
$refs = ImageRefFields::clean(['image' => $style['image'] ?? null, '_upload' => $style['_upload'] ?? null], $widgetErrors, errorKey: 'image');
+24 -1
View File
@@ -5,6 +5,8 @@
use App\Domain\Cms\Widgets\RenderContext;
use App\Domain\Cms\Widgets\Support\WebsiteImage;
use App\Domain\Cms\Widgets\WidgetRenderer;
use App\Domain\Design\ColorContrast;
use App\Domain\Design\DesignPalette;
use Illuminate\Support\HtmlString;
/**
@@ -141,24 +143,45 @@ private function renderSection(array $section, array $cells, int $index, RenderC
$classes[] = 'section-cards-links-bottom';
}
// Farbe aus der Palette (ADR-67): Hintergrund- und Schriftfarbe der Farbe; die Bausteine erhalten daraus abgeleitete
// Bedeutungswerte. Ist die Farbe nicht (mehr) in der Palette, fällt SectionStyle::fromStored auf „Standard“ zurück.
$palette = $style['background'] === 'palette' ? DesignPalette::find($style['palette_slot']) : null;
$dark = $palette !== null && ColorContrast::isDarkSurface($palette['fg'], $palette['bg']);
// 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',
$dark => 'scope-dark',
default => null,
};
if ($scope !== null) {
$classes[] = $scope;
}
// Breite der Fläche (ADR-67): nur bei „Auf Abschnittsbreite begrenzt“, mit eigener Fläche und schmaler als die volle Breite.
$hasSurface = $hasImage || $palette !== null || in_array($style['background'], ['light', 'dark', 'accent'], true);
if ($hasSurface && $style['background_width'] === 'section' && $style['width'] !== 'full') {
$classes[] = 'section-bg-width-section';
}
// Die Sprungmarke ist die Kennung, die ein Link „#marke“ anspringt; ohne sie bleibt die bisherige Kennung.
$anchor = PageSections::cleanAnchor($section['anchor'] ?? null);
$id = $anchor !== null
? ' id="'.e($anchor).'"'
: (is_string($section['id'] ?? null) ? ' id="bereich-'.e($section['id']).'"' : '');
$html = '<div class="'.e(implode(' ', $classes)).'"'.$id.'>';
$surface = '';
if ($palette !== null) {
$surface = ' style="';
foreach (ColorContrast::surfaceProperties($palette['bg'], $palette['fg']) as $property => $value) {
$surface .= '--'.$property.': '.e($value).'; ';
}
$surface = rtrim($surface).'"';
}
$html = '<div class="'.e(implode(' ', $classes)).'"'.$id.$surface.'>';
if ($hasImage) {
// Das Bild des ersten Abschnitts ist meist das größte sichtbare Element und wird nicht verzögert geladen.
+34 -2
View File
@@ -3,6 +3,7 @@
namespace App\Domain\Cms\Sections;
use App\Domain\Cms\Widgets\Support\WebsiteImage;
use App\Domain\Design\DesignPalette;
/**
* Semantische Abschnittsgestaltung. Jeder Wert ist eine Aufzählung, die auf zentrale Design-Tokens
@@ -16,9 +17,21 @@ final class SectionStyle
'light' => 'Helle Markenfläche',
'dark' => 'Dunkle Markenfläche',
'accent' => 'Markenakzent',
'palette' => 'Farbe aus der Palette',
'image' => 'Hintergrundbild',
];
/**
* Breite der Fläche eines Abschnitts mit eigenem Hintergrund (Farbe, Palette oder Bild). „Volle Browserbreite“ ist das
* bisherige Verhalten; „Auf Abschnittsbreite begrenzt“ zentriert die Fläche in der gewählten Inhaltsbreite.
*
* @var array<string, string>
*/
public const BACKGROUND_WIDTHS = [
'full' => 'Volle Browserbreite',
'section' => 'Auf Abschnittsbreite begrenzt',
];
/** @var array<string, string> */
public const WIDTHS = [
'narrow' => 'Lesebereich',
@@ -123,6 +136,7 @@ final class SectionStyle
* Abschnitte ohne diese Optionen unverändert bleiben (Format und Vergleich mit dem letzten Stand).
*/
public const OPTIONAL = [
'background_width' => 'full',
'cards_height' => 'auto',
'cards_links' => 'text',
];
@@ -136,6 +150,7 @@ public static function enums(): array
{
return [
'background' => self::BACKGROUNDS,
'background_width' => self::BACKGROUND_WIDTHS,
'focus' => self::FOCUS,
'overlay' => self::OVERLAYS,
'width' => self::WIDTHS,
@@ -152,7 +167,7 @@ public static function enums(): array
* 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_top: string, spacing_bottom: string, gap: string, divider: string, cards_height: string, cards_links: string}
* @return array{background: string, palette_slot: ?string, background_width: string, image: ?string, focus: string, overlay: string, width: string, spacing_top: string, spacing_bottom: string, gap: string, divider: string, cards_height: string, cards_links: string}
*/
public static function fromStored(mixed $style): array
{
@@ -168,6 +183,17 @@ public static function fromStored(mixed $style): array
$result['image'] = $result['background'] === 'image' ? WebsiteImage::normalize($style['image'] ?? null) : null;
// Farbe aus der Palette: Ist die Farbe nicht (mehr) in der Palette, erscheint der Abschnitt ohne eigene Fläche.
$result['palette_slot'] = null;
if ($result['background'] === 'palette') {
$slot = DesignPalette::find($style['palette_slot'] ?? null);
if ($slot === null) {
$result['background'] = 'default';
} else {
$result['palette_slot'] = $slot['id'];
}
}
return $result;
}
@@ -179,7 +205,13 @@ public static function fromStored(mixed $style): array
public static function summary(array $style): string
{
$style = self::fromStored($style);
$parts = [self::BACKGROUNDS[$style['background']]];
$parts = [$style['background'] === 'palette'
? 'Farbe „'.(DesignPalette::find($style['palette_slot'])['name'] ?? '').'“'
: self::BACKGROUNDS[$style['background']]];
if ($style['background'] !== 'default' && $style['background_width'] === 'section') {
$parts[] = 'Hintergrund auf Abschnittsbreite';
}
if ($style['width'] !== 'standard') {
$parts[] = self::WIDTHS[$style['width']];