Merge remote-tracking branch 'origin/develop' into feature/widget-flaeche-schrift
CI Feature / test (push) Failing after 8m2s
CI Feature / test (push) Failing after 8m2s
This commit is contained in:
commit
7b43db2498
8 files changed
+233
-4
No files matched your search
@@ -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'))
|
->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')))
|
->itemLabel(fn (array $state, ?int $index, Get $get): HtmlString => self::slotLabel($state, $index, $get('layout')))
|
||||||
->default(fn (): array => self::arrangeSlots([], SectionLayouts::DEFAULT))
|
->default(fn (): array => self::arrangeSlots([], SectionLayouts::DEFAULT))
|
||||||
->extraAttributes(fn (Get $get): array => [
|
->extraAttributes(function (Get $get): array {
|
||||||
'class' => 'luf-slots',
|
// Die eingestellte Hintergrundfarbe steht schon im Seitenaufbau hinter den Plätzen (nur bei eigener Fläche).
|
||||||
'style' => '--luf-slot-cols: '.self::editorColumns($get('layout')),
|
$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>'
|
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>' : '')
|
.($given !== null ? '<span class="luf-abschnitt-nummer" aria-hidden="true">'.e($number).'</span>' : '')
|
||||||
.$badges
|
.$badges
|
||||||
|
.SectionSurface::swatch(is_array($state['style'] ?? null) ? $state['style'] : [])
|
||||||
.'<span class="luf-abschnitt-meta" aria-hidden="true">'.e(implode(' · ', $meta)).'</span>'
|
.'<span class="luf-abschnitt-meta" aria-hidden="true">'.e(implode(' · ', $meta)).'</span>'
|
||||||
.'<span class="vw-sr">: '.e($spoken).'</span></span>');
|
.'<span class="vw-sr">: '.e($spoken).'</span></span>');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) ?? '';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# Abnahme: Hintergrund des Abschnitts im Seitenaufbau
|
||||||
|
|
||||||
|
Stand: 30.11.2026. Screenshots: `abnahme/cms-seitenuebersicht-flaechen/`. Prüfung durch Claude lokal im Browser (Playwright, Chromium); die praktische Abnahme durch den Betreiber auf `luf-test` steht aus.
|
||||||
|
|
||||||
|
## Was geändert ist
|
||||||
|
|
||||||
|
Der Seitenaufbau (Seiteninhalt im Seiteneditor) zeigt die eingestellte Hintergrundfläche jedes Abschnitts:
|
||||||
|
|
||||||
|
- **Farbfeld im Abschnittskopf** („Aa“ in Flächen- und Schriftfarbe) neben dem Namen, mit dem Titel „Hintergrund: …“. Die Kurzangabe nennt die Fläche weiterhin als Text (Helle/Dunkle Markenfläche, Markenakzent, Name der Palettenfarbe, Hintergrundbild).
|
||||||
|
- **Fläche hinter den Plätzen:** Die Plätze des Abschnitts stehen auf einem Rahmen in der Hintergrundfarbe. Die Plätze selbst bleiben helle Karten, damit Texte und Bedienelemente des Editors lesbar bleiben. Bei einem Hintergrundbild steht das Bild (Vorschaubreite) als Rahmen.
|
||||||
|
- **Abschnitte ohne eigene Fläche** (Standard) bleiben unverändert. Eine Palettenfarbe, die es nicht mehr gibt, erscheint wie auf der Website als Abschnitt ohne Fläche.
|
||||||
|
- Eine Änderung im Kontext „Abschnitt gestalten“ (Kachel wählen) wirkt nach „Zum Seitenaufbau“ sofort (`nach-farbwahl`).
|
||||||
|
|
||||||
|
Reine Anzeige im Editor: Speicherformat, Ausgabe auf der Website und Vorschau ändern sich nicht. Umsetzung: `App\Filament\Support\SectionSurface`, Regeln `.luf-flaeche` und `.luf-abschnitt-flaeche` in `resources/views/filament/cms/styles.blade.php`.
|
||||||
|
|
||||||
|
## Geprüft (lokal, Testseite mit sechs Abschnitten: Standard, hell, dunkel, Akzent, zwei Palettenfarben)
|
||||||
|
|
||||||
|
- Berechnete Hintergrundfarben des Rahmens stimmen mit den Flächenfarben überein (dunkel rgb(3, 37, 81), Akzent rgb(59, 123, 9), Sand rgb(243, 233, 210), Waldgrün rgb(31, 77, 43)); der Abschnitt ohne Fläche bleibt transparent (`seitenaufbau-breit`).
|
||||||
|
- Fünf Farbfelder im Kopf, eines je Abschnitt mit Fläche.
|
||||||
|
- 390 px: kein waagerechtes Scrollen, Rahmen und Farbfeld bleiben sichtbar (`seitenaufbau-schmal`).
|
||||||
|
- Keine Skriptfehler.
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 150 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 237 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 177 KiB |
@@ -94,6 +94,11 @@
|
|||||||
/* Ein Platz ist eine leise Fläche statt eines gestrichelten Rahmens; nur ein leerer Platz bleibt gestrichelt. */
|
/* Ein Platz ist eine leise Fläche statt eines gestrichelten Rahmens; nur ein leerer Platz bleibt gestrichelt. */
|
||||||
.luf-slots .fi-fo-repeater-item { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; background: var(--vw-paper); border: 0; border-radius: var(--vw-radius-small); box-shadow: none; }
|
.luf-slots .fi-fo-repeater-item { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; background: var(--vw-paper); border: 0; border-radius: var(--vw-radius-small); box-shadow: none; }
|
||||||
.luf-slots .fi-fo-repeater-item:not(:has(.fi-fo-builder-item)) { background: transparent; box-shadow: inset 0 0 0 1px var(--vw-line-strong); }
|
.luf-slots .fi-fo-repeater-item:not(:has(.fi-fo-builder-item)) { background: transparent; box-shadow: inset 0 0 0 1px var(--vw-line-strong); }
|
||||||
|
/* Hintergrund des Abschnitts (Seitenübersicht): die eingestellte Fläche steht als Rahmen hinter den Plätzen, die Plätze
|
||||||
|
bleiben helle Karten, damit Bedienelemente und Texte des Editors lesbar bleiben. Ohne eigene Fläche entfällt der Rahmen. */
|
||||||
|
.luf-slots.luf-flaeche { padding: .5rem; border-radius: var(--vw-radius-small); background-color: var(--luf-fl-bg); background-image: var(--luf-fl-img, none); background-position: center; background-size: cover; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 14%); }
|
||||||
|
.luf-slots.luf-flaeche .fi-fo-repeater-item:not(:has(.fi-fo-builder-item)) { background: rgb(255 255 255 / 60%); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 25%); }
|
||||||
|
.luf-abschnitt-flaeche { display: inline-flex; align-items: center; justify-content: center; min-width: 1.7rem; height: 1.3rem; padding: 0 .3rem; border-radius: .3rem; font-size: .7rem; font-weight: 700; line-height: 1; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 25%); }
|
||||||
.luf-slots .fi-fo-repeater-item-header { padding: .2rem 0 .2rem .1rem; border: 0; background: transparent; min-height: 0; }
|
.luf-slots .fi-fo-repeater-item-header { padding: .2rem 0 .2rem .1rem; border: 0; background: transparent; min-height: 0; }
|
||||||
.luf-slots .fi-fo-repeater-item:has(.luf-platz-warnung) { grid-template-columns: minmax(0, 1fr); }
|
.luf-slots .fi-fo-repeater-item:has(.luf-platz-warnung) { grid-template-columns: minmax(0, 1fr); }
|
||||||
.luf-platz-warnung { display: block; padding: .25rem .5rem; border-radius: .35rem; background: #fff6dc; color: #9a5b00; font-size: .8rem; font-weight: 600; }
|
.luf-platz-warnung { display: block; padding: .25rem .5rem; border-radius: .35rem; background: #fff6dc; color: #9a5b00; font-size: .8rem; font-weight: 600; }
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Domain\Cms\Page;
|
||||||
|
use App\Domain\Cms\PageService;
|
||||||
|
use App\Domain\Design\DesignPalette;
|
||||||
|
use App\Filament\Resources\Pages\Pages\EditPage;
|
||||||
|
use App\Filament\Support\SectionSurface;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Livewire\Features\SupportTesting\Testable;
|
||||||
|
use Livewire\Livewire;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hintergrund des Abschnitts in der Seitenübersicht (Seitenaufbau im Editor): Die eingestellte Fläche steht hinter den
|
||||||
|
* Plätzen und als Farbfeld im Abschnittskopf. Abschnitte ohne eigene Fläche bleiben unverändert.
|
||||||
|
*/
|
||||||
|
class CmsSectionSurfaceTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
protected function tearDown(): void
|
||||||
|
{
|
||||||
|
DesignPalette::flush();
|
||||||
|
parent::tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<array<string, mixed>> $styles
|
||||||
|
*/
|
||||||
|
private function editor(array $styles): Testable
|
||||||
|
{
|
||||||
|
$user = User::factory()->redakteur()->create();
|
||||||
|
$user->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||||
|
$page = Page::query()->create(['path' => '/flaechen']);
|
||||||
|
$sections = array_map(fn (array $style): array => [
|
||||||
|
'layout' => 'u4',
|
||||||
|
'style' => $style,
|
||||||
|
'slots' => [['type' => 'cards', 'v' => 2, 'variant' => 'standard', 'settings' => ['link_style' => 'text'], 'data' => ['items' => [['title' => 'Eins', 'url' => '/a']]]]],
|
||||||
|
], $styles);
|
||||||
|
app(PageService::class)->saveRevision($page, $sections, null, null, null);
|
||||||
|
|
||||||
|
return Livewire::actingAs($user, 'staff')->test(EditPage::class, ['record' => $page->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_brand_surfaces_are_described_with_their_colours(): void
|
||||||
|
{
|
||||||
|
$dark = SectionSurface::of(['background' => 'dark']);
|
||||||
|
$this->assertSame(['brand', '#032551', true], [$dark['kind'], $dark['bg'], $dark['dark']]);
|
||||||
|
|
||||||
|
$light = SectionSurface::of(['background' => 'light']);
|
||||||
|
$this->assertSame(['brand', '#f7f6f2', false], [$light['kind'], $light['bg'], $light['dark']]);
|
||||||
|
|
||||||
|
$this->assertSame('', SectionSurface::css([]), 'Ohne eigene Fläche gibt es keine Eigenschaften.');
|
||||||
|
$this->assertSame('', SectionSurface::swatch(['background' => 'default']));
|
||||||
|
$this->assertSame('--luf-fl-bg: #3b7b09', SectionSurface::css(['background' => 'accent']));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_palette_colour_and_a_missing_palette_colour(): void
|
||||||
|
{
|
||||||
|
$this->assertSame([], DesignPalette::save(null, 'Sand', '#f3e9d2', '#15243a'));
|
||||||
|
$id = DesignPalette::slots()[0]['id'];
|
||||||
|
|
||||||
|
$surface = SectionSurface::of(['background' => 'palette', 'palette_slot' => $id]);
|
||||||
|
$this->assertSame(['palette', 'Sand', '#f3e9d2'], [$surface['kind'], $surface['label'], $surface['bg']]);
|
||||||
|
$this->assertStringContainsString('--luf-fl-bg: #f3e9d2', SectionSurface::css(['background' => 'palette', 'palette_slot' => $id]));
|
||||||
|
|
||||||
|
// Wie auf der Website: eine Farbe, die es nicht mehr gibt, erscheint als Abschnitt ohne eigene Fläche.
|
||||||
|
$this->assertSame('', SectionSurface::css(['background' => 'palette', 'palette_slot' => 'c99']));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_an_image_without_a_usable_address_gets_a_neutral_surface_and_never_leaks_markup(): void
|
||||||
|
{
|
||||||
|
$this->assertSame('--luf-fl-bg: #d9dee5', SectionSurface::css(['background' => 'image']));
|
||||||
|
$this->assertStringContainsString('Hintergrundbild', SectionSurface::swatch(['background' => 'image']));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_editor_shows_the_surface_behind_the_slots_and_in_the_header(): void
|
||||||
|
{
|
||||||
|
$this->assertSame([], DesignPalette::save(null, 'Sand', '#f3e9d2', '#15243a'));
|
||||||
|
$component = $this->editor([
|
||||||
|
[],
|
||||||
|
['background' => 'dark'],
|
||||||
|
['background' => 'palette', 'palette_slot' => DesignPalette::slots()[0]['id']],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$html = $component->html();
|
||||||
|
|
||||||
|
$this->assertSame(2, substr_count($html, 'luf-slots luf-flaeche'), 'Nur die beiden Abschnitte mit eigener Fläche erhalten den Rahmen.');
|
||||||
|
$this->assertStringContainsString('--luf-fl-bg: #032551', $html);
|
||||||
|
$this->assertStringContainsString('--luf-fl-bg: #f3e9d2', $html);
|
||||||
|
$this->assertSame(2, substr_count($html, 'luf-abschnitt-flaeche" aria-hidden'), 'Je Abschnitt mit Fläche ein Farbfeld im Kopf.');
|
||||||
|
$this->assertStringContainsString('Hintergrund: Dunkle Markenfläche', $html);
|
||||||
|
$this->assertStringContainsString('Hintergrund: Sand', $html);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user