Zeige den Abschnittshintergrund im Seitenaufbau des Editors
CI Feature / test (push) Successful in 5m17s
Deploy Test / test (push) Successful in 5m21s
Deploy Test / deploy (push) Successful in 26s

Farbfeld im Abschnittskopf und die eingestellte Fläche (Markenfläche,
Palettenfarbe, Hintergrundbild) als Rahmen hinter den Plätzen. Reine
Anzeige im Editor; Speicherformat und Ausgabe bleiben unverändert.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Sonnet 5.5 committed 2026-11-30 09:32:16 +01:00
1 parent 63ad125859
commit aca713c6ba
8 files changed
+233 -4

No files matched your search

+11 -4
View File
@@ -172,10 +172,16 @@ private static function sectionSchema(): array
->reorderAction(fn (Action $action): Action => $action->label('Baustein auf einen anderen Platz ziehen')->tooltip('Baustein auf einen anderen Platz ziehen'))
->itemLabel(fn (array $state, ?int $index, Get $get): HtmlString => 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')),
]),
->extraAttributes(function (Get $get): array {
// Die eingestellte Hintergrundfarbe steht schon im Seitenaufbau hinter den Plätzen (nur bei eigener Fläche).
$style = $get('style');
$surface = SectionSurface::css(is_array($style) ? $style : []);
return [
'class' => 'luf-slots'.($surface !== '' ? ' luf-flaeche' : ''),
'style' => '--luf-slot-cols: '.self::editorColumns($get('layout')).($surface !== '' ? '; '.$surface : ''),
];
}),
];
}
@@ -807,6 +813,7 @@ private static function sectionLabel(array $state, ?int $index): HtmlString
return new HtmlString('<span class="luf-abschnitt'.($hidden ? ' is-ausgeblendet' : '').'" title="'.e(($given !== null ? $number.' · ' : '').$full).'"><span class="luf-abschnitt-nr">'.e($text).'</span>'
.($given !== null ? '<span class="luf-abschnitt-nummer" aria-hidden="true">'.e($number).'</span>' : '')
.$badges
.SectionSurface::swatch(is_array($state['style'] ?? null) ? $state['style'] : [])
.'<span class="luf-abschnitt-meta" aria-hidden="true">'.e(implode(' · ', $meta)).'</span>'
.'<span class="vw-sr">: '.e($spoken).'</span></span>');
}
+98
View File
@@ -0,0 +1,98 @@
<?php
namespace App\Filament\Support;
use App\Domain\Cms\Sections\SectionStyle;
use App\Domain\Cms\Widgets\Support\WebsiteImage;
use App\Domain\Design\ColorContrast;
use App\Domain\Design\DesignPalette;
/**
* Fläche eines Abschnitts für den Seitenaufbau im Editor: die eingestellte Hintergrundfarbe (feste Markenfläche, Farbe
* aus der Palette oder Hintergrundbild), damit sie schon in der Seitenübersicht sichtbar ist und nicht erst in der
* Vorschau. Reine Anzeige; die Ausgabe auf der Website steht im SectionRenderer.
*/
final class SectionSurface
{
/**
* @param array<string, mixed> $style Gestaltung des Abschnitts (roh oder gespeichert)
* @return array{kind: string, label: string, bg: ?string, fg: ?string, image: ?string, dark: bool}
*/
public static function of(array $style): array
{
$style = SectionStyle::fromStored($style);
$background = $style['background'];
if ($background === 'palette') {
$slot = DesignPalette::find($style['palette_slot']);
if ($slot !== null) {
return ['kind' => 'palette', 'label' => $slot['name'], 'bg' => $slot['bg'], 'fg' => $slot['fg'], 'image' => null, 'dark' => ColorContrast::isDarkSurface($slot['fg'], $slot['bg'])];
}
}
if ($background === 'image') {
// Vorschaubreite aus dem Medienmanager (auch ohne Website-Freigabe, wie die Seitenvorschau).
$url = $style['image'] === null ? null : app(WebsiteImage::class)->url($style['image'], true, 640);
return ['kind' => 'image', 'label' => SectionStyle::BACKGROUNDS['image'], 'bg' => null, 'fg' => null, 'image' => $url, 'dark' => $style['overlay'] === 'dark'];
}
foreach (DesignPalette::builtIns() as $built) {
if ($built['key'] === $background) {
return ['kind' => $background === 'default' ? 'default' : 'brand', 'label' => $built['label'], 'bg' => $built['bg'], 'fg' => $built['fg'], 'image' => null, 'dark' => ColorContrast::isDarkSurface($built['fg'], $built['bg'])];
}
}
return ['kind' => 'default', 'label' => SectionStyle::BACKGROUNDS['default'], 'bg' => '#ffffff', 'fg' => '#15243a', 'image' => null, 'dark' => false];
}
/**
* Eigenschaften für den Platzbereich des Abschnitts. Leer bei „Standard“, damit sich dort nichts ändert.
*
* @param array<string, mixed> $style
*/
public static function css(array $style): string
{
$surface = self::of($style);
if ($surface['kind'] === 'default') {
return '';
}
if ($surface['kind'] === 'image') {
return $surface['image'] === null
? '--luf-fl-bg: #d9dee5'
: "--luf-fl-bg: #d9dee5; --luf-fl-img: url('".self::plain($surface['image'])."')";
}
return '--luf-fl-bg: '.$surface['bg'];
}
/**
* Farbfeld im Abschnittskopf. Nur bei eigener Fläche; der Name der Fläche steht in der Kurzangabe daneben, das Feld
* ist daher nur Schmuck für Screenreader (aria-hidden) und im Titel benannt.
*
* @param array<string, mixed> $style
*/
public static function swatch(array $style): string
{
$surface = self::of($style);
if ($surface['kind'] === 'default') {
return '';
}
$css = $surface['kind'] === 'image'
? 'background: #d9dee5'.($surface['image'] === null ? '' : " url('".self::plain($surface['image'])."') center / cover")
: 'background: '.$surface['bg'].'; color: '.$surface['fg'];
return '<span class="luf-abschnitt-flaeche" aria-hidden="true" title="Hintergrund: '.e($surface['label']).'" style="'.e($css).'">Aa</span>';
}
/** Adresse ohne Zeichen, die einen CSS-Wert verlassen könnten. */
private static function plain(string $url): string
{
return preg_replace('/[\s"\'()\\\\]/', '', $url) ?? '';
}
}