diff --git a/app/Domain/Cms/Sections/PageSections.php b/app/Domain/Cms/Sections/PageSections.php index 29b90c7..4a31282 100644 --- a/app/Domain/Cms/Sections/PageSections.php +++ b/app/Domain/Cms/Sections/PageSections.php @@ -264,11 +264,11 @@ private function normalizeSection(array $section, int $index, array &$errors, ar } $type = $this->widgets->get($widget['type']); - if ($slotUnits < $type->minUnits()) { + if (! $type->supportsUnits($slotUnits)) { $errors["$prefix.slots.$position.units"] = [sprintf( - '„%s“ braucht mindestens %d Rastereinheiten; dieser Platz hat %d. Wählen Sie ein breiteres Raster oder einen breiteren Platz.', + '„%s“ ist für Plätze mit %s Rastereinheiten vorgesehen; dieser Platz hat %d. Wählen Sie ein passendes Raster oder einen passenden Platz.', $type->label(), - $type->minUnits(), + $type->unitsLabel(), $slotUnits, )]; } diff --git a/app/Domain/Cms/Sections/SectionRenderer.php b/app/Domain/Cms/Sections/SectionRenderer.php index ea30b0e..bc71a60 100644 --- a/app/Domain/Cms/Sections/SectionRenderer.php +++ b/app/Domain/Cms/Sections/SectionRenderer.php @@ -15,7 +15,6 @@ * - Ein Abschnitt ohne darstellbares Widget entfällt samt Hintergrund und Trenner. * - Das erste dargestellte Widget der Seite ist der Seiteneinstieg (Überschrift erster Ordnung). * - Trenner stehen zwischen Abschnitten, nie nach dem letzten. - * - Steht ein randloses Widget (WidgetType::bleeds) allein im Abschnitt, entfallen Innenabstand und Breitenbegrenzung. */ class SectionRenderer { @@ -44,7 +43,7 @@ public function renderAll(array $sections, RenderContext $context): HtmlString if ($html !== '') { $first = false; - $cells[] = ['units' => $slotUnits, 'html' => $html, 'bleeds' => $this->widgets->bleeds($widget)]; + $cells[] = ['units' => $slotUnits, 'html' => $html]; } } @@ -70,7 +69,7 @@ public function renderAll(array $sections, RenderContext $context): HtmlString /** * @param array $section - * @param list $cells + * @param list $cells */ private function renderSection(array $section, array $cells, int $index): string { @@ -106,10 +105,6 @@ private function renderSection(array $section, array $cells, int $index): string $classes[] = 'section-divider-space'; } - if (count($cells) === 1 && $cells[0]['bleeds']) { - $classes[] = 'section-bleed'; - } - $id = is_string($section['id'] ?? null) ? ' id="bereich-'.e($section['id']).'"' : ''; $html = '
'; diff --git a/app/Domain/Cms/Widgets/Support/ImageFocus.php b/app/Domain/Cms/Widgets/Support/ImageFocus.php deleted file mode 100644 index 63471c0..0000000 --- a/app/Domain/Cms/Widgets/Support/ImageFocus.php +++ /dev/null @@ -1,30 +0,0 @@ - - */ - public static function options(): array - { - return SectionStyle::FOCUS; - } - - /** - * @param array $settings - */ - public static function position(array $settings, string $key = 'focus'): string - { - $focus = $settings[$key] ?? 'center'; - - return SectionStyle::FOCUS_POSITIONS[is_string($focus) && isset(SectionStyle::FOCUS_POSITIONS[$focus]) ? $focus : 'center']; - } -} diff --git a/app/Domain/Cms/Widgets/Support/ImageRefFields.php b/app/Domain/Cms/Widgets/Support/ImageRefFields.php index 3b76105..d5244a6 100644 --- a/app/Domain/Cms/Widgets/Support/ImageRefFields.php +++ b/app/Domain/Cms/Widgets/Support/ImageRefFields.php @@ -16,18 +16,21 @@ final class ImageRefFields { /** + * @param bool $live Änderungen sofort an die Vorschau im Bearbeitungsdialog geben. * @return list */ - public static function fields(string $label = 'Bild'): array + public static function fields(string $label = 'Bild', bool $live = false): array { return [ Select::make('image') + ->live($live) ->label($label.': vorhandenes Bild') ->options(fn (): array => PublicMedia::imageOptions()) ->searchable() ->placeholder('Kein Bild') ->helperText('Auswahl aus den Bildern, die bereits für die Website hochgeladen wurden.'), FileUpload::make('_upload') + ->live($live) ->label($label.': neu hochladen') ->disk('cms_incoming') ->directory('cms') diff --git a/app/Domain/Cms/Widgets/Support/PremiumFields.php b/app/Domain/Cms/Widgets/Support/PremiumFields.php new file mode 100644 index 0000000..d1b8cb4 --- /dev/null +++ b/app/Domain/Cms/Widgets/Support/PremiumFields.php @@ -0,0 +1,200 @@ + 'Automatisch (Seiteneinstieg H1, sonst H2)', + 'h2' => 'H2', + 'h3' => 'H3', + ]; + + /** + * @return array + */ + public static function rules(): array + { + return [ + 'eyebrow' => ['nullable', 'string', 'max:80'], + 'cta_label' => ['nullable', 'string', 'max:80', 'required_with:data.cta_url'], + 'cta_url' => ['nullable', 'string', 'max:500', 'required_with:data.cta_label'], + 'cta2_label' => ['nullable', 'string', 'max:80', 'required_with:data.cta2_url'], + 'cta2_url' => ['nullable', 'string', 'max:500', 'required_with:data.cta2_label'], + 'alt' => ['nullable', 'string', 'max:300'], + 'focus_x' => ['nullable', 'numeric', 'between:0,100'], + 'focus_y' => ['nullable', 'numeric', 'between:0,100'], + ]; + } + + public static function eyebrowField(): TextInput + { + return TextInput::make('eyebrow') + ->label('Label über der Überschrift (optional)') + ->maxLength(80) + ->live(onBlur: true) + ->helperText('Kurzer Hinweis, zum Beispiel ein Themenbereich. Kein Pflichtfeld.'); + } + + public static function ctaFields(): Grid + { + $url = fn (string $name, string $label, string $pair) => TextInput::make($name) + ->label($label) + ->maxLength(500) + ->rule(SafeUrl::rule()) + ->requiredWith($pair) + ->live(onBlur: true) + ->placeholder('/programme'); + + return Grid::make(['default' => 1, 'md' => 2])->schema([ + TextInput::make('cta_label')->label('Hauptschaltfläche: Beschriftung')->maxLength(80)->live(onBlur: true), + $url('cta_url', 'Hauptschaltfläche: Linkziel', 'cta_label'), + TextInput::make('cta2_label')->label('Zweite Schaltfläche: Beschriftung')->maxLength(80)->live(onBlur: true), + $url('cta2_url', 'Zweite Schaltfläche: Linkziel', 'cta2_label'), + ]); + } + + /** + * @return list + */ + public static function focusFields(int $defaultX = 50, int $defaultY = 50): array + { + // Ohne gespeicherten Wert zeigt der Regler die Vorgabe der Widget-Art, die auch die Darstellung verwendet. + $slider = fn (string $name, string $label, int $default) => Slider::make($name) + ->label($label) + ->range(0, 100) + ->step(1) + ->required(false) + ->tooltips() + ->default($default) + ->afterStateHydrated(function (Slider $component, mixed $state) use ($default): void { + if (! is_numeric($state)) { + $component->state($default); + } + }) + ->live(); + + return [ + $slider('focus_x', 'Bildausschnitt waagerecht (0 = links, 100 = rechts)', $defaultX), + $slider('focus_y', 'Bildausschnitt senkrecht (0 = oben, 100 = unten)', $defaultY), + ]; + } + + public static function altField(): TextInput + { + return TextInput::make('alt') + ->label('Alternativtext des Bildes') + ->maxLength(300) + ->live(onBlur: true) + ->helperText('Beschreibt, was auf dem Bild zu sehen ist. Pflicht, sobald ein Bild gewählt ist.'); + } + + /** + * Bereinigt Label, Schaltflächen, Alternativtext und Fokus; meldet unsichere Linkziele. + * + * @param array $data + * @return array + */ + public static function clean(array $data, WidgetErrors $errors, bool $hasImage): array + { + foreach (['eyebrow', 'cta_label', 'cta_url', 'cta2_label', 'cta2_url', 'alt'] as $key) { + $data[$key] = filled($data[$key] ?? null) ? trim((string) $data[$key]) : null; + } + + foreach (['cta_url', 'cta2_url'] as $key) { + if ($data[$key] !== null && ! SafeUrl::isSafe($data[$key])) { + $errors->add("data.$key", SafeUrl::message()); + } + } + + foreach (['focus_x', 'focus_y'] as $key) { + $value = $data[$key] ?? null; + $data[$key] = is_numeric($value) ? (int) round(max(0, min(100, (float) $value))) : null; + } + + if ($hasImage && $data['alt'] === null) { + $errors->add('data.alt', 'Bitte einen Alternativtext für das Bild angeben.'); + } + + return $data; + } + + /** + * Schaltflächen mit sicherem Linkziel in Anzeigereihenfolge. + * + * @param array $data + * @return list + */ + public static function actions(array $data): array + { + $actions = []; + + foreach ([['cta_label', 'cta_url'], ['cta2_label', 'cta2_url']] as [$label, $url]) { + if (filled($data[$label] ?? null) && SafeUrl::isSafe($data[$url] ?? null)) { + $actions[] = ['label' => (string) $data[$label], 'url' => (string) $data[$url]]; + } + } + + return $actions; + } + + /** + * Bildfokus in Prozent; ohne Angabe die Vorgabe der Widget-Art. + * + * @param array $data + * @return array{x: int, y: int} + */ + public static function focus(array $data, int $defaultX = 50, int $defaultY = 50): array + { + $clamp = fn (mixed $value, int $default): int => is_numeric($value) ? (int) round(max(0, min(100, (float) $value))) : $default; + + return ['x' => $clamp($data['focus_x'] ?? null, $defaultX), 'y' => $clamp($data['focus_y'] ?? null, $defaultY)]; + } + + /** + * Übersetzt den früheren Fokuspunkt (Aufzählung wie beim Abschnittshintergrund) in Prozentwerte. + * + * @return array{focus_x: int|null, focus_y: int|null} + */ + public static function focusFromEnum(mixed $focus): array + { + if (! is_string($focus) || ! isset(SectionStyle::FOCUS_POSITIONS[$focus])) { + return ['focus_x' => null, 'focus_y' => null]; + } + + [$x, $y] = array_map(fn (string $part): int => (int) rtrim($part, '%'), explode(' ', SectionStyle::FOCUS_POSITIONS[$focus])); + + return ['focus_x' => $x, 'focus_y' => $y]; + } + + /** + * Überschriftenebene: „auto“ ergibt H1 für das erste Widget der Seite, sonst H2. Eine weitere H1 gibt es nicht. + * + * @param array $settings + */ + public static function headingTag(array $settings, bool $first): string + { + $level = $settings['heading_level'] ?? 'auto'; + + return match (true) { + $first => 'h1', + $level === 'h3' => 'h3', + default => 'h2', + }; + } +} diff --git a/app/Domain/Cms/Widgets/Types/CallToActionWidget.php b/app/Domain/Cms/Widgets/Types/CallToActionWidget.php index 3694a26..3123704 100644 --- a/app/Domain/Cms/Widgets/Types/CallToActionWidget.php +++ b/app/Domain/Cms/Widgets/Types/CallToActionWidget.php @@ -25,9 +25,22 @@ public function description(): string return 'Hervorgehobene Fläche mit Überschrift, Text und einer Schaltfläche.'; } - public function minUnits(): int + public function supportedUnits(): array { - return 1; + return [1, 2, 3, 4]; + } + + public function narrowBehavior(): string + { + return 'Unter 20 rem Slotbreite steht die Schaltfläche in voller Breite; Überschrift, Text und Beschriftung brechen um.'; + } + + public function heights(): array + { + return [ + 'auto' => 'Automatisch (nach Inhalt)', + 'fill' => 'Abschnittshöhe füllen (gleich hoch wie Nachbarplätze)', + ]; } public function preferredUnits(): int diff --git a/app/Domain/Cms/Widgets/Types/CardsWidget.php b/app/Domain/Cms/Widgets/Types/CardsWidget.php index ffe9e38..cc3bd86 100644 --- a/app/Domain/Cms/Widgets/Types/CardsWidget.php +++ b/app/Domain/Cms/Widgets/Types/CardsWidget.php @@ -35,9 +35,14 @@ public function description(): string return 'Mehrere Karten mit Titel, Text, Linkziel und optionalem Bild. Als Raster, kompakte Liste oder mit hervorgehobener erster Karte.'; } - public function minUnits(): int + public function supportedUnits(): array { - return 1; + return [1, 2, 3, 4]; + } + + public function narrowBehavior(): string + { + return 'Karten stehen untereinander, sobald keine zwei 15 rem breiten Karten nebeneinander passen; die hervorgehobene Karte stapelt Bild und Text.'; } public function preferredUnits(): int diff --git a/app/Domain/Cms/Widgets/Types/CatalogCardsWidget.php b/app/Domain/Cms/Widgets/Types/CatalogCardsWidget.php index 2150ab2..2a8e5a1 100644 --- a/app/Domain/Cms/Widgets/Types/CatalogCardsWidget.php +++ b/app/Domain/Cms/Widgets/Types/CatalogCardsWidget.php @@ -37,9 +37,14 @@ public function description(): string return 'Ausgewählte Programme und Module; Titel und Beschreibung kommen automatisch aus den Fachdaten.'; } - public function minUnits(): int + public function supportedUnits(): array { - return 1; + return [1, 2, 3, 4]; + } + + public function narrowBehavior(): string + { + return 'Karten stehen untereinander, die Markentafel über dem Text; lange Titel brechen um.'; } public function preferredUnits(): int diff --git a/app/Domain/Cms/Widgets/Types/FaqWidget.php b/app/Domain/Cms/Widgets/Types/FaqWidget.php index b8c332c..ca92261 100644 --- a/app/Domain/Cms/Widgets/Types/FaqWidget.php +++ b/app/Domain/Cms/Widgets/Types/FaqWidget.php @@ -24,9 +24,14 @@ public function description(): string return 'Häufige Fragen mit Antworten.'; } - public function minUnits(): int + public function supportedUnits(): array { - return 2; + return [2, 3, 4]; + } + + public function narrowBehavior(): string + { + return 'Fragen und Antworten untereinander; Antworten höchstens in Lesebreite.'; } public function preferredUnits(): int diff --git a/app/Domain/Cms/Widgets/Types/HeadingWidget.php b/app/Domain/Cms/Widgets/Types/HeadingWidget.php index a8b9fa3..1151a33 100644 --- a/app/Domain/Cms/Widgets/Types/HeadingWidget.php +++ b/app/Domain/Cms/Widgets/Types/HeadingWidget.php @@ -23,9 +23,14 @@ public function description(): string return 'Abschnittsüberschrift mit kurzem Einleitungstext.'; } - public function minUnits(): int + public function supportedUnits(): array { - return 1; + return [1, 2, 3, 4]; + } + + public function narrowBehavior(): string + { + return 'Überschriftengröße folgt der Platzbreite; lange Wörter werden getrennt.'; } public function preferredUnits(): int diff --git a/app/Domain/Cms/Widgets/Types/HeroWidget.php b/app/Domain/Cms/Widgets/Types/HeroWidget.php index 0722508..01b7ed7 100644 --- a/app/Domain/Cms/Widgets/Types/HeroWidget.php +++ b/app/Domain/Cms/Widgets/Types/HeroWidget.php @@ -3,17 +3,23 @@ namespace App\Domain\Cms\Widgets\Types; use App\Domain\Cms\Widgets\RenderContext; -use App\Domain\Cms\Widgets\Support\ImageFocus; use App\Domain\Cms\Widgets\Support\ImageRefFields; +use App\Domain\Cms\Widgets\Support\PremiumFields; use App\Domain\Cms\Widgets\Support\PublicMedia; -use App\Domain\Cms\Widgets\Support\SafeUrl; use App\Domain\Cms\Widgets\WidgetErrors; use App\Domain\Cms\Widgets\WidgetType; use Filament\Forms\Components\Textarea; use Filament\Forms\Components\TextInput; -use Filament\Schemas\Components\Grid; use Filament\Schemas\Components\Group; +/** + * Premium-Einstieg nach Brand-UI-Kit v1.6 (12_premium_widgets_adaptiv_v1.6, Komponente lf-hero). + * + * Version 2: Varianten photo_split und editorial_solid, Höhen compact/normal/large (Mindesthöhen ab 860 px + * Containerbreite), Label, Überschriftenebene, Bildfokus in Prozent, Akzent, zwei Schaltflächen. + * Die data-Schlüssel der Version 1 (heading, text, cta_*, alt) bleiben unverändert, damit ältere Revisionen und ein + * Code-Rollback darstellbar bleiben. + */ class HeroWidget extends WidgetType { public function key(): string @@ -28,27 +34,46 @@ public function label(): string public function description(): string { - return 'Großer Seiteneinstieg mit Überschrift, Beschreibung, optionalem Bild und bis zu zwei Schaltflächen. Als Markenbühne randlos über die volle Breite.'; + return 'Markenprägender Seiteneinstieg: großes Foto mit Textfläche oder dunkle Markenfläche, Überschrift, Beschreibung und bis zu zwei Schaltflächen.'; } - public function minUnits(): int + public function version(): int { return 2; } - public function preferredUnits(): int + public function supportedUnits(): array { - return 4; + return [3, 4]; } public function stages(): array { return [ - 'narrow' => 'unter 48rem Slotbreite: Bild über beziehungsweise unter dem Text', - 'wide' => 'ab 48rem: Bild neben dem Text, größere Überschrift; Markenbühne ab 56rem mit Text auf dem Bild', + 'wide' => 'ab 860 px Containerbreite: Foto über die ganze Fläche, Text links auf heller Fläche; Mindesthöhe nach Höheneinstellung', + 'safety' => 'unter 860 px nur technischer Sicherheitsumbruch: Foto 16:9 über dem Text, Schaltflächen ab 440 px untereinander', ]; } + public function narrowBehavior(): string + { + return 'Für breite Plätze (3 oder 4 Einheiten). Unter 860 px Containerbreite steht das Foto über dem Text; die Höhe richtet sich dann nach dem Inhalt.'; + } + + public function heights(): array + { + return [ + 'compact' => 'Kompakt (mind. 400 px)', + 'normal' => 'Normal (mind. 512 px)', + 'large' => 'Groß (mind. 640 px)', + ]; + } + + public function defaultHeight(): ?string + { + return 'normal'; + } + public function icon(): string { return 'heroicon-o-sparkles'; @@ -56,38 +81,64 @@ public function icon(): string public function schematic(): array { - return [[2, 3, 56, 30, 'line'], [6, 8, 26, 6, 'ink'], [6, 17, 24, 3, 'line'], [6, 24, 12, 5, 'accent'], [36, 7, 18, 22, 'image']]; + return [[2, 3, 56, 30, 'image'], [6, 8, 24, 6, 'ink'], [6, 16, 10, 2, 'accent'], [6, 21, 22, 3, 'line'], [6, 27, 12, 4, 'accent']]; } public function variants(): array { return [ - 'standard' => 'Standard (Bild neben dem Text)', - 'highlight' => 'Hervorgehoben (Markenfläche)', - 'stage' => 'Markenbühne (großes Bild, randlos)', - 'editorial' => 'Editorial (textbetont)', + 'photo_split' => 'Foto mit Textfläche', + 'editorial_solid' => 'Markenfläche (ohne Foto)', + ]; + } + + public function optionIcons(): array + { + return [ + 'variant' => ['photo_split' => 'heroicon-o-photo', 'editorial_solid' => 'heroicon-o-swatch'], + 'height' => ['compact' => 'heroicon-o-bars-2', 'normal' => 'heroicon-o-bars-3', 'large' => 'heroicon-o-bars-4'], ]; } public function settings(): array { return [ - 'focus' => ImageFocus::options(), - 'text_side' => ['left' => 'Links', 'right' => 'Rechts'], + 'heading_level' => PremiumFields::HEADING_LEVELS, + 'accent' => ['underline' => 'Gelbe Unterstreichung', 'rays' => 'Unterstreichung und Signalstrahlen', 'none' => 'Ohne Akzent'], ]; } public function settingLabels(): array { return [ - 'focus' => ['Bildausschnitt', 'Welcher Bildteil bei engen Zuschnitten sichtbar bleibt.'], - 'text_side' => ['Textseite (Markenbühne)', 'Auf welcher Seite der Text über dem Bild steht. Vorgabe: rechts.'], + 'heading_level' => ['Überschriftenebene', 'Der erste Einstieg einer Seite ist immer die Hauptüberschrift (H1).'], + 'accent' => ['Markenakzent', 'Freigegebene Akzente aus dem Brand-UI-Kit. Vorgabe: gelbe Unterstreichung.'], ]; } - public function bleeds(array $widget): bool + /** + * Version 1 (bis Designiteration 1) → 2: Varianten abbilden, früheren Fokuspunkt in Prozent umrechnen, + * nicht mehr vorhandene Einstellungen (focus, text_side) entfernen. Inhalte bleiben unverändert. + */ + public function upgrade(array $widget, int $from): array { - return ($widget['variant'] ?? null) === 'stage' && PublicMedia::isPublicPath($widget['refs']['image'] ?? null); + if ($from !== 1) { + return parent::upgrade($widget, $from); + } + + $widget['variant'] = in_array($widget['variant'] ?? null, ['highlight', 'editorial'], true) ? 'editorial_solid' : 'photo_split'; + $settings = is_array($widget['settings'] ?? null) ? $widget['settings'] : []; + $data = is_array($widget['data'] ?? null) ? $widget['data'] : []; + + if (! isset($data['focus_x'], $data['focus_y'])) { + $data = PremiumFields::focusFromEnum($settings['focus'] ?? null) + $data; + } + + unset($settings['focus'], $settings['text_side']); + $widget['settings'] = $settings; + $widget['data'] = $data; + + return $widget; } public function dataRules(): array @@ -95,12 +146,7 @@ public function dataRules(): array return [ 'heading' => ['required', 'string', 'max:200'], 'text' => ['nullable', 'string', 'max:600'], - 'cta_label' => ['nullable', 'string', 'max:80', 'required_with:data.cta_url'], - 'cta_url' => ['nullable', 'string', 'max:500', 'required_with:data.cta_label'], - 'cta2_label' => ['nullable', 'string', 'max:80', 'required_with:data.cta2_url'], - 'cta2_url' => ['nullable', 'string', 'max:500', 'required_with:data.cta2_label'], - 'alt' => ['nullable', 'string', 'max:300'], - ]; + ] + PremiumFields::rules(); } public function refRules(): array @@ -111,85 +157,57 @@ public function refRules(): array public function dataFields(): array { return [ - TextInput::make('heading')->label('Überschrift')->required()->maxLength(200), - Textarea::make('text')->label('Beschreibung')->rows(3)->maxLength(600), - Grid::make(2)->schema([ - TextInput::make('cta_label')->label('Schaltfläche: Beschriftung (optional)')->maxLength(80), - TextInput::make('cta_url') - ->label('Schaltfläche: Linkziel') - ->maxLength(500) - ->rule(SafeUrl::rule()) - ->requiredWith('cta_label'), - ]), - Grid::make(2)->schema([ - TextInput::make('cta2_label')->label('Zweite Schaltfläche: Beschriftung (optional)')->maxLength(80), - TextInput::make('cta2_url') - ->label('Zweite Schaltfläche: Linkziel') - ->maxLength(500) - ->rule(SafeUrl::rule()) - ->requiredWith('cta2_label'), - ]), - TextInput::make('alt') - ->label('Alternativtext des Bildes') - ->maxLength(300) - ->helperText('Pflicht, sobald ein Bild gewählt ist.'), + PremiumFields::eyebrowField(), + TextInput::make('heading')->label('Überschrift')->required()->maxLength(200)->live(onBlur: true), + Textarea::make('text')->label('Beschreibung')->rows(3)->maxLength(600)->live(onBlur: true), + PremiumFields::ctaFields(), + PremiumFields::altField(), + ...PremiumFields::focusFields(68, 50), ]; } public function refFields(): array { - return ImageRefFields::fields(); + return ImageRefFields::fields(live: true); } public function editorSchema(): array { - [$heading, $text, $cta, $cta2, $alt] = $this->dataFields(); + [$eyebrow, $heading, $text, $ctas] = $this->dataFields(); + + return [Group::make([$eyebrow, $heading, $text, $ctas])->statePath('data')]; + } + + public function mediaSchema(): array + { + [, , , , $alt, $focusX, $focusY] = $this->dataFields(); return [ - Group::make([$heading, $text, $cta, $cta2])->statePath('data'), Group::make($this->refFields())->statePath('refs'), - Group::make([$alt])->statePath('data'), + Group::make([$alt, $focusX, $focusY])->statePath('data'), ]; } public function clean(array $data, array $refs, WidgetErrors $errors): array { $refs = ImageRefFields::clean($refs, $errors); - - foreach (['text', 'cta_label', 'cta_url', 'cta2_label', 'cta2_url', 'alt'] as $key) { - $data[$key] = filled($data[$key] ?? null) ? trim($data[$key]) : null; - } - - foreach (['cta_url', 'cta2_url'] as $key) { - if ($data[$key] !== null && ! SafeUrl::isSafe($data[$key])) { - $errors->add("data.$key", SafeUrl::message()); - } - } - - if ($refs['image'] !== null && $data['alt'] === null) { - $errors->add('data.alt', 'Bitte einen Alternativtext für das Bild angeben.'); - } + $data['heading'] = trim((string) ($data['heading'] ?? '')); + $data['text'] = filled($data['text'] ?? null) ? trim((string) $data['text']) : null; + $data = PremiumFields::clean($data, $errors, $refs['image'] !== null); return [$data, $refs]; } public function resolve(array $widget, RenderContext $context): array { - $data = $widget['data']; - $actions = []; - - foreach ([['cta_label', 'cta_url'], ['cta2_label', 'cta2_url']] as [$label, $url]) { - if (filled($data[$label] ?? null) && SafeUrl::isSafe($data[$url] ?? null)) { - $actions[] = ['label' => $data[$label], 'url' => $data[$url]]; - } - } + $actions = PremiumFields::actions($widget['data']); return [ 'imageUrl' => PublicMedia::imageUrl($widget['refs']), - 'action' => $actions[0] ?? null, 'actions' => $actions, - 'focus' => ImageFocus::position($widget['settings'] ?? []), - 'textSide' => ($widget['settings']['text_side'] ?? null) === 'left' ? 'left' : 'right', + 'action' => $actions[0] ?? null, + 'focus' => PremiumFields::focus($widget['data'], 68, 50), + 'accent' => in_array($widget['settings']['accent'] ?? null, ['underline', 'rays', 'none'], true) ? $widget['settings']['accent'] : 'underline', ]; } diff --git a/app/Domain/Cms/Widgets/Types/ImageTextWidget.php b/app/Domain/Cms/Widgets/Types/ImageTextWidget.php index 4ca3909..98149e7 100644 --- a/app/Domain/Cms/Widgets/Types/ImageTextWidget.php +++ b/app/Domain/Cms/Widgets/Types/ImageTextWidget.php @@ -3,8 +3,8 @@ namespace App\Domain\Cms\Widgets\Types; use App\Domain\Cms\Widgets\RenderContext; -use App\Domain\Cms\Widgets\Support\ImageFocus; use App\Domain\Cms\Widgets\Support\ImageRefFields; +use App\Domain\Cms\Widgets\Support\PremiumFields; use App\Domain\Cms\Widgets\Support\PublicMedia; use App\Domain\Cms\Widgets\Support\RichText; use App\Domain\Cms\Widgets\WidgetErrors; @@ -14,10 +14,13 @@ use Filament\Schemas\Components\Group; /** - * Bild und Text. + * Bild und Text, Premium-Fassung nach Brand-UI-Kit v1.6 (Komponente lf-bild-text). * * Version 1 (Bestand): data {image, alt, body} mit Klartext. * Version 2: data {title, body (formatierter Text), alt}, refs {image}, Varianten Bild links/rechts. + * Version 3: zusätzlich Label, zwei Schaltflächen, Bildfokus in Prozent; Einstellungen Oberfläche, Höhe und + * Überschriftenebene. Die Bildseite bleibt die Variante (keine doppelte Einstellung). Die Einstellung + * format der Designiteration 1 entfällt; die Bildproportion folgt jetzt der Höhe. */ class ImageTextWidget extends WidgetType { @@ -33,12 +36,17 @@ public function label(): string public function description(): string { - return 'Bild neben formatiertem Text; Bild links oder rechts, auf dem Smartphone untereinander.'; + return 'Redaktionelle Bild-Text-Komposition mit Label, formatiertem Text und bis zu zwei Schaltflächen; passt sich der Platzbreite an.'; } - public function minUnits(): int + public function version(): int { - return 2; + return 3; + } + + public function supportedUnits(): array + { + return [1, 2, 3, 4]; } public function preferredUnits(): int @@ -49,14 +57,29 @@ public function preferredUnits(): int public function stages(): array { return [ - 'narrow' => 'unter 36rem Slotbreite: Bild über dem Text', - 'wide' => 'ab 36rem: Bild links oder rechts neben dem Text, gleich breit; ab 56rem Bild betont (7:5)', + 'stacked' => 'unter 540 px Containerbreite: Bild über dem Text, Schaltflächen untereinander in voller Breite', + 'band' => '540 bis 899 px: flacher Bildstreifen über dem vollständigen Text (typisch zwei Einheiten)', + 'wide' => 'ab 900 px: Bild und Text nebeneinander, Bild links oder rechts nach Variante', ]; } - public function version(): int + public function narrowBehavior(): string { - return 2; + return 'Unter 900 px Containerbreite steht das Bild über dem Text, unabhängig von „Bild links/rechts“; die gespeicherte Seite bleibt erhalten. Text und Schaltflächen werden nie gekürzt.'; + } + + public function heights(): array + { + return [ + 'compact' => 'Kompakt (flacheres Bild, engere Abstände)', + 'normal' => 'Normal', + 'spacious' => 'Großzügig (höheres Bild, mehr Abstand)', + ]; + } + + public function defaultHeight(): ?string + { + return 'normal'; } public function icon(): string @@ -66,7 +89,7 @@ public function icon(): string public function schematic(): array { - return [[4, 6, 22, 24, 'image'], [30, 7, 24, 4, 'ink'], [30, 15, 26, 3, 'line'], [30, 21, 22, 3, 'line']]; + return [[4, 6, 22, 24, 'image'], [30, 7, 10, 2, 'accent'], [30, 11, 24, 4, 'ink'], [30, 18, 26, 3, 'line'], [30, 24, 14, 4, 'accent']]; } public function variants(): array @@ -77,40 +100,64 @@ public function variants(): array ]; } + public function optionIcons(): array + { + return [ + 'variant' => ['image_left' => 'heroicon-o-arrow-left', 'image_right' => 'heroicon-o-arrow-right'], + 'height' => ['compact' => 'heroicon-o-bars-2', 'normal' => 'heroicon-o-bars-3', 'spacious' => 'heroicon-o-bars-4'], + ]; + } + public function settings(): array { return [ - 'format' => ['landscape' => 'Querformat (4:3)', 'portrait' => 'Hochformat (4:5)', 'square' => 'Quadrat', 'original' => 'Originalformat'], - 'focus' => ImageFocus::options(), + 'surface' => ['cream' => 'Creme (Markenfläche)', 'clear' => 'Ohne eigene Fläche', 'navy' => 'Navy (dunkel)'], + 'heading_level' => PremiumFields::HEADING_LEVELS, ]; } public function settingLabels(): array { return [ - 'format' => ['Bildformat', 'Zuschnitt des Bildes. Vorgabe: Querformat.'], - 'focus' => ['Bildausschnitt', 'Welcher Bildteil beim Zuschnitt sichtbar bleibt.'], + 'surface' => ['Hintergrund des Widgets', 'Unabhängig vom Abschnittshintergrund. „Ohne eigene Fläche“ übernimmt den Abschnitt.'], + 'heading_level' => ['Überschriftenebene', 'Steht das Widget als erstes auf der Seite, ist die Überschrift immer H1.'], ]; } public function upgrade(array $widget, int $from): array { - if ($from !== 1) { - return parent::upgrade($widget, $from); + if ($from === 1) { + $data = $widget['data']; + + $widget['data'] = [ + 'title' => null, + 'body' => RichText::fromPlainText(is_string($data['body'] ?? null) ? $data['body'] : ''), + 'alt' => $data['alt'] ?? null, + ]; + $widget['refs'] = [ + 'image' => PublicMedia::fromUploadState($data['image'] ?? null), + ]; + + return $widget; } - $data = $widget['data']; + if ($from === 2) { + // Designiteration 1 → Premium: Fokus in Prozent, Bildformat entfällt (Proportion folgt der Höhe). + $settings = is_array($widget['settings'] ?? null) ? $widget['settings'] : []; + $data = is_array($widget['data'] ?? null) ? $widget['data'] : []; - $widget['data'] = [ - 'title' => null, - 'body' => RichText::fromPlainText(is_string($data['body'] ?? null) ? $data['body'] : ''), - 'alt' => $data['alt'] ?? null, - ]; - $widget['refs'] = [ - 'image' => PublicMedia::fromUploadState($data['image'] ?? null), - ]; + if (! isset($data['focus_x'], $data['focus_y'])) { + $data = PremiumFields::focusFromEnum($settings['focus'] ?? null) + $data; + } - return $widget; + unset($settings['focus'], $settings['format']); + $widget['settings'] = $settings; + $widget['data'] = $data; + + return $widget; + } + + return parent::upgrade($widget, $from); } public function dataRules(): array @@ -118,8 +165,7 @@ public function dataRules(): array return [ 'title' => ['nullable', 'string', 'max:160'], 'body' => ['required', 'string', 'max:40000'], - 'alt' => ['nullable', 'string', 'max:300'], - ]; + ] + PremiumFields::rules(); } public function refRules(): array @@ -130,31 +176,38 @@ public function refRules(): array public function dataFields(): array { return [ - TextInput::make('title')->label('Titel (optional)')->maxLength(160), + PremiumFields::eyebrowField(), + TextInput::make('title')->label('Überschrift')->maxLength(160)->live(onBlur: true), RichEditor::make('body') ->label('Text') ->required() + ->live(onBlur: true) ->toolbarButtons(RichText::TOOLBAR), - TextInput::make('alt') - ->label('Alternativtext des Bildes') - ->maxLength(300) - ->helperText('Beschreibt, was auf dem Bild zu sehen ist. Pflicht, sobald ein Bild gewählt ist.'), + PremiumFields::ctaFields(), + PremiumFields::altField(), + ...PremiumFields::focusFields(64, 43), ]; } public function refFields(): array { - return ImageRefFields::fields(); + return ImageRefFields::fields(live: true); } public function editorSchema(): array { - [$title, $body, $alt] = $this->dataFields(); + [$eyebrow, $title, $body, $ctas] = $this->dataFields(); + + return [Group::make([$eyebrow, $title, $body, $ctas])->statePath('data')]; + } + + public function mediaSchema(): array + { + [, , , , $alt, $focusX, $focusY] = $this->dataFields(); return [ - Group::make([$title, $body])->statePath('data'), Group::make($this->refFields())->statePath('refs'), - Group::make([$alt])->statePath('data'), + Group::make([$alt, $focusX, $focusY])->statePath('data'), ]; } @@ -162,29 +215,26 @@ public function clean(array $data, array $refs, WidgetErrors $errors): array { $refs = ImageRefFields::clean($refs, $errors); $data['body'] = RichText::sanitize($data['body'] ?? ''); - $data['title'] = filled($data['title'] ?? null) ? trim($data['title']) : null; - $data['alt'] = filled($data['alt'] ?? null) ? trim($data['alt']) : null; + $data['title'] = filled($data['title'] ?? null) ? trim((string) $data['title']) : null; + $data = PremiumFields::clean($data, $errors, $refs['image'] !== null); if (RichText::isBlank($data['body'])) { $errors->add('data.body', 'Bitte einen Text eingeben.'); } - if ($refs['image'] !== null && $data['alt'] === null) { - $errors->add('data.alt', 'Bitte einen Alternativtext für das Bild angeben.'); - } - return [$data, $refs]; } public function resolve(array $widget, RenderContext $context): array { - $format = $widget['settings']['format'] ?? 'landscape'; + $surface = $widget['settings']['surface'] ?? 'cream'; return [ 'imageUrl' => PublicMedia::imageUrl($widget['refs']), 'body' => RichText::sanitize(is_string($widget['data']['body'] ?? null) ? $widget['data']['body'] : ''), - 'format' => in_array($format, ['landscape', 'portrait', 'square', 'original'], true) ? $format : 'landscape', - 'focus' => ImageFocus::position($widget['settings'] ?? []), + 'actions' => PremiumFields::actions($widget['data']), + 'focus' => PremiumFields::focus($widget['data'], 64, 43), + 'surface' => in_array($surface, ['cream', 'clear', 'navy'], true) ? $surface : 'cream', ]; } diff --git a/app/Domain/Cms/Widgets/Types/ProseWidget.php b/app/Domain/Cms/Widgets/Types/ProseWidget.php index ac17ff1..d62a15c 100644 --- a/app/Domain/Cms/Widgets/Types/ProseWidget.php +++ b/app/Domain/Cms/Widgets/Types/ProseWidget.php @@ -23,9 +23,14 @@ public function description(): string return 'Längerer Text in Absätzen. Eine Leerzeile beginnt einen neuen Absatz.'; } - public function minUnits(): int + public function supportedUnits(): array { - return 1; + return [1, 2, 3, 4]; + } + + public function narrowBehavior(): string + { + return 'Fließtext bricht um; Zeilen höchstens etwa 70 Zeichen.'; } public function preferredUnits(): int diff --git a/app/Domain/Cms/Widgets/WidgetRegistry.php b/app/Domain/Cms/Widgets/WidgetRegistry.php index dcc505f..f287097 100644 --- a/app/Domain/Cms/Widgets/WidgetRegistry.php +++ b/app/Domain/Cms/Widgets/WidgetRegistry.php @@ -45,8 +45,18 @@ public function register(WidgetType $type): void throw new InvalidArgumentException("Widget „{$key}“ braucht eine Schemaversion ab 1."); } - if ($type->minUnits() < 1 || $type->minUnits() > 4 || $type->preferredUnits() < $type->minUnits() || $type->preferredUnits() > 4) { - throw new InvalidArgumentException("Widget „{$key}“ braucht eine Mindest- und Vorzugsbreite zwischen 1 und 4 Rastereinheiten."); + // Gemeinsamer Layoutvertrag (ADR-38): Breiten, Vorzugsbreite und Höhen aus festen Wertebereichen. + $units = $type->supportedUnits(); + if ($units === [] || array_diff($units, [1, 2, 3, 4]) !== [] || $units !== array_values(array_unique($units)) || ! $type->supportsUnits($type->preferredUnits())) { + throw new InvalidArgumentException("Widget „{$key}“ braucht unterstützte Breiten zwischen 1 und 4 Rastereinheiten und eine darin enthaltene Vorzugsbreite."); + } + + if (array_diff(array_keys($type->heights()), array_keys(WidgetType::HEIGHTS)) !== []) { + throw new InvalidArgumentException("Widget „{$key}“ verwendet eine Höhe außerhalb des gemeinsamen Vokabulars."); + } + + if (array_key_exists('height', $type->settings())) { + throw new InvalidArgumentException("Widget „{$key}“ deklariert die Höhe über heights(), nicht über settings()."); } if ($type->variants() === []) { @@ -266,7 +276,7 @@ private function validateOne(WidgetType $type, array $widget, string $errorPrefi } $settings = []; - $allowedSettings = $type->settings(); + $allowedSettings = $type->settingOptions(); foreach ($widget['settings'] as $key => $value) { if ($value === null || $value === '') { continue; diff --git a/app/Domain/Cms/Widgets/WidgetRenderer.php b/app/Domain/Cms/Widgets/WidgetRenderer.php index 51308a0..c3d5840 100644 --- a/app/Domain/Cms/Widgets/WidgetRenderer.php +++ b/app/Domain/Cms/Widgets/WidgetRenderer.php @@ -46,16 +46,6 @@ public function renderAll(?array $blocks, RenderContext $context): HtmlString return new HtmlString($html); } - /** - * Ob die Instanz randlos dargestellt werden darf (siehe WidgetType::bleeds). - * - * @param array $widget aktuelle Hülle - */ - public function bleeds(array $widget): bool - { - return $this->registry->has((string) ($widget['type'] ?? '')) && $this->registry->get($widget['type'])->bleeds($widget); - } - /** * Rendert eine Instanz samt Abschnittshülle. Liefert '' wenn das Widget nichts darzustellen hat. * @@ -71,6 +61,7 @@ public function renderWidget(array $widget, RenderContext $context, bool $first 'refs' => $widget['refs'], 'variant' => $widget['variant'], 'settings' => $widget['settings'], + 'height' => $type->height($widget), 'first' => $first, 'context' => $context, ] + $type->resolve($widget, $context))->render()); @@ -81,7 +72,11 @@ public function renderWidget(array $widget, RenderContext $context, bool $first $id = is_string($widget['id'] ?? null) ? ' id="abschnitt-'.e($widget['id']).'"' : ''; - return '
' + // Gemeinsamer Layoutvertrag (ADR-38): Höhe als Klasse an der Hülle, nur wenn die Art Höhen anbietet. + $height = $type->height($widget); + $heightClass = $height !== null ? ' widget-height-'.e($height) : ''; + + return '
' .$inner .'
'; } diff --git a/app/Domain/Cms/Widgets/WidgetType.php b/app/Domain/Cms/Widgets/WidgetType.php index fc2b227..20bded9 100644 --- a/app/Domain/Cms/Widgets/WidgetType.php +++ b/app/Domain/Cms/Widgets/WidgetType.php @@ -35,12 +35,57 @@ public function version(): int } /** - * Kleinste Slotbreite in logischen Rastereinheiten (1 bis 4), in der das Widget auf dem Desktop lesbar bleibt. - * Ein schmalerer Slot wird beim Speichern abgewiesen. Auf Tablet und Smartphone stapeln die Slots ohnehin. + * Gemeinsames Höhenvokabular aller Widget-Arten (ADR-38). Eine Art bietet davon nur die sinnvollen Werte an + * (heights()). Die Höhe ist ein Gestaltungsparameter, nie eine Begrenzung: Inhalte erhalten immer den nötigen Platz. */ + public const HEIGHTS = [ + 'auto' => 'Automatisch', + 'compact' => 'Kompakt', + 'normal' => 'Normal', + 'large' => 'Groß', + 'spacious' => 'Großzügig', + 'fill' => 'Abschnittshöhe füllen', + ]; + + /** + * Gemeinsamer Layoutvertrag (ADR-38), Teil 1: zulässige Platzbreiten in logischen Rastereinheiten (1 bis 4). + * Ein Platz mit nicht unterstützter Breite wird beim Speichern abgewiesen. Auf Tablet und Smartphone stapeln die + * Plätze; dort bestimmt die tatsächliche Containerbreite die Darstellung (Container-Abfragen), nicht die Einheitenzahl. + * + * @return list + */ + public function supportedUnits(): array + { + return [1, 2, 3, 4]; + } + + public function supportsUnits(int $units): bool + { + return in_array($units, $this->supportedUnits(), true); + } + + /** Kleinste zulässige Platzbreite; abgeleitet aus supportedUnits(). */ public function minUnits(): int { - return 1; + return min($this->supportedUnits()); + } + + /** Lesbare Angabe der zulässigen Platzbreiten, zum Beispiel „1 bis 4“ oder „3 oder 4“. */ + public function unitsLabel(): string + { + $units = $this->supportedUnits(); + + if (count($units) === 1) { + return (string) $units[0]; + } + + if ($units === range(min($units), max($units)) && count($units) > 2) { + return min($units).' bis '.max($units); + } + + $last = array_pop($units); + + return implode(', ', $units).' oder '.$last; } /** Empfohlene Slotbreite in Rastereinheiten; Hinweis in der Widget-Auswahl. */ @@ -60,6 +105,42 @@ public function stages(): array return ['fluid' => 'passt sich fließend an jede Slotbreite an']; } + /** + * Gemeinsamer Layoutvertrag, Teil 2: angebotene Höhen (Schlüssel aus HEIGHTS => Bezeichnung im Editor). + * Leer: keine Höhenwahl, die Höhe folgt dem Inhalt. Der erste Eintrag ist die Vorgabe. + * + * @return array + */ + public function heights(): array + { + return []; + } + + public function defaultHeight(): ?string + { + $key = array_key_first($this->heights()); + + return $key === null ? null : (string) $key; + } + + /** + * Wirksame Höhe einer Instanz (gespeicherte Einstellung oder Vorgabe). + * + * @param array $widget + */ + public function height(array $widget): ?string + { + $height = $widget['settings']['height'] ?? null; + + return is_string($height) && array_key_exists($height, $this->heights()) ? $height : $this->defaultHeight(); + } + + /** Gemeinsamer Layoutvertrag, Teil 3: Verhalten bei reduziertem Platzangebot (Hinweis im Editor und in der Dokumentation). */ + public function narrowBehavior(): string + { + return 'Text bricht um, nichts wird abgeschnitten.'; + } + /** Heroicon-Name für Auswahl und Liste im Editor. */ public function icon(): string { @@ -114,14 +195,30 @@ public function settingLabels(): array } /** - * Ob die Instanz randlos über die volle Fensterbreite dargestellt wird, wenn sie allein in einem Abschnitt - * mit Raster „4“ steht (zum Beispiel die Markenbühne). Der Abschnitt verzichtet dann auf Innenabstand und Begrenzung. + * Alle zulässigen Einstellungen einschließlich der gemeinsamen Höhe. Registry-Prüfung, Editor und Darstellung + * verwenden ausschließlich diese Zusammenführung. * - * @param array $widget + * @return array> */ - public function bleeds(array $widget): bool + final public function settingOptions(): array { - return false; + $options = $this->settings(); + + if ($this->heights() !== []) { + $options['height'] = $this->heights(); + } + + return $options; + } + + /** + * Symbole für die visuelle Auswahl im Editor: 'variant' oder Einstellungsschlüssel => [Wert => Heroicon]. + * + * @return array> + */ + public function optionIcons(): array + { + return []; } /** @@ -164,6 +261,17 @@ public function refFields(): array * * @return list */ + /** + * Felder der Gruppe „Medien“ im Bearbeitungsdialog (Bild, Bildausschnitt, Alternativtext). Leer: keine eigene Gruppe; + * Verweise stehen dann mit im Inhalt (editorSchema()). + * + * @return list + */ + public function mediaSchema(): array + { + return []; + } + public function editorSchema(): array { $schema = []; diff --git a/app/Filament/Support/SectionEditor.php b/app/Filament/Support/SectionEditor.php index 6a1d686..1759d14 100644 --- a/app/Filament/Support/SectionEditor.php +++ b/app/Filament/Support/SectionEditor.php @@ -524,8 +524,8 @@ private static function slotLabel(array $state, ?int $index, mixed $layout): str $type = $items !== [] ? (array_values($items)[0]['type'] ?? null) : null; $registry = app(WidgetRegistry::class); - if ($registry->has($type) && $registry->get($type)->minUnits() > $slotUnits) { - $label .= ' · zu schmal: „'.$registry->get($type)->label().'“ braucht '.$registry->get($type)->minUnits(); + if ($registry->has($type) && ! $registry->get($type)->supportsUnits($slotUnits)) { + $label .= ' · passt nicht: „'.$registry->get($type)->label().'“ ist für '.$registry->get($type)->unitsLabel().' Einheiten vorgesehen'; } return $label; diff --git a/app/Filament/Support/WidgetEditor.php b/app/Filament/Support/WidgetEditor.php index 7fa301c..3d4d2e3 100644 --- a/app/Filament/Support/WidgetEditor.php +++ b/app/Filament/Support/WidgetEditor.php @@ -14,6 +14,12 @@ use Filament\Forms\Components\ToggleButtons; use Filament\Notifications\Notification; use Filament\Schemas\Components\Grid; +use Filament\Schemas\Components\Section; +use Filament\Schemas\Components\Tabs; +use Filament\Schemas\Components\Tabs\Tab; +use Filament\Schemas\Components\Text; +use Filament\Schemas\Components\Utilities\Get; +use Filament\Schemas\Components\View; use Illuminate\Foundation\Vite; use Illuminate\Support\HtmlString; use Illuminate\Support\Str; @@ -83,34 +89,69 @@ public static function slotBuilder(string $name = 'widget'): Builder public static function block(WidgetType $type): Block { - $variants = $type->variants(); + $icons = $type->optionIcons(); + $display = []; - $schema = [Hidden::make('id')]; - - $schema[] = count($variants) > 1 - ? ToggleButtons::make('variant') + if (count($type->variants()) > 1) { + $display[] = ToggleButtons::make('variant') ->label('Darstellung') - ->options($variants) + ->options($type->variants()) + ->icons($icons['variant'] ?? []) ->default($type->defaultVariant()) ->inline() ->required() - : Hidden::make('variant')->default($type->defaultVariant()); + ->live(); + } - if ($type->settings() !== []) { - $settings = []; - $labels = $type->settingLabels(); - foreach ($type->settings() as $key => $options) { - $settings[] = Select::make($key) + $settings = []; + $labels = $type->settingLabels(); + foreach ($type->settingOptions() as $key => $options) { + // Gemeinsame Höhe (ADR-38): immer als sichtbare Auswahl mit Vorgabe, nie als freie Eingabe. + $settings[] = $key === 'height' + ? ToggleButtons::make('height') + ->label('Höhe') + ->helperText('Gestaltungsparameter, keine Begrenzung: Längere Inhalte erhalten immer den nötigen Platz.') + ->options($options) + ->icons($icons['height'] ?? []) + ->default($type->defaultHeight()) + ->inline() + ->live() + : Select::make($key) ->label($labels[$key][0] ?? Str::headline($key)) ->helperText($labels[$key][1] ?? null) ->placeholder('Vorgabe der Darstellung') - ->options($options); - } - $schema[] = Grid::make(['default' => 1, 'md' => min(3, count($settings))])->schema($settings)->statePath('settings'); + ->options($options) + ->live(); } - foreach ($type->editorSchema() as $component) { - $schema[] = $component; + if ($settings !== []) { + $display[] = Grid::make(['default' => 1, 'md' => 2])->schema($settings)->statePath('settings'); + } + + $variantField = count($type->variants()) > 1 ? [] : [Hidden::make('variant')->default($type->defaultVariant())]; + $content = $type->editorSchema(); + $media = $type->mediaSchema(); + + if ($display === [] && $media === []) { + $schema = [Hidden::make('id'), ...$variantField, ...$content]; + } else { + $tabs = [Tab::make('Inhalt')->icon('heroicon-o-pencil-square')->schema($content)]; + if ($media !== []) { + $tabs[] = Tab::make('Medien')->icon('heroicon-o-photo')->schema($media); + } + if ($display !== []) { + $tabs[] = Tab::make('Darstellung')->icon('heroicon-o-adjustments-horizontal')->schema([ + ...$display, + Text::make('Platzbreiten: '.$type->unitsLabel().' Rastereinheiten. '.$type->narrowBehavior()), + ]); + } + + $schema = [ + Hidden::make('id'), + ...$variantField, + Tabs::make('Widget')->tabs($tabs)->contained(false), + self::livePreview($type), + ]; } return WidgetBlock::make($type->key()) @@ -238,6 +279,50 @@ public static function notifyErrors(array $errors, array $blocks): void ->send(); } + /** Logische Vorschaubreiten in px: tatsächliche Platzbreiten im Standardabschnitt bei 1440 px Fensterbreite. */ + public const PREVIEW_UNIT_WIDTHS = [1 => 310, 2 => 640, 3 => 960, 4 => 1300]; + + public const PREVIEW_PHONE_WIDTH = 390; + + /** + * Live-Vorschau im Bearbeitungsdialog: rendert den ungespeicherten Zustand mit derselben Ansicht wie die Website + * in einer wählbaren Platzbreite. Die Breitenwahl (_preview_width) wird nicht gespeichert. + */ + private static function livePreview(WidgetType $type): Section + { + $default = (string) self::PREVIEW_UNIT_WIDTHS[$type->preferredUnits()]; + $widths = [(string) self::PREVIEW_PHONE_WIDTH => 'Smartphone']; + foreach ($type->supportedUnits() as $units) { + $widths[(string) self::PREVIEW_UNIT_WIDTHS[$units]] = $units.' '.($units === 1 ? 'Einheit' : 'Einheiten'); + } + + return Section::make('Vorschau') + ->description('Änderungen erscheinen sofort. Unter 860 px zeigt der Einstieg den Sicherheitsumbruch, Bild und Text ab 900 px zwei Spalten.') + ->collapsible() + ->compact() + ->schema([ + ToggleButtons::make('_preview_width') + ->hiddenLabel() + ->options($widths) + ->default($default) + ->inline() + ->live() + ->dehydrated(false) + ->extraAttributes(['class' => 'luf-preview-width']), + View::make('filament.cms.widget-live-preview') + ->viewData(fn (Get $get): array => [ + 'html' => self::renderPreview($type->key(), [ + 'variant' => $get('variant'), + 'settings' => $get('settings'), + 'data' => $get('data'), + 'refs' => $get('refs'), + ]), + 'stylesheets' => self::previewStylesheets(), + 'width' => (int) ($get('_preview_width') ?: $default), + ]), + ]); + } + /** * Blockvorschau: dieselbe Widget-Ansicht wie öffentlich, aus dem ungespeicherten Zustand. * @@ -292,9 +377,9 @@ private static function pickerLabel(WidgetType $type): HtmlString private static function unitsHint(WidgetType $type): string { - return $type->minUnits() === 1 - ? 'Passt in jeden Platz' - : 'Braucht einen Platz ab '.$type->minUnits().' Rastereinheiten'; + return $type->supportedUnits() === [1, 2, 3, 4] + ? 'Passt in jeden Platz (1 bis 4 Einheiten)' + : 'Für Plätze mit '.$type->unitsLabel().' Rastereinheiten'; } /** diff --git a/docs/architektur/12_Entscheidungsprotokoll_ADR.md b/docs/architektur/12_Entscheidungsprotokoll_ADR.md index cc1ac5c..34aa5f3 100644 --- a/docs/architektur/12_Entscheidungsprotokoll_ADR.md +++ b/docs/architektur/12_Entscheidungsprotokoll_ADR.md @@ -58,6 +58,7 @@ ## Übersicht der Architekturentscheidungen | ADR-35 | Messung | Entwurf / Rechtsprüfung offen | Reichweitenmessung ohne Cookies als Vorschlag; Prüfung offen | | ADR-36 | Designsystem | Designprinzip fest; Tokens offen | Gemeinsame Design-Tokens für Website und Mitgliederbereich | | ADR-37 | n8n-Anbindung | Option / nicht beschlossen | n8n allenfalls für externe Kanäle, ohne direkten Datenbankzugang | +| ADR-38 | Layoutvertrag der Widgets | Umgesetzt auf Test (18.11.2026); UX-Abnahme offen | Zulässige Rasterbreiten, Höhen und Verhalten bei wenig Platz je Widget-Art in der bestehenden Registry; Darstellung nach realer Containerbreite | --- @@ -485,3 +486,16 @@ ## ADR-37 – Optionale externe Workflow-Anbindung **Alternativen.** Keine externe Workflow-Engine; n8n als allgemeine Produktsteuerung. **Folgen und offene Prüfung.** Umsetzung erst bei konkret nachgewiesenem Kanalbedarf. **Quelle.** Website-Zielkonzept §12; Website-CMS-Zielarchitektur §9, ADR-37-Tabelle. + +## ADR-38 – Gemeinsamer Layoutvertrag für Widget-Arten + +**Status am 18.11.2026:** Umgesetzt auf `develop`/Testinstanz (Branch `feature/adaptive-widgets`); **UX-Abnahme durch den Betreiber offen**. Ergänzt ADR-30, ersetzt es nicht. +**Kontext.** Das Abschnittsraster (vier logische Einheiten, ein Widget je Platz) verteilte Widgets bisher nur mit einer Mindestbreite. Das Brand-UI-Kit v1.6 (`12_premium_widgets_adaptiv_v1.6`) verlangt für die Premium-Widgets bestimmte Rasterbreiten (Einstieg 3–4, Bild und Text 1–4), Höhenvarianten und eine Darstellung nach realer Containerbreite. +**Entscheidung.** Jede Widget-Art erklärt in der bestehenden Registry (`WidgetType`) einen gemeinsamen Layoutvertrag: +- `supportedUnits()`: zulässige Platzbreiten aus 1–4; ein Platz mit anderer Breite wird beim Speichern mit verständlicher Meldung abgewiesen; `minUnits()` ist daraus abgeleitet. +- `heights()`: angebotene Höhen aus einem gemeinsamen Vokabular (`auto`, `compact`, `normal`, `large`, `spacious`, `fill`), gespeichert als `settings.height`, geprüft wie jede Einstellung; Höhen sind Mindestwerte oder Proportionen, nie Begrenzungen. +- `stages()` und `narrowBehavior()`: Darstellungsmodi und Verhalten bei reduziertem Platz, im Editor angezeigt. +Die Widget-Ansichten entscheiden über Container-Abfragen nach der tatsächlichen Breite, nicht nach der Einheitenzahl. Keine zweite Registry, kein zweites Abschnittsmodell, keine freien CSS-Werte. +**Alternativen.** Je Widget eigene Breitenlogik im Editor; feste Pixelhöhen; Höhe als Abschnittseinstellung (verworfen: doppelte, widersprüchliche Einstellmöglichkeit neben Abstand und Raster). +**Folgen und offene Prüfung.** Premium-Einstieg (`hero` Version 2) und Bild und Text (`image_text` Version 3) heben ältere Instanzen beim Lesen an; gespeicherte Revisionen bleiben unverändert. Ein Einstieg in einem Platz mit 2 Einheiten ist nicht mehr zulässig (vorher Mindestbreite 2; auf der Testinstanz kein Bestand betroffen). Bewusste Abweichungen vom Kit: Bildfokus als `data.focus_x/focus_y` (Einstellungen tragen nur Aufzählungswerte), Überschriftenebene „Automatisch/H2/H3“ statt freier H1 (genau eine H1 je Seite), Linkziele über die bestehende `SafeUrl`-Regel. Praktische Redaktionsabnahme (Bedienung, Bildzuschnitte mit freigegebenen Motiven) steht aus. +**Quelle.** Brand-UI-Kit v1.6 (`docs/Brand-UI-Kit/12_premium_widgets_adaptiv_v1.6`, `docs/layout-profiles.json`); `docs/architektur/cms-widget-registry.md` §§2, 4, 12; ADR-30, ADR-36. diff --git a/docs/architektur/cms-widget-registry.md b/docs/architektur/cms-widget-registry.md index 8229dd2..9e21e98 100644 --- a/docs/architektur/cms-widget-registry.md +++ b/docs/architektur/cms-widget-registry.md @@ -46,7 +46,7 @@ ## 2. Widget-Vertrag | `type` | Typkennung aus dem Register; ändert sich nie | | `v` | Schemaversion der Art | | `variant` | eine der für die Art registrierten Varianten | -| `settings` | nur registrierte Aufzählungswerte; freie Werte werden abgewiesen. Seit Designiteration 1: `hero` (`focus`, `text_side`), `image_text` (`format`, `focus`). Fehlt ein Wert, gilt die Vorgabe der Darstellung | +| `settings` | nur registrierte Aufzählungswerte (`WidgetType::settingOptions()`, einschließlich der gemeinsamen Höhe `height`); freie Werte werden abgewiesen. Fehlt ein Wert, gilt die Vorgabe der Darstellung | | `data` | redaktionelle Inhalte | | `refs` | Verweise auf Fachobjekte oder Medien, nur Kennungen bzw. Pfade im öffentlichen Bereich `cms/` | @@ -62,39 +62,52 @@ ## 3. Versionierung und Altbestand - Unbekannte Widget-Arten werden ausgelassen; unbekannte Raster- oder Gestaltungswerte fallen beim Lesen auf Vorgaben zurück. Eine Hülle mit höherer Version als im Code wird bestmöglich dargestellt, aber nicht gespeichert. - Regel: Optionale neue Felder brauchen keine neue Version. Umbenennen, Umdeuten oder Verschieben von Feldern braucht eine neue Version mit `upgrade()` und einen Test. Gleiches gilt für die Abschnittshülle (`PageSections::VERSION`). -Beispiel: `image_text` Version 1 `{image, alt, body (Klartext)}` → Version 2 `data {title, body (bereinigtes HTML), alt}`, `refs {image}`, Variante `image_left`. +Beispiele: +- `image_text` Version 1 `{image, alt, body (Klartext)}` → Version 2 `data {title, body (bereinigtes HTML), alt}`, `refs {image}`, Variante `image_left` → Version 3 (Kit v1.6): `settings.format` entfällt, `settings.focus` wird zu `data.focus_x/focus_y` (Prozent). +- `hero` Version 1 → Version 2 (Kit v1.6): Varianten `standard`/`stage` → `photo_split`, `highlight`/`editorial` → `editorial_solid`; `settings.focus` wird zu `data.focus_x/focus_y`, `settings.text_side` entfällt. Die data-Schlüssel (`heading`, `text`, `cta_*`, `alt`) bleiben, damit ein Code-Rollback darstellbar bleibt. ## 4. Registrierte Widget-Arten -| Kennung | Name | Version | Varianten | Verweise | Mindestbreite | -|---|---|---|---|---|---| -| `hero` | Einstieg (Hero) | 1 | `standard` (Bild neben dem Text), `highlight` (Markenfläche), `stage` (Markenbühne, randlos), `editorial` (textbetont) | `refs.image` | 2 | -| `heading` | Überschrift und Einleitung | 1 | `standard` | – | 1 | -| `prose` | Fließtext | 1 | `standard` | – | 1 | -| `image_text` | Bild und Text | 2 | `image_left`, `image_right` | `refs.image` | 2 | -| `cards` | Redaktionelle Karten | 1 | `standard` (Raster), `compact` (kompakte Liste), `featured` (erste Karte hervorgehoben) | Bild je Karte in `data.items[].image` | 1 | -| `catalog_cards` | Programm- und Modulkarten | 1 | `standard` (Karten mit Kurzbeschreibung), `compact` (Liste) | `refs.items[] = {type: composition, id}` | 1 | -| `call_to_action` | Handlungsaufruf | 1 | `standard` | – | 1 | -| `faq` | FAQ | 1 | `standard` | – | 2 | +| Kennung | Name | Version | Varianten | Breiten (Einheiten) | Höhen | Verweise | +|---|---|---|---|---|---|---| +| `hero` | Einstieg (Hero), Premium nach Kit v1.6 | 2 | `photo_split` (Foto mit Textfläche), `editorial_solid` (Navy-Markenfläche) | 3, 4 | `compact` (mind. 400 px), `normal` (512 px, Vorgabe), `large` (640 px) | `refs.image` | +| `heading` | Überschrift und Einleitung | 1 | `standard` | 1–4 | – | – | +| `prose` | Fließtext | 1 | `standard` | 1–4 | – | – | +| `image_text` | Bild und Text, Premium nach Kit v1.6 | 3 | `image_left`, `image_right` (Bildseite) | 1–4 | `compact`, `normal` (Vorgabe), `spacious` | `refs.image` | +| `cards` | Redaktionelle Karten | 1 | `standard` (Raster), `compact` (Liste), `featured` (erste Karte hervorgehoben) | 1–4 | – | Bild je Karte in `data.items[].image` | +| `catalog_cards` | Programm- und Modulkarten | 1 | `standard`, `compact` | 1–4 | – | `refs.items[] = {type: composition, id}` | +| `call_to_action` | Handlungsaufruf | 1 | `standard` | 1–4 | `auto` (Vorgabe), `fill` (Abschnittshöhe füllen) | – | +| `faq` | FAQ | 1 | `standard` | 2–4 | – | – | -Darstellungsklassen: `widget widget- widget-variant-` an der Widget-Hülle; je Ansicht eigene Klassen (`hero-highlight`, `hero-stage`, `image-text-right`, `image-format-portrait`, `cards-compact`, `cards-featured`, `catalog-cards-compact`). Die visuelle Veredelung verändert nur `resources/views/widgets/*` und `resources/css/widgets.css`, nicht Daten, Register oder Editor. +Darstellungsklassen an der Widget-Hülle: `widget widget- widget-variant-` und, wenn die Art Höhen anbietet, `widget-height-`. Premium-Ansichten: `lf-hero lf-hero--{photo-split|editorial-solid} lf-hero--height- lf-hero--accent-` und `lf-bt lf-bt--{cream|clear|navy} lf-bt--image-{left|right} lf-bt--height-`. -**Designiteration 1 (additiv, keine neue Version):** +**Premium-Widgets (Kit v1.6).** Ansichten `resources/views/widgets/hero.blade.php` und `image_text.blade.php`, Stylesheets `resources/css/components/lf-hero.css` und `lf-bild-text.css` (aus `12_premium_widgets_adaptiv_v1.6/components/*.v1.6.css` übernommen und angepasst; sie ersetzen das frühere Hero- und Bild-und-Text-CSS und werden nicht parallel geladen). Gemeinsame Felder in `App\Domain\Cms\Widgets\Support\PremiumFields`: -| Art | Neu | Gespeichert als | +| Feld | Gespeichert als | Hinweis | |---|---|---| -| `hero` | Varianten `stage`, `editorial`; zweite Schaltfläche; Bildausschnitt; Textseite der Markenbühne | `variant`; `data.cta2_label`, `data.cta2_url` (sicheres Linkziel wie `cta_url`); `settings.focus` (Werte wie Abschnittsfokus), `settings.text_side` (`left`, `right`) | -| `image_text` | Bildformat und Bildausschnitt | `settings.format` (`landscape`, `portrait`, `square`, `original`), `settings.focus` | -| `cards` | Variante `featured`; ganze Karte über den Titellink klickbar | `variant` | -| `catalog_cards` | Markentafel statt Bild, eine Karte breit mit Tafel daneben | keine Datenänderung | +| Label | `data.eyebrow` | höchstens 80 Zeichen | +| Überschrift | `data.heading` (Einstieg), `data.title` (Bild und Text) | | +| Beschreibung | `data.text` (Klartext, Einstieg), `data.body` (bereinigter formatierter Text, Bild und Text) | | +| Schaltflächen | `data.cta_label/cta_url`, `data.cta2_label/cta2_url` | Linkziele über `SafeUrl` | +| Bild, Alternativtext | `refs.image`, `data.alt` | öffentlicher Bereich `cms/`; Alternativtext Pflicht bei Bild | +| Bildfokus | `data.focus_x`, `data.focus_y` | ganze Zahlen 0–100; Vorgabe Einstieg 68/50, Bild und Text 64/43 | +| Überschriftenebene | `settings.heading_level` | `auto` (Vorgabe), `h2`, `h3`; das erste Widget der Seite ist immer H1 | +| Akzent (Einstieg) | `settings.accent` | `underline` (Vorgabe), `rays`, `none` | +| Fläche (Bild und Text) | `settings.surface` | `cream` (Vorgabe), `clear` (übernimmt den Abschnitt), `navy` | +| Höhe | `settings.height` | gemeinsamer Layoutvertrag (§12) | -Ältere Instanzen enthalten die neuen Schlüssel nicht und werden mit den Vorgaben dargestellt (Test `CmsDesignIterationTest`). Die erste Schaltfläche des Einstiegs ist jetzt die gelbe Markenschaltfläche (`button button-brand`). - -**Randlos (`WidgetType::bleeds`).** Eine Markenbühne mit Bild, die allein in ihrem Abschnitt steht, setzt am Abschnitt `section-bleed`: kein Innenabstand, keine Breitenbegrenzung, das Bild reicht über die ganze Fensterbreite; die Texttafel richtet sich am Standardraster aus. In mehrspaltigen Abschnitten erscheint dieselbe Bühne als Bild mit runden Ecken und überlappender Tafel. +**Abweichungen vom Kit (bewusst):** +- Kennungen bleiben `hero` und `image_text`, nicht `lf-brand-hero`/`lf-editorial-bild-text`; Varianten `photo_split`/`editorial_solid` mit Unterstrich, weil Variantenkennungen `^[a-z][a-z0-9_]*$` folgen. +- Bildseite von Bild und Text bleibt die Variante (`image_left/right`), nicht zusätzlich `settings.image_side`, damit es keine doppelte Einstellung gibt. +- Bildfokus in `data` statt `settings.image_focus`, weil Einstellungen nur Aufzählungswerte tragen. +- Überschriftenebene ohne frei wählbare H1 (Regel: genau eine H1 je Seite, erstes Widget). +- Linkziele: Seitenpfad, `#Anker`, `http` und `https` (bestehende `SafeUrl`-Regel); das Kit erlaubt nur `https`. +- Das Kit lädt das Einstiegsbild immer sofort; hier nur beim ersten Widget der Seite, alle anderen verzögert. +- Kit-CSS ergänzt: Überschriften erben Farbe (globale h1–h3-Regeln), Unterstreichung als Block, Fläche `clear` übernimmt die Farben dunkler Abschnitte, Strahlen-Akzent aus `components/brand/rays.blade.php`, Fokusfarbe aus den Tokens. ## 5. Neues Widget hinzufügen -1. Klasse unter `app/Domain/Cms/Widgets/Types/` anlegen, von `WidgetType` ableiten. Pflicht: `key()`, `label()`, `description()`, `dataRules()`, `dataFields()`. Je nach Bedarf: `variants()`, `minUnits()`/`preferredUnits()`/`stages()` (Abschnitt 12), `refRules()`, `refFields()`, `clean()` (Links mit `SafeUrl`, Text mit `RichText::sanitize`, Bilder mit `ImageRefFields::clean`), `resolve()`, `mediaPaths()`, `summary()`, `schematic()`, `icon()`. +1. Klasse unter `app/Domain/Cms/Widgets/Types/` anlegen, von `WidgetType` ableiten. Pflicht: `key()`, `label()`, `description()`, `dataRules()`, `dataFields()`. Je nach Bedarf: `variants()`, Layoutvertrag `supportedUnits()`/`preferredUnits()`/`heights()`/`stages()`/`narrowBehavior()` (Abschnitt 12), `settings()`/`settingLabels()`/`optionIcons()`, `mediaSchema()` für den Reiter „Medien“, `refRules()`, `refFields()`, `clean()` (Links mit `SafeUrl`, Text mit `RichText::sanitize`, Bilder mit `ImageRefFields::clean`), `resolve()`, `mediaPaths()`, `summary()`, `schematic()`, `icon()`. 2. Ansicht `resources/views/widgets/.blade.php` anlegen. Verfügbar: `$data`, `$refs`, `$variant`, `$settings`, `$first`, `$context` (Vorschau ja/nein) und die Rückgabe von `resolve()`. Kein `{!! !!}` außer für mit `RichText::sanitize` bereinigten Text. Breitenabhängige Regeln als Container-Abfrage `@container slot (…)`, nicht als Fenster-Medienabfrage; Farben nur über Bedeutungs-Tokens. 3. Klasse in `config/cms.php` unter `widgets` eintragen. 4. Tests ergänzen (Registrierung und Prüfregeln in `tests/Unit/WidgetRegistryTest.php`, Darstellung in `tests/Feature/CmsWidgetRenderingTest.php` bzw. `CmsSectionRenderingTest.php`). @@ -130,7 +143,9 @@ ## 8. Editor und Vorschau - **Raster**: grafische Auswahl mit sechs Kacheln. Raster mit weniger Plätzen als eingesetzten Widgets sind gesperrt. Beim Wechsel entfallen zuerst leere Plätze; Widgets behalten ihre Reihenfolge (`SectionEditor::arrangeSlots`). Kein Wechsel entfernt ein Widget. - **Gestaltung des Abschnitts** (eingeklappt, Zusammenfassung im Kopf): Hintergrund, Breite, Abstand, Trenner; bei Hintergrundbild zusätzlich Bild (Auswahl oder Upload), Fokuspunkt und Überlagerung. Abschnitts- und Widget-Einstellungen sind getrennt. - **Plätze** stehen im Verhältnis des Desktop-Rasters nebeneinander; Widgets lassen sich per Ziehen zwischen Plätzen tauschen. Der Platzkopf nennt Breite und warnt, wenn das Widget breiter sein müsste. Ein freier Platz bietet „Widget einsetzen“ (Auswahl mit Name, Beschreibung, Symbolbild, Mindestbreite), danach öffnet der Widget-Dialog. Ein Klick auf die Vorschau öffnet denselben Dialog: eine Dialogebene. -- **Widget-Vorschau**: dieselbe Ansicht wie öffentlich, im isolierten `iframe` mit dem Website-Stylesheet, in der tatsächlichen Platzbreite (Container-Abfragen greifen). Keine eigene Bildlaufleiste; über 22 rem wird gekürzt mit Hinweis „vollständig in der Seitenvorschau“. Die Abschnittsfläche zeigt erst die Seitenvorschau. +- **Widget-Dialog**: Arten mit Darstellungsoptionen oder Medien gliedern den Dialog in die Reiter **Inhalt**, **Medien** und **Darstellung** (generisch aus der Registry: `editorSchema()`, `mediaSchema()`, Varianten und `settingOptions()`); andere Arten zeigen ihre Felder direkt. Varianten und Höhen sind sichtbare Auswahlknöpfe mit Symbol, Bildfokus zwei Schieberegler (0–100). „Darstellung“ nennt die zulässigen Platzbreiten und das Verhalten bei wenig Platz. +- **Live-Vorschau im Dialog**: rendert den ungespeicherten Zustand mit derselben Ansicht wie die Website (`WidgetEditor::renderPreview`) in einer wählbaren logischen Platzbreite (Smartphone 390 px und die zulässigen Einheiten: 310/640/960/1300 px, entsprechend dem Standardabschnitt bei 1440 px Fensterbreite) und verkleinert sie auf die Dialogbreite. Die Breitenwahl wird nicht gespeichert. +- **Widget-Vorschau im Platz**: dieselbe Ansicht im isolierten `iframe` in der Breite des Platzes im Editor; über 28 rem gekürzt mit Hinweis „vollständig in der Seitenvorschau“. - „Entwurf speichern“ erzeugt eine Revision (bei unverändertem Stand keine weitere). „Veröffentlichen“ speichert zuerst den aktuellen Stand im Editor und veröffentlicht genau diesen; enthält er Fehler, wird nichts veröffentlicht. Vorher veröffentlichte „Veröffentlichen“ nur die zuletzt gespeicherte Revision, sodass übernommene, aber ungespeicherte Änderungen (etwa ein gewähltes Bild) verloren gingen. - Verlassen oder Neuladen mit ungespeicherten Änderungen löst eine Warnung des Browsers aus. - Ganzseitige Vorschau: `/redaktion/vorschau/{revision}/geraete` mit Umschaltern 390/768/1440 px; zeigt Kopfzeile, Navigation, Abschnitte, Flächen, Trenner und Fußbereich mit demselben Renderer wie die öffentliche Seite; `noindex`. @@ -172,6 +187,8 @@ ## 9. Rollback und Datenformat (wichtig vor dem Merge nach `main`) Die Migrationen (`sections`, `parent_id`) sind ergänzend und müssen beim Rollback nicht zurückgenommen werden; älterer Code ignoriert beide Spalten. +**Adaptive Widgets (ADR-38)** bringen keine Migration. Gespeichert werden ab jetzt `hero` Version 2 und `image_text` Version 3. Ein Code-Rollback auf Designiteration 1 stellt diese Hüllen „bestmöglich“ dar (höhere Version als im Code): unbekannte Varianten fallen auf die Vorgabe zurück, die data-Schlüssel sind unverändert; Höhe, Fläche, Label und Fokus werden nicht dargestellt, aber nicht gelöscht. Speichern im alten Editor ist für diese Hüllen nicht möglich, bis der neue Code wieder läuft. + **Designiteration 1** bringt keine Migration. Bei einem Code-Rollback auf Iteration 2 fallen die neuen Varianten beim Lesen auf die Vorgabe zurück (`stage`/`editorial` → `standard`, `featured` → `standard`); die neuen Einstellungen und `cta2_*` werden nicht dargestellt, aber nicht gelöscht. Seiten bleiben darstellbar; der Wiederherstellungsweg oben ist dafür nicht nötig. Ein reiner Code-Rollback ist nach redaktionellen Änderungen im neuen Editor **nicht** als sicher anzusehen; der Weg oben ist Teil jedes Rollbacks. ## 10. Navigation @@ -214,19 +231,26 @@ ## 11. Abschnitte und Plätze - **Erstes Widget** der Seite ist der Seiteneinstieg (Überschrift erster Ordnung); seitenweit genau eine. - **Grenzen**: höchstens 30 Abschnitte und 60 Widgets je Seite; keine Verschachtelung. -## 12. Responsive Widget-Regeln +## 12. Responsive Widget-Regeln und gemeinsamer Layoutvertrag (ADR-38) -Jede Widget-Art meldet `minUnits()` (kleinste zulässige Platzbreite auf dem Desktop), `preferredUnits()` (Hinweis) und `stages()` (Darstellungsstufen). Jeder Platz ist ein Container (`slot`); die Widget-Ansichten verwenden Container-Abfragen statt Fensterbreiten. +Jede Widget-Art erklärt in `WidgetType`: +- `supportedUnits()`: zulässige Platzbreiten (1–4); `minUnits()` ist daraus abgeleitet. Ein Platz mit anderer Breite wird beim Speichern abgewiesen („… ist für Plätze mit 3 oder 4 Rastereinheiten vorgesehen“); der Platzkopf im Editor warnt vorher („passt nicht“), die Widget-Auswahl nennt die zulässigen Breiten. +- `heights()`: angebotene Höhen aus `WidgetType::HEIGHTS` (`auto`, `compact`, `normal`, `large`, `spacious`, `fill`), gespeichert als `settings.height`; `defaultHeight()` gilt ohne Angabe. Höhen sind Mindesthöhen oder Proportionen, nie Begrenzungen. `fill` streckt das Widget auf die Höhe der Abschnittszeile, wenn Plätze nebeneinander stehen. +- `stages()` und `narrowBehavior()`: Darstellungsmodi nach Containerbreite und Verhalten bei wenig Platz. -| Widget | Mindestbreite | Vorzug | Stufen | +Jeder Platz ist ein Container (`slot`); die Premium-Widgets haben zusätzlich eigene Container (`lf-hero`, `lf-bt`). Entscheidend ist die tatsächliche Breite, nicht die Einheitenzahl. + +| Widget | Breiten | Höhen | Darstellung nach Containerbreite | |---|---|---|---| -| Einstieg (Hero) | 2 | 4 | unter 48 rem Bild unter dem Text; ab 48 rem nebeneinander; Überschrift wächst mit der Platzbreite. Markenbühne: unter 56 rem Bild 4:3 mit überlappender Tafel, ab 56 rem Bild über die ganze Bühne (30–46 rem hoch) mit Tafel links oder rechts. Editorial: ab 56 rem Beschreibung und Schaltflächen nebeneinander, Bild 21:9 | -| Überschrift | 1 | 4 | Größe folgt der Platzbreite | -| Fließtext | 1 | 2 | Zeilenlänge höchstens etwa 70 Zeichen | -| Bild und Text | 2 | 4 | unter 36 rem gestapelt; ab 36 rem Bild und Text gleich breit; ab 56 rem Bild betont (7:5); festes Bildformat nach Einstellung | -| Redaktionelle Karten | 1 | 4 | so viele Karten nebeneinander, wie bei 15 rem Kartenbreite passen; hervorgehobene erste Karte ab 44 rem mit Bild neben dem Text; kompakte Liste mit kleinem Bild rechts | -| Programm- und Modulkarten | 1 | 4 | ab 17 rem Kartenbreite mehrspaltig; eine einzelne Karte ab 40 rem mit Tafel neben dem Text; kompakte Liste für schmale Plätze | -| Handlungsaufruf | 1 | 2 | unter 20 rem Schaltfläche in voller Breite | -| FAQ | 2 | 4 | Fragen untereinander, Antworten auf Lesebreite | +| Einstieg (Hero) | 3, 4 | compact/normal/large | ab 860 px Foto über die Fläche, Text links, Mindesthöhe 400/512/640 px; darunter Sicherheitsumbruch: Foto 16:9 über dem Text, Höhe nach Inhalt; unter 440 px Schaltflächen untereinander | +| Bild und Text | 1–4 | compact/normal/spacious | unter 540 px gestapelt, Schaltflächen in voller Breite; 540–899 px flacher Bildstreifen (2,5 : 1 / 2,15 : 1 / 1,8 : 1) über dem Text; ab 900 px zweispaltig, Bild links oder rechts | +| Überschrift | 1–4 | – | Größe folgt der Platzbreite, lange Wörter werden getrennt | +| Fließtext | 1–4 | – | Zeilenlänge höchstens etwa 70 Zeichen, lange Adressen brechen um | +| Redaktionelle Karten | 1–4 | – | so viele Karten nebeneinander, wie bei 15 rem Kartenbreite passen; hervorgehobene Karte ab 44 rem mit Bild neben dem Text | +| Programm- und Modulkarten | 1–4 | – | ab 17 rem Kartenbreite mehrspaltig; eine einzelne Karte ab 40 rem mit Tafel neben dem Text | +| Handlungsaufruf | 1–4 | auto/fill | unter 20 rem Schaltfläche in voller Breite; Beschriftungen brechen um | +| FAQ | 2–4 | – | Fragen untereinander, Antworten auf Lesebreite | -Ableitung: Ein Platz mit einer Einheit ist bei Standardbreite auf dem Desktop etwa 17 rem (rund 276 px) breit. Bild-neben-Text und Einstieg sind darin nicht sinnvoll lesbar (zwei Spalten unter je 140 px); Karten, Fließtext und Aufrufe bleiben es. Ein zu schmaler Platz wird beim Speichern mit Abschnitt und Platz gemeldet; der Platzkopf im Editor zeigt „zu schmal“ bereits vorher. Auf Tablet und Smartphone stapeln die Plätze, dort gilt die Mindestbreite nicht. +Gemessene Platzbreiten im Standardabschnitt (82 rem) bei 1440 px Fensterbreite: 1 Einheit etwa 301–319 px, 2 Einheiten 638 px, 3 Einheiten 957 px, 4 Einheiten 1312 px. Bei 1200 px Fensterbreite hat ein Platz mit 3 Einheiten 807 px; der Einstieg zeigt dort den Sicherheitsumbruch. + +Ableitung: Bild und Text funktioniert dank gestapelter Darstellung auch in einer Einheit; der Einstieg braucht für seine Komposition mindestens etwa 860 px und ist deshalb nur für 3 oder 4 Einheiten freigegeben. Auf Tablet und Smartphone stapeln die Plätze; dort gelten die Breitenregeln nicht, die Widgets reagieren auf ihre Containerbreite. diff --git a/docs/architektur/designsystem.md b/docs/architektur/designsystem.md index 2b9192e..bc4a0fc 100644 --- a/docs/architektur/designsystem.md +++ b/docs/architektur/designsystem.md @@ -146,6 +146,19 @@ ## 12. Breitenmodell (Designiteration 1) | Standard | `--width-standard` | 82 rem | `standard` | Grundraster; Kopfzeile, Fußbereich und Inhalt fluchten hier | | Breit | `--width-wide` | 96 rem | `wide` | bildstarke Kompositionen | | Vollbreite | – | 100 % abzüglich Randabstand | `full` | Inhalt bis an den Rand | -| Randlos | – | 100 % | automatisch (`section-bleed`) | Markenbühne allein im Abschnitt | -Hintergründe reichen immer über die ganze Fensterbreite. `--frame-inset` = `max(Randabstand, (100 % − Standard) / 2)` richtet Inhalte in randlosen Flächen (Tafel der Markenbühne) am Standardraster aus, ohne `100vw` (kein Scrollbalkenfehler). Die Schlüssel der Abschnittsbreiten sind gespeicherte Daten und bleiben unverändert; nur die Werte wurden angepasst (vorher 45/75/90 rem). +Hintergründe reichen immer über die ganze Fensterbreite. `--frame-inset` = `max(Randabstand, (100 % − Standard) / 2)` steht für Inhalte in fensterbreiten Flächen bereit, ohne `100vw` (kein Scrollbalkenfehler). Die randlose Markenbühne der Designiteration 1 ist mit Kit v1.6 entfallen; der Premium-Einstieg ist eine Karte im Abschnitt. Die Schlüssel der Abschnittsbreiten sind gespeicherte Daten und bleiben unverändert; nur die Werte wurden angepasst (vorher 45/75/90 rem). + +## 13. Premium-Widgets (Brand-UI-Kit v1.6, ADR-38) + +Einstieg und Bild und Text verwenden die Komponenten aus `docs/Brand-UI-Kit/12_premium_widgets_adaptiv_v1.6`, übernommen nach `resources/css/components/lf-hero.css` und `lf-bild-text.css` (über `app.css` geladen; das frühere Hero- und Bild-und-Text-CSS ist entfernt). Die Kit-Variablen `--lf-font-display`, `--lf-font-ui` und `--lf-muted` zeigen in `tokens.css` auf die gemeinsamen Werte. Nunito wird zusätzlich in Stärke 900 lokal ausgeliefert (Überschrift des Einstiegs). + +| Paar | Kontrast | +|---|---| +| Label `#17370b` auf `#dff0c0` (Einstieg) | 10,9 : 1 | +| Weiß auf Grün dunkel (Schaltflächen) | 5,22 : 1 | +| Navy auf Creme / Weiß auf Navy (Flächen) | 14,0 / 15,1 : 1 | +| Fließtext `#46556b` auf Creme (Bild und Text) | 7,0 : 1 | +| Label `#295b08` auf Creme; `#fff2b0` auf Navy | 7,5 / 13,4 : 1 | + +Bildmotive des Kits (`09_hero_widget/assets`, `10_bild_text_widget/assets`) sind für die öffentliche Verwendung nicht freigegeben; sie wurden nur lokal für die Sichtprüfung verwendet. diff --git a/resources/css/app.css b/resources/css/app.css index bfede86..4bc6f44 100644 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -10,6 +10,9 @@ @import './site.css'; @import './sections.css'; @import './widgets.css'; +/* Premium-Widgets nach Brand-UI-Kit v1.6; ersetzen das frühere Hero- und Bild-und-Text-CSS. */ +@import './components/lf-hero.css'; +@import './components/lf-bild-text.css'; /* * Mitgliederbereich: eigene Anwendungsoberfläche mit eigener Navigation. Er verwendet die gemeinsamen diff --git a/resources/css/components.css b/resources/css/components.css index e72f223..e380afd 100644 --- a/resources/css/components.css +++ b/resources/css/components.css @@ -29,6 +29,9 @@ .ui-button { font: inherit; font-weight: 700; line-height: 1.2; + max-width: 100%; + text-align: center; + overflow-wrap: anywhere; text-decoration: none; cursor: pointer; transition: background-color 0.15s ease, border-color 0.15s ease; diff --git a/resources/css/components/lf-bild-text.css b/resources/css/components/lf-bild-text.css new file mode 100644 index 0000000..ce3ead0 --- /dev/null +++ b/resources/css/components/lf-bild-text.css @@ -0,0 +1,226 @@ +/* + * Premium-Bild-und-Text – übernommen aus docs/Brand-UI-Kit/12_premium_widgets_adaptiv_v1.6/components/lf-bild-text.v1.6.css. + * Ersetzt das bisherige Bild-und-Text-CSS (nicht parallel laden). Die Darstellung folgt der tatsächlichen + * Containerbreite, nicht der Einheitenzahl. + * + * Anpassungen an das Repository: + * - Oberfläche „clear“ übernimmt die Bedeutungswerte des Abschnitts (auch auf dunklen Abschnitten lesbar). + * - Überschrift erbt Farbe und Schrift (globale h1–h3-Regeln setzen sonst Navy). + * - Fokusfarbe aus den Tokens; Schriften über --lf-font-display und --lf-font-ui. + */ +.lf-bt-host { container: lf-bt / inline-size; inline-size: 100%; min-inline-size: 0; max-inline-size: 100%; } +.lf-bt-host, .lf-bt-host * { box-sizing: border-box; } + +.lf-bt { + --bt-navy: var(--lf-navy, #032551); + --bt-green: var(--lf-green-deep, #3b7b09); + --bt-yellow: var(--lf-yellow, #fcd10a); + --bt-cream: var(--lf-cream, #f7f6f2); + --bt-muted: var(--lf-muted, #46556b); + --bt-eyebrow: #295b08; + --bt-focus-x: 64%; + --bt-focus-y: 43%; + --color-focus: var(--lf-focus); + display: grid; + grid-template-columns: minmax(0, 1fr); + align-items: start; + gap: clamp(0.9rem, 2.65cqi, 2rem); + padding: clamp(1rem, 2.8cqi, 3.25rem); + border-radius: clamp(1rem, 1.8cqi, 1.65rem); + min-inline-size: 0; + max-inline-size: 100%; + background: var(--bt-cream); + color: var(--bt-navy); + font: 400 1rem/1.6 var(--lf-font-ui); + overflow-wrap: break-word; +} + +.lf-bt--navy { + --bt-muted: #f0f4f9; + --bt-eyebrow: #fff2b0; + --color-focus: var(--lf-yellow); + background: var(--bt-navy); + color: #fff; +} + +/* Ohne eigene Fläche: Farben des Abschnitts (hell, dunkel, Markenakzent). */ +.lf-bt--clear { + --bt-muted: var(--color-text-muted); + --bt-eyebrow: var(--color-heading); + --color-focus: inherit; + background: transparent; + color: var(--color-heading); + padding-inline: 0; +} + +.lf-bt__copy { min-inline-size: 0; max-inline-size: 49rem; align-self: center; } + +.lf-bt__eyebrow { + display: flex; + align-items: center; + gap: 0.6rem; + margin: 0 0 0.8rem; + color: var(--bt-eyebrow); + font-size: 0.73rem; + line-height: 1.45; + font-weight: 800; + letter-spacing: 0.065em; + text-transform: uppercase; + overflow-wrap: anywhere; +} + +.lf-bt__eyebrow::before { + content: ''; + flex: 0 0 auto; + inline-size: 1.35rem; + block-size: 0.25rem; + background: var(--bt-yellow); + border-radius: 999px; +} + +.lf-bt__headline { + margin: 0; + color: inherit; + font-family: var(--lf-font-display); + font-size: clamp(1.55rem, 4.5cqi, 3.35rem); + line-height: 1.14; + letter-spacing: -0.03em; + font-weight: 850; + overflow-wrap: anywhere; + hyphens: manual; + text-wrap: balance; +} + +.lf-bt__accent { + display: block; + inline-size: clamp(4.6rem, 12cqi, 7rem); + block-size: 0.36rem; + margin: clamp(0.55rem, 1.7cqi, 1rem) 0 clamp(0.8rem, 2.3cqi, 1.25rem) 0.12rem; + background: var(--bt-yellow); + border-radius: 90% 35% 75% 40%; + transform: rotate(-1deg); +} + +.lf-bt__body { color: var(--bt-muted); font-size: clamp(0.97rem, 1.45cqi, 1.12rem); line-height: 1.62; overflow-wrap: anywhere; } +.lf-bt__body > :first-child { margin-block-start: 0; } +.lf-bt__body > :last-child { margin-block-end: 0; } +.lf-bt__body p { margin: 0 0 0.9em; } +.lf-bt__body ul, +.lf-bt__body ol { padding-inline-start: 1.35em; margin: 0.6em 0; } +.lf-bt__body a { color: inherit; text-decoration: underline; text-underline-offset: 0.15em; } + +.lf-bt__actions { display: flex; flex-wrap: wrap; align-items: stretch; gap: 0.65rem; margin-block-start: clamp(1rem, 2cqi, 1.5rem); min-inline-size: 0; } + +.lf-bt__button { + display: inline-flex; + align-items: center; + justify-content: center; + gap: 0.5rem; + max-inline-size: 100%; + min-inline-size: 0; + min-block-size: 2.95rem; + padding: 0.7rem 1rem; + background: var(--bt-green); + border: 2px solid var(--bt-green); + color: #fff; + border-radius: 999px; + text-decoration: none; + text-align: center; + font-size: 0.89rem; + font-weight: 800; + line-height: 1.33; + overflow-wrap: anywhere; + white-space: normal; + transition: background-color 0.14s ease, transform 0.14s ease; +} + +.lf-bt__button:visited { color: #fff; } +.lf-bt__button:hover { background: #285a06; color: #fff; transform: translateY(-1px); } +.lf-bt__button--secondary, +.lf-bt__button--secondary:visited { background: transparent; border-color: currentColor; color: inherit; } +.lf-bt__button--secondary:hover { background: rgb(3 37 81 / 6%); color: inherit; } +.lf-bt--navy .lf-bt__button--secondary:hover, +.scope-dark .lf-bt--clear .lf-bt__button--secondary:hover, +.scope-accent .lf-bt--clear .lf-bt__button--secondary:hover { background: rgb(255 255 255 / 12%); } +.lf-bt__button:focus-visible, +.lf-bt__body a:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 3px; } + +.lf-bt__media { position: relative; display: block; order: -1; min-inline-size: 0; isolation: isolate; } + +.lf-bt__media::before { + content: ''; + position: absolute; + inset: auto -0.42rem -0.45rem 1rem; + z-index: -1; + block-size: 53%; + border-radius: 1.1rem; + background: #8ab848; + transform: rotate(1.5deg); +} + +.lf-bt--navy .lf-bt__media::before { background: var(--bt-yellow); } + +.lf-bt__image { + display: block; + inline-size: 100%; + max-inline-size: none; + block-size: auto; + aspect-ratio: 16 / 10; + object-fit: cover; + object-position: var(--bt-focus-x) var(--bt-focus-y); + border-radius: clamp(0.78rem, 1.8cqi, 1.3rem); + box-shadow: 0 10px 28px rgb(3 37 81 / 11%); +} + +.lf-bt--height-compact .lf-bt__image { aspect-ratio: 16 / 9; } +.lf-bt--height-spacious .lf-bt__image { aspect-ratio: 4 / 3; } +.lf-bt--height-compact { gap: clamp(0.75rem, 2cqi, 1.45rem); } +.lf-bt--height-spacious { gap: clamp(1.15rem, 3.4cqi, 2.7rem); } +.lf-bt--without-image { grid-template-columns: minmax(0, 1fr); } + +/* Schmale Plätze: vollständiger Text und Links, keine erzwungene Höhe. */ +@container lf-bt (max-width: 539.99px) { + .lf-bt__actions { display: grid; grid-template-columns: minmax(0, 1fr); } + .lf-bt__button { inline-size: 100%; } + .lf-bt__headline { font-size: clamp(1.42rem, 6.8cqi, 2.2rem); } + .lf-bt__eyebrow { letter-spacing: 0.03em; } +} + +/* Mittlere Containerbreite (meist zwei Einheiten): flacher Bildstreifen statt gequetschter Zweispaltigkeit. */ +@container lf-bt (min-width: 540px) and (max-width: 899.99px) { + .lf-bt { gap: clamp(0.8rem, 1.6cqi, 1.2rem); padding: clamp(1.1rem, 2.4cqi, 1.65rem); } + .lf-bt--clear { padding-inline: 0; } + .lf-bt__media { inline-size: 100%; } + .lf-bt__image { aspect-ratio: 2.15 / 1; } + .lf-bt--height-compact .lf-bt__image { aspect-ratio: 2.5 / 1; } + .lf-bt--height-spacious .lf-bt__image { aspect-ratio: 1.8 / 1; } + .lf-bt__headline { font-size: clamp(1.65rem, 3.6cqi, 2.28rem); } + .lf-bt__body { font-size: 1.01rem; line-height: 1.59; } + .lf-bt__actions { margin-block-start: 0.95rem; } + .lf-bt__button { flex: 1 1 13rem; } +} + +/* Breiter Container: zweispaltige Komposition, Bild links oder rechts. */ +@container lf-bt (min-width: 900px) { + .lf-bt { + grid-template-columns: minmax(0, 1.02fr) minmax(0, 0.98fr); + align-items: center; + gap: clamp(1.8rem, 4cqi, 4.5rem); + padding: clamp(1.8rem, 4cqi, 4.5rem); + } + + .lf-bt--clear { padding-inline: 0; } + .lf-bt__media { order: 0; align-self: stretch; } + .lf-bt--image-left .lf-bt__media { order: -1; } + .lf-bt__image { block-size: 100%; min-block-size: 18rem; aspect-ratio: 4 / 3; } + .lf-bt--height-compact .lf-bt__image { min-block-size: 14rem; aspect-ratio: 3 / 2; } + .lf-bt--height-spacious .lf-bt__image { min-block-size: 24rem; aspect-ratio: 1 / 1; } + .lf-bt--height-compact { padding-block: clamp(1.25rem, 2.8cqi, 2.6rem); } + .lf-bt--height-spacious { padding-block: clamp(2.15rem, 4.5cqi, 4.75rem); } + .lf-bt--without-image { grid-template-columns: minmax(0, 1fr); } +} + +@media (prefers-reduced-motion: reduce) { + .lf-bt__button { transition: none; } + .lf-bt__button:hover { transform: none; } +} diff --git a/resources/css/components/lf-hero.css b/resources/css/components/lf-hero.css new file mode 100644 index 0000000..60ee795 --- /dev/null +++ b/resources/css/components/lf-hero.css @@ -0,0 +1,209 @@ +/* + * Premium-Einstieg – übernommen aus docs/Brand-UI-Kit/12_premium_widgets_adaptiv_v1.6/components/lf-hero.v1.6.css. + * Ersetzt das bisherige Hero-CSS (nicht parallel laden). + * + * Anpassungen an das Repository (dokumentiert in docs/architektur/cms-widget-registry.md): + * - Überschrift und Akzent erben Farbe und erhalten Blockdarstellung (die globalen h1–h3-Regeln setzen sonst Navy). + * - Akzentwahl underline/rays/none; Strahlen aus resources/views/components/brand/rays.blade.php. + * - Fokusfarbe und Schriften über die gemeinsamen Tokens (--lf-font-display, --lf-font-ui, --color-focus). + * Die Höhen sind Mindesthöhen ab 860 px Containerbreite; Inhalte vergrößern jede Variante. + */ +.lf-hero-host { container: lf-hero / inline-size; inline-size: 100%; min-inline-size: 0; max-inline-size: 100%; } +.lf-hero-host, .lf-hero-host * { box-sizing: border-box; } + +.lf-hero { + --lf-hero-navy: var(--lf-navy, #032551); + --lf-hero-green: var(--lf-green-deep, #3b7b09); + --lf-hero-yellow: var(--lf-yellow, #fcd10a); + --lf-hero-cream: var(--lf-cream, #f7f6f2); + --lf-hero-focus-x: 68%; + --lf-hero-focus-y: 50%; + --color-focus: var(--lf-focus); + isolation: isolate; + position: relative; + display: grid; + align-items: center; + min-inline-size: 0; + min-block-size: 32rem; + max-inline-size: 100%; + border-radius: clamp(1rem, 1.9cqi, 1.75rem); + background: var(--lf-hero-cream); + color: var(--lf-hero-navy); + font-family: var(--lf-font-display); +} + +.lf-hero--height-compact { min-block-size: 25rem; } +.lf-hero--height-normal { min-block-size: 32rem; } +.lf-hero--height-large { min-block-size: 40rem; } + +.lf-hero__photo { + position: absolute; + inset: 0; + z-index: -2; + inline-size: 100%; + block-size: 100%; + max-inline-size: none; + object-fit: cover; + object-position: var(--lf-hero-focus-x) var(--lf-hero-focus-y); + border-radius: inherit; +} + +.lf-hero--photo-split::before { + content: ''; + position: absolute; + inset: 0; + z-index: -1; + border-radius: inherit; + background: linear-gradient(90deg, rgb(250 249 243 / 99%) 0%, rgb(250 249 243 / 98%) 28%, rgb(250 249 243 / 85%) 41%, rgb(250 249 243 / 12%) 69%, transparent 80%); +} + +.lf-hero--editorial-solid { + --color-focus: var(--lf-yellow); + background: var(--lf-hero-navy); + color: #fff; +} + +.lf-hero--editorial-solid::before { + content: ''; + position: absolute; + inset: auto -7% -50% auto; + z-index: -1; + inline-size: 40%; + aspect-ratio: 1; + background: var(--lf-hero-green); + border-radius: 50%; + opacity: 0.8; +} + +.lf-hero--editorial-solid { overflow: hidden; } + +.lf-hero__inner { + inline-size: 100%; + max-inline-size: 1440px; + min-inline-size: 0; + margin-inline: auto; + padding: clamp(1.8rem, 4.3cqi, 5rem); + padding-block: clamp(2.1rem, 5cqi, 5rem); +} + +.lf-hero__copy { position: relative; max-inline-size: min(660px, 58%); min-inline-size: 0; } +.lf-hero--editorial-solid .lf-hero__copy { max-inline-size: 760px; } + +.lf-hero__eyebrow { + display: inline-block; + margin: 0; + padding: 0.35em 0.75em; + border-radius: 999px; + background: #dff0c0; + color: #17370b; + font-weight: 800; + font-size: clamp(0.78rem, 1.25cqi, 0.95rem); + overflow-wrap: anywhere; +} + +.lf-hero__title { + margin: 0.25em 0; + color: inherit; + font-family: inherit; + font-size: clamp(2.1rem, 5.4cqi, 4.9rem); + line-height: 1.06; + letter-spacing: -0.035em; + font-weight: 900; + text-wrap: balance; + overflow-wrap: anywhere; + hyphens: manual; +} + +.lf-hero__title-accent { + display: block; + inline-size: clamp(6rem, 15cqi, 15rem); + block-size: 0.42rem; + margin: 0 0 clamp(1.1rem, 2cqi, 1.5rem); + background: var(--lf-hero-yellow); + border-radius: 90% 30% 45% 25%; + transform: rotate(-1deg); +} + +.lf-hero__rays { + position: absolute; + inset-block-start: -2.4rem; + inset-inline-start: -2.2rem; + inline-size: clamp(2.6rem, 4.5cqi, 3.6rem); + color: var(--lf-hero-yellow); + transform: rotate(-24deg); + pointer-events: none; +} + +.lf-hero__description { + max-inline-size: 56ch; + margin: 0 0 clamp(1.25rem, 2.1cqi, 2rem); + font-family: var(--lf-font-ui); + font-size: clamp(1.05rem, 1.7cqi, 1.3rem); + line-height: 1.5; + overflow-wrap: anywhere; +} + +.lf-hero__actions { display: flex; flex-wrap: wrap; align-items: stretch; gap: 0.75rem; min-inline-size: 0; } + +.lf-hero__button { + display: inline-flex; + align-items: center; + justify-content: center; + min-inline-size: 0; + max-inline-size: 100%; + min-block-size: 3rem; + padding: 0.77rem 1.2rem; + border: 2px solid transparent; + border-radius: 999px; + font: 800 0.96rem/1.28 var(--lf-font-ui); + text-decoration: none; + text-align: center; + white-space: normal; + overflow-wrap: anywhere; + transition: transform 0.15s ease, background-color 0.15s ease; +} + +.lf-hero__button:hover { transform: translateY(-1px); } +.lf-hero__button:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 3px; } +.lf-hero__button--primary, +.lf-hero__button--primary:visited { background: var(--lf-hero-green); color: #fff; } +.lf-hero__button--primary:hover { background: #285a06; color: #fff; } +.lf-hero__button--secondary, +.lf-hero__button--secondary:visited { background: rgb(255 255 255 / 95%); color: var(--lf-hero-navy); border-color: var(--lf-hero-navy); } +.lf-hero__button--secondary:hover { color: var(--lf-hero-navy); } + +.lf-hero__bottom { + position: absolute; + inset: auto 0 0; + block-size: 15px; + border-radius: 0 0 1.5rem 1.5rem; + background: linear-gradient(105deg, var(--lf-hero-yellow) 0%, var(--lf-hero-yellow) 22%, var(--lf-hero-green) 72%); + clip-path: polygon(0 45%, 30% 90%, 65% 75%, 100% 0, 100% 100%, 0 100%); + pointer-events: none; +} + +/* Sicherheitsumbruch, wenn der Container physisch zu schmal ist; keine eigene redaktionelle Variante. */ +@container lf-hero (max-width: 859.99px) { + .lf-hero { display: block; min-block-size: 0; } + .lf-hero--height-compact, + .lf-hero--height-normal, + .lf-hero--height-large { min-block-size: 0; } + .lf-hero__photo { position: relative; display: block; block-size: auto; aspect-ratio: 16 / 9; } + .lf-hero--photo-split::before { display: none; } + .lf-hero__inner { padding: clamp(1.2rem, 3.5cqi, 2rem); padding-block-end: 2.4rem; } + .lf-hero__copy { max-inline-size: 100%; } + .lf-hero__title { font-size: clamp(2rem, 5.5cqi, 3.1rem); } + .lf-hero__description { font-size: 1.07rem; } + .lf-hero--editorial-solid .lf-hero__copy { max-inline-size: 100%; } + .lf-hero__rays { inset-block-start: -1.6rem; inset-inline-start: auto; inset-inline-end: 0; transform: rotate(10deg); } +} + +@container lf-hero (max-width: 440px) { + .lf-hero__actions { display: grid; grid-template-columns: minmax(0, 1fr); } + .lf-hero__button { inline-size: 100%; } +} + +@media (prefers-reduced-motion: reduce) { + .lf-hero__button { transition: none; } + .lf-hero__button:hover { transform: none; } +} diff --git a/resources/css/tokens.css b/resources/css/tokens.css index c9a4820..8e1731b 100644 --- a/resources/css/tokens.css +++ b/resources/css/tokens.css @@ -71,6 +71,11 @@ :root { --color-theme-4: var(--color-surface-subtle); --color-theme-5: var(--color-surface-subtle); + /* Schriftvariablen der Kit-Komponenten (Brand-UI-Kit v1.6) zeigen auf die gemeinsamen Schriften. */ + --lf-font-display: var(--font-display); + --lf-font-ui: var(--font-reading); + --lf-muted: #46556b; + /* Typografie (Website-Zielkonzept 7.2: Fließtext 17 → 18 px, H1 34 → 52 px) */ --font-reading: var(--font-sans); --text-small: 0.9375rem; diff --git a/resources/css/widgets.css b/resources/css/widgets.css index 7f8c333..3014288 100644 --- a/resources/css/widgets.css +++ b/resources/css/widgets.css @@ -1,11 +1,37 @@ /* - * Widget-Ansichten (Designiteration 1). Jede Regel verwendet Bedeutungswerte und richtet sich nach der Slotbreite + * Widget-Ansichten der Bestandswidgets. Jede Regel verwendet Bedeutungswerte und richtet sich nach der Slotbreite * (Container „slot“), nicht nach dem Fenster. Markenakzente (Unterstreichung, Strahlen) stammen aus * resources/views/components/brand und sind dekorativ. */ .widget { + min-width: 0; color: var(--color-text); + overflow-wrap: break-word; +} + +/* + * Gemeinsamer Layoutvertrag (ADR-38): Höhe „fill“ streckt das Widget auf die Höhe der Abschnittszeile, wenn Plätze + * nebeneinander stehen. Gestapelt (schmaler Abschnitt) entspricht das der Inhaltshöhe. Inhalte werden nie begrenzt. + */ +.section-slot:has(> .widget-height-fill) { + align-self: stretch; + display: flex; + flex-direction: column; +} + +.section-slot > .widget-height-fill { + flex: 1 1 auto; + display: flex; + flex-direction: column; +} + +.widget-height-fill > .cta { + flex: 1 1 auto; + display: flex; + flex-direction: column; + justify-content: center; + align-items: flex-start; } .widget > :last-child, @@ -19,406 +45,11 @@ .widget-heading h2 { max-width: 22ch; } -/* ------------------------------------------------------------------------------------------------ - * Einstieg (Hero) - * Varianten: standard (Text | Bild), highlight (Markenfläche), stage (Markenbühne), editorial (textbetont). - * ---------------------------------------------------------------------------------------------- */ -.hero { - --hero-focus: 50% 50%; - position: relative; - display: grid; - gap: var(--space-6); - align-items: center; -} - -.hero-copy > :is(h1, h2) { - font-size: clamp(2.125rem, 1.2rem + 4.4cqi, 4rem); - line-height: 1.05; - letter-spacing: -0.025em; - max-width: 15ch; - margin: 0; - text-wrap: balance; -} - -/* Markenstrich unter der Überschrift: kurze gelbe Unterstreichung, kein Hervorheben einzelner Wörter. */ -.hero-mark { - width: clamp(5.5rem, 4rem + 6cqi, 9rem); - height: 0.9rem; - margin: var(--space-3) 0 var(--space-5); -} - -.hero .lede { - max-width: 48ch; - margin: 0; - font-size: clamp(1.125rem, 1rem + 0.6cqi, 1.3125rem); -} - -.hero-actions { - display: flex; - flex-wrap: wrap; - gap: var(--space-3); - margin-top: var(--space-6); -} - -.hero-copy { - position: relative; - min-width: 0; -} - -.hero-figure { - position: relative; - margin: 0; -} - -.hero-image { - display: block; - width: 100%; - height: 100%; - object-fit: cover; - object-position: var(--hero-focus); -} - -.hero-figure .hero-image { - aspect-ratio: 4 / 3; - border-radius: var(--radius-panel); -} - -.hero-rays { - position: absolute; - width: clamp(2.75rem, 2rem + 3cqi, 4.5rem); - pointer-events: none; -} - -/* Standard: Bild mit grüner Fläche als Versatz und Signalstrahlen an der Ecke. */ -.hero-standard .hero-figure::before { - content: ''; - position: absolute; - inset: 1.25rem -1.25rem -1.25rem 1.25rem; - z-index: -1; - border-radius: var(--radius-panel); - background: var(--lf-green-tint); -} - -.hero-standard .hero-rays { - top: -2.25rem; - left: -1.75rem; - transform: rotate(-18deg); -} - -@container slot (min-width: 48rem) { - .hero-standard.hero-with-image { - grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); - gap: clamp(2.5rem, 6cqi, 5rem); - } -} - -/* Hervorgehoben: dunkle Markenfläche mit gelben Akzenten. */ -.hero-highlight { - padding: clamp(1.75rem, 6cqi, 4rem); - border-radius: var(--radius-panel); - background: var(--lf-navy); - --color-text: #f4f6f8; - --color-heading: var(--lf-white); - --color-link: var(--lf-white); - --color-link-hover: var(--lf-yellow); - --color-focus: var(--lf-yellow); - --color-border-strong: rgb(255 255 255 / 60%); - --color-action-secondary-text: var(--lf-white); - color: var(--color-text); - overflow: hidden; -} - -.hero-highlight .hero-rays { - top: clamp(1rem, 3cqi, 2rem); - right: clamp(1rem, 4cqi, 2.5rem); -} - -.hero-highlight .hero-figure .hero-image { - aspect-ratio: 16 / 10; -} - -@container slot (min-width: 48rem) { - .hero-highlight.hero-with-image { - grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); - gap: clamp(2rem, 5cqi, 4rem); - } -} - -/* Editorial: großer Text, Beschreibung und Schaltflächen nebeneinander, Bild als breites Band darunter. */ -.hero-editorial { - gap: var(--space-7); -} - -.hero-editorial .hero-copy > :is(h1, h2) { - font-size: clamp(2.375rem, 1.2rem + 5.6cqi, 5rem); - max-width: 18ch; -} - -.hero-editorial .hero-figure .hero-image { - aspect-ratio: 16 / 9; -} - -/* Abgesetzter Markenstrich: liest sich als Abschluss der Überschrift, nicht als Hervorhebung eines Wortes. */ -.hero-editorial .hero-mark { - width: clamp(9rem, 32cqi, 20rem); - margin-top: var(--space-5); -} - -@container slot (min-width: 56rem) { - .hero-editorial .hero-copy { - display: grid; - grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); - column-gap: clamp(2rem, 6cqi, 5rem); - align-items: end; - } - - .hero-editorial .hero-copy > :is(h1, h2), - .hero-editorial .hero-mark { - grid-column: 1 / -1; - } - - .hero-editorial .hero-actions { - margin-top: 0; - justify-content: flex-end; - } - - .hero-editorial .hero-figure .hero-image { - aspect-ratio: 21 / 9; - } -} - -/* - * Markenbühne: Bild über die volle Breite, Text auf einer hellen Tafel (Kontrast unabhängig vom Motiv). - * Schmal: Bild oben im festen Format, Tafel überlappt den unteren Bildrand. Breit (ab 56rem): Bild füllt die Bühne, - * die Tafel steht im Grundraster links oder rechts. Feste Formate verhindern Layoutverschiebungen beim Laden. - */ -.hero-stage { - display: block; -} - -.hero-stage .hero-media { - position: relative; - aspect-ratio: 4 / 3; - overflow: hidden; - background: var(--lf-green-tint); -} - -.hero-stage .hero-frame { - position: relative; - z-index: 1; - padding-inline: var(--gutter); -} - -.hero-stage.hero-with-image .hero-frame { - margin-top: -3.5rem; -} - -.hero-stage .hero-copy { - --color-text: var(--lf-ink); - --color-heading: var(--lf-navy); - --color-link: var(--lf-navy); - --color-focus: var(--lf-focus); - --color-border-strong: var(--lf-navy); - --color-action-secondary-text: var(--lf-navy); - color: var(--color-text); - background: var(--lf-cream); - border-radius: var(--radius-panel); - padding: clamp(1.5rem, 1rem + 3cqi, 3rem); - box-shadow: 0 18px 40px rgb(3 37 81 / 12%); -} - -.hero-stage .hero-rays { - top: -1.6rem; - right: 1.5rem; -} - -/* Ohne Bild: Markenbühne als ruhige Fläche. */ -.hero-stage:not(.hero-with-image) .hero-copy { - box-shadow: none; -} - -@container slot (min-width: 56rem) { - .hero-stage.hero-with-image { - display: grid; - min-height: clamp(30rem, 72svh, 46rem); - } - - .hero-stage .hero-media { - position: absolute; - inset: 0; - aspect-ratio: auto; - } - - .hero-stage.hero-with-image .hero-frame { - display: grid; - align-items: center; - justify-items: end; - margin-top: 0; - padding-block: clamp(3rem, 6cqi, 5.5rem); - padding-inline: var(--frame-inset); - } - - .hero-stage.hero-text-left .hero-frame { - justify-items: start; - } - - .hero-stage .hero-copy { - width: min(36rem, 46%); - } - - .hero-stage .hero-rays { - top: -2.25rem; - right: auto; - left: -2rem; - transform: rotate(-18deg); - } -} - -/* Randlos (SectionRenderer: section-bleed): keine Begrenzung, Abstand nach unten bleibt für die Tafel. */ -.section-bleed { - padding-block: 0; -} - -.section-bleed .page-section-inner { - width: 100%; -} - -/* Schmal: Abstand unter der Tafel bis zum nächsten Abschnitt. */ -@container slot (max-width: 55.99rem) { - .section-bleed .hero-stage .hero-frame { - padding-bottom: clamp(2rem, 8cqi, 3.5rem); - } -} - -/* Nicht randlos (Markenbühne in schmaleren Abschnitten oder Rastern): Bild mit runden Ecken. */ -.page-section:not(.section-bleed) .hero-stage .hero-media { - border-radius: var(--radius-panel); -} - -.page-section:not(.section-bleed) .hero-stage .hero-frame { - padding-inline: clamp(0.75rem, 4cqi, 2.5rem); -} - /* Fließtext */ .widget-prose .prose p { margin: 0 0 var(--space-4); } -/* ------------------------------------------------------------------------------------------------ - * Bild und Text. Varianten: image_left, image_right. Stufen: schmal (gestapelt), ab 36rem nebeneinander, - * ab 56rem Bild betont. Formate über Einstellung: Quer-, Hochformat, Quadrat, Original. - * ---------------------------------------------------------------------------------------------- */ -.image-text { - --image-focus: 50% 50%; - --image-ratio: 4 / 3; - display: grid; - gap: var(--space-6); -} - -.image-format-portrait { - --image-ratio: 4 / 5; -} - -.image-format-square { - --image-ratio: 1 / 1; -} - -.image-text-figure { - position: relative; - margin: 0; -} - -/* Versetzte Markenfläche hinter dem Bild, auf der Außenseite des Textes. */ -.image-text-figure::before { - content: ''; - position: absolute; - inset: 0.6rem -0.6rem -0.6rem 0.6rem; - z-index: -1; - border-radius: var(--radius-panel); - background: var(--lf-yellow-tint); -} - -@container slot (min-width: 36rem) { - .image-text-figure::before { - inset: 1rem 1rem -1rem -1rem; - } - - .image-text-right .image-text-figure::before { - inset: 1rem -1rem -1rem 1rem; - } -} - -.scope-dark .image-text-figure::before, -.scope-accent .image-text-figure::before { - background: rgb(255 255 255 / 12%); -} - -.image-text-figure img { - display: block; - width: 100%; - aspect-ratio: var(--image-ratio); - object-fit: cover; - object-position: var(--image-focus); - border-radius: var(--radius-panel); -} - -.image-format-original .image-text-figure img { - aspect-ratio: auto; -} - -.image-text-copy > :first-child { - margin-top: 0; -} - -.image-text-copy h1, -.image-text-copy h2 { - font-size: clamp(1.75rem, 1.2rem + 2.4cqi, 2.75rem); - line-height: 1.1; - max-width: 20ch; - margin: 0; - text-wrap: balance; -} - -.image-text-mark { - width: 5rem; - height: 0.75rem; - margin: var(--space-3) 0 var(--space-5); -} - -.image-text-copy .prose { - font-size: clamp(1.0625rem, 1rem + 0.25cqi, 1.1875rem); -} - -@container slot (min-width: 36rem) { - .image-text { - grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); - align-items: center; - gap: clamp(2rem, 5cqi, 4rem); - } - - .image-text-right > .image-text-figure { - order: 2; - } - - .image-text-no-image { - grid-template-columns: minmax(0, 1fr); - } -} - -@container slot (min-width: 56rem) { - .image-text-left { - grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); - } - - .image-text-right { - grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); - } - - .image-text-no-image { - grid-template-columns: minmax(0, 1fr); - } -} - /* ------------------------------------------------------------------------------------------------ * Redaktionelle Karten. Varianten: Raster (cards-grid), kompakte Liste (cards-compact), * erste Karte hervorgehoben (cards-featured). Die ganze Karte ist über den Titellink klickbar. diff --git a/resources/views/filament/cms/styles.blade.php b/resources/views/filament/cms/styles.blade.php index 19f8464..ac8d14d 100644 --- a/resources/views/filament/cms/styles.blade.php +++ b/resources/views/filament/cms/styles.blade.php @@ -9,7 +9,7 @@ /* Widget-Vorschau: kompakt, ohne eigene Bildlaufleiste; lange Inhalte werden gekürzt angezeigt. */ .luf-widget-preview { position: relative; } - .luf-widget-preview-frame { display: block; width: 100%; min-height: 3rem; max-height: 22rem; border: 0; overflow: hidden; pointer-events: none; background: #fff; } + .luf-widget-preview-frame { display: block; width: 100%; min-height: 3rem; max-height: 28rem; border: 0; overflow: hidden; pointer-events: none; background: #fff; } .luf-widget-preview.is-clipped::after { content: 'Vorschau gekürzt – vollständig in der Seitenvorschau'; position: absolute; inset: auto 0 0 0; padding: 2.5rem .75rem .5rem; @@ -18,6 +18,13 @@ } .luf-widget-preview-empty { margin: 0; padding: 1rem; font-size: .875rem; opacity: .75; } + /* Live-Vorschau im Bearbeitungsdialog: feste logische Breite, auf die Dialogbreite verkleinert. */ + .luf-live-preview { border: 1px solid rgb(0 0 0 / 10%); border-radius: .75rem; padding: .75rem; background: rgb(247 246 242 / 60%); } + .luf-live-preview-caption { margin: 0 0 .5rem; font-size: .75rem; opacity: .75; } + .luf-live-preview-stage { position: relative; overflow: hidden; background: #fff; border-radius: .5rem; } + .luf-live-preview-frame { display: block; border: 0; pointer-events: none; background: #fff; transform-origin: 0 0; } + .luf-preview-width .fi-btn-group { flex-wrap: wrap; } + /* Abschnitte: breite Arbeitsfläche, deutlich abgesetzte Abschnitte */ .luf-sections > .fi-fo-repeater-items { gap: 1.25rem; } .luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item { border-left: 4px solid rgb(3 37 81 / 70%); } @@ -50,8 +57,34 @@ ', 'heading' => 'Erster Einstieg', 'alt' => 'Lara und Felix', 'focus_x' => 30, 'focus_y' => 70], + 'refs' => ['image' => 'cms/park.jpg'], + ]]), + $this->section('u3_1', [[ + 'type' => 'hero', 'v' => 2, 'variant' => 'editorial_solid', 'settings' => ['height' => 'large', 'heading_level' => 'h3', 'accent' => 'rays'], + 'data' => ['heading' => 'Zweiter Einstieg', 'cta_label' => 'Konzept', 'cta_url' => '/konzept'], + ], null]), + ]); + + $this->assertStringContainsString('class="lf-hero lf-hero--photo-split lf-hero--height-compact lf-hero--accent-none"', $html); + $this->assertStringContainsString('style="--lf-hero-focus-x: 30%; --lf-hero-focus-y: 70%"', $html); + $this->assertStringContainsString('alt="Lara und Felix" loading="eager" fetchpriority="high" decoding="async"', $html); + $this->assertStringContainsString('<script>alert(1)</script>', $html); + $this->assertStringNotContainsString('', $html); + $this->assertSame(1, substr_count($html, 'assertStringContainsString('

Erster Einstieg

', $html); + $this->assertStringContainsString('

Zweiter Einstieg

', $html); + $this->assertStringContainsString('lf-hero--editorial-solid lf-hero--height-large lf-hero--accent-rays', $html); + $this->assertStringContainsString('brand-rays lf-hero__rays', $html); + $this->assertSame(1, substr_count($html, 'lf-hero__title-accent'), 'Ohne Akzent keine Unterstreichung.'); + $this->assertStringContainsString('widget-hero widget-variant-photo-split widget-height-compact', $html); + } + + public function test_hero_rejects_unsafe_links_and_out_of_range_focus(): void + { + $cases = [ + 'blocks.0.data.cta2_url' => ['heading' => 'X', 'cta2_label' => 'Böse', 'cta2_url' => 'javascript:alert(1)'], + 'blocks.0.data.focus_x' => ['heading' => 'X', 'focus_x' => 150], + ]; + + foreach ($cases as $key => $data) { + try { + app(WidgetRegistry::class)->normalize([['type' => 'hero', 'v' => 2, 'data' => $data]]); + $this->fail("$key wurde angenommen."); + } catch (ValidationException $exception) { + $this->assertArrayHasKey($key, $exception->errors()); + } + } + } + + public function test_premium_image_text_renders_surface_height_side_and_sanitized_body(): void + { + $html = $this->publish('/bild-text', [ + ['type' => 'heading', 'v' => 1, 'data' => ['heading' => 'Seite']], + $this->section('u4', [[ + 'type' => 'image_text', 'v' => 3, 'variant' => 'image_left', + 'settings' => ['surface' => 'navy', 'height' => 'spacious', 'heading_level' => 'h3'], + 'data' => ['eyebrow' => 'Unser Ansatz', 'title' => 'Geschichten', 'body' => '

Text

', 'alt' => 'Park', 'cta_label' => 'Mehr', 'cta_url' => '/konzept', 'cta2_label' => 'Themen', 'cta2_url' => 'https://example.org/themen', 'focus_x' => 10, 'focus_y' => 90], + 'refs' => ['image' => 'cms/park.jpg'], + ]]), + $this->section('u4', [['type' => 'image_text', 'v' => 3, 'data' => ['body' => '

Ohne Bild

']]]), + ]); + + $this->assertStringContainsString('class="lf-bt lf-bt--navy lf-bt--image-left lf-bt--height-spacious"', $html); + $this->assertStringContainsString('style="--bt-focus-x: 10%; --bt-focus-y: 90%"', $html); + $this->assertStringContainsString('

Geschichten

', $html); + $this->assertStringContainsString('

Unser Ansatz

', $html); + $this->assertStringNotContainsString('', $html); + $this->assertStringContainsString('Mehr ', $html); + $this->assertStringContainsString('Themen', $html); + $this->assertStringContainsString('lf-bt lf-bt--cream lf-bt--image-left lf-bt--height-normal lf-bt--without-image', $html); + } + + /** + * Gemeinsamer Layoutvertrag für alle Bestandswidgets: In jeder zulässigen Platzbreite wird gerendert; nicht + * zulässige Breiten werden beim Speichern mit verständlicher Meldung abgewiesen. + */ + public function test_every_widget_renders_in_each_supported_width_and_rejects_the_others(): void + { + $samples = [ + 'heading' => ['heading' => 'Überschrift mit einem sehr langen Wort Gewaltpräventionsfortbildungsmaßnahme'], + 'prose' => ['body' => 'Fließtext mit einer langen Adresse https://example.org/'.str_repeat('a', 80)], + 'cards' => ['items' => [['title' => 'Karte mit langem Titel für schmale Plätze', 'text' => 'Beschreibung', 'url' => '/a']]], + 'call_to_action' => ['heading' => 'Aufruf', 'text' => 'Text', 'label' => 'Eine ausgesprochen lange Schaltflächenbeschriftung zum Prüfen', 'url' => '/a'], + 'faq' => ['items' => [['question' => 'Frage?', 'answer' => 'Antwort.']]], + 'hero' => ['heading' => 'Einstieg mit einer langen Überschrift, die umbrechen muss'], + 'image_text' => ['title' => 'Bild und Text', 'body' => '

Text

'], + ]; + $registry = app(WidgetRegistry::class); + $layouts = ['u4' => [4], 'u3_1' => [3, 1], 'u2_2' => [2, 2], 'u1_1_1_1' => [1, 1, 1, 1]]; + $path = 0; + + foreach ($samples as $type => $data) { + $widgetType = $registry->get($type); + $widget = ['type' => $type, 'v' => $widgetType->version(), 'data' => $data]; + + foreach ($layouts as $layout => $units) { + $slots = array_fill(0, count($units), null); + $slots[0] = $widget; + + if ($widgetType->supportsUnits($units[0])) { + $html = $this->publish('/raster-'.(++$path), [$this->section($layout, $slots)]); + $this->assertStringContainsString('widget-'.str_replace('_', '-', $type), $html, "$type in $layout"); + $this->assertStringContainsString('data-units="'.$units[0].'"', $html, "$type in $layout"); + } else { + try { + app(PageService::class)->saveRevision(Page::query()->create(['path' => '/abgewiesen-'.(++$path)]), [$this->section($layout, $slots)], null, null, null); + $this->fail("$type in $layout ({$units[0]} Einheiten) wurde angenommen."); + } catch (ValidationException $exception) { + $this->assertStringContainsString($widgetType->unitsLabel().' Rastereinheiten', $exception->errors()['sections.0.slots.0.units'][0]); + } + } + } + } + + $this->assertSame(['u4', 'u2_2', 'u1_3', 'u3_1', 'u1_2_1', 'u1_1_1_1'], array_keys(SectionLayouts::UNITS)); + } + + public function test_fill_height_marks_the_widget_and_defaults_to_content_height(): void + { + $html = $this->publish('/fuellen', [ + $this->section('u2_2', [ + ['type' => 'call_to_action', 'v' => 1, 'settings' => ['height' => 'fill'], 'data' => ['heading' => 'Gleich hoch', 'label' => 'Los', 'url' => '/a']], + ['type' => 'call_to_action', 'v' => 1, 'data' => ['heading' => 'Nach Inhalt', 'label' => 'Los', 'url' => '/b']], + ]), + ]); + + $this->assertStringContainsString('widget-call-to-action widget-variant-standard widget-height-fill', $html); + $this->assertStringContainsString('widget-call-to-action widget-variant-standard widget-height-auto', $html); + $this->assertStringNotContainsString('widget-prose widget-variant-standard widget-height', $html); + } +} diff --git a/tests/Feature/CmsWidgetRenderingTest.php b/tests/Feature/CmsWidgetRenderingTest.php index 4379e77..1ac1249 100644 --- a/tests/Feature/CmsWidgetRenderingTest.php +++ b/tests/Feature/CmsWidgetRenderingTest.php @@ -140,7 +140,8 @@ public function test_new_revisions_are_stored_as_widget_envelopes(): void $this->assertSame(['id', 'type', 'v', 'variant', 'settings', 'data', 'refs'], array_keys($revision->blocks[0])); $this->assertSame('prose', $revision->blocks[0]['type']); $this->assertSame(['body' => 'Altes Eingabeformat'], $revision->blocks[0]['data']); - $this->assertSame('highlight', $revision->blocks[1]['variant']); + // Gespeichert wird immer die aktuelle Version: hero v1 „highlight“ wird zu v2 „editorial_solid“. + $this->assertSame([2, 'editorial_solid'], [$revision->blocks[1]['v'], $revision->blocks[1]['variant']]); $this->assertNull($page->fresh()->published_revision_id, 'Speichern veröffentlicht nicht.'); } @@ -156,11 +157,11 @@ public function test_reference_widgets_render_their_variants(): void $this->get('/varianten') ->assertOk() - ->assertSee('hero hero-highlight', false) - ->assertSee('

Stark im Alltag

', false) - ->assertSee('class="button button-brand" href="/praevention"', false) - ->assertSee('image-text image-text-right', false) - ->assertSee('

Bild rechts

', false) + ->assertSee('lf-hero lf-hero--editorial-solid lf-hero--height-normal', false) + ->assertSee('

Stark im Alltag

', false) + ->assertSee('class="lf-hero__button lf-hero__button--primary" href="/praevention"', false) + ->assertSee('lf-bt lf-bt--cream lf-bt--image-right lf-bt--height-normal', false) + ->assertSee('

Bild rechts

', false) ->assertSee('betont', false) ->assertSee(route('media.public', ['path' => 'cms/beispiel.jpg']), false) ->assertSee('cards cards-compact', false); diff --git a/tests/Unit/PageSectionsTest.php b/tests/Unit/PageSectionsTest.php index cf3bc7e..2006a7e 100644 --- a/tests/Unit/PageSectionsTest.php +++ b/tests/Unit/PageSectionsTest.php @@ -108,20 +108,31 @@ public function test_surplus_empty_slots_are_compacted_without_losing_widgets(): $this->assertSame(['A', 'C'], array_map(fn ($slot) => $slot['data']['heading'], $stored[0]['slots'])); } - public function test_widget_minimum_width_is_enforced_per_slot(): void + /** + * Layoutvertrag (ADR-38): Ein Platz muss eine der unterstützten Breiten haben. Der Premium-Einstieg ist seit + * Kit v1.6 nur für 3 oder 4 Einheiten vorgesehen (vorher Mindestbreite 2). + */ + public function test_widget_supported_widths_are_enforced_per_slot(): void { - $hero = ['type' => 'hero', 'v' => 1, 'data' => ['heading' => 'Einstieg']]; + $hero = ['type' => 'hero', 'v' => 2, 'data' => ['heading' => 'Einstieg']]; - try { - $this->sections()->normalize([$this->section('u1_3', [$hero, null])]); - $this->fail('Einstieg im schmalen Platz wurde angenommen.'); - } catch (ValidationException $exception) { - $this->assertArrayHasKey('sections.0.slots.0.units', $exception->errors()); + foreach ([['u1_3', [$hero, null]], ['u2_2', [$hero, null]]] as [$layout, $slots]) { + try { + $this->sections()->normalize([$this->section($layout, $slots)]); + $this->fail("Einstieg im zu schmalen Platz ($layout) wurde angenommen."); + } catch (ValidationException $exception) { + $this->assertArrayHasKey('sections.0.slots.0.units', $exception->errors()); + $this->assertStringContainsString('3 oder 4 Rastereinheiten', $exception->errors()['sections.0.slots.0.units'][0]); + } } $stored = $this->sections()->normalize([$this->section('u1_3', [null, $hero])]); $this->assertSame('hero', $stored[0]['slots'][1]['type']); - $this->assertSame(2, app(WidgetRegistry::class)->get('hero')->minUnits()); + $this->assertSame([3, 4], app(WidgetRegistry::class)->get('hero')->supportedUnits()); + + $imageText = ['type' => 'image_text', 'v' => 3, 'data' => ['body' => '

Schmal

']]; + $stored = $this->sections()->normalize([$this->section('u1_1_1_1', [$imageText, null, null, null])]); + $this->assertSame('image_text', $stored[0]['slots'][0]['type'], 'Bild und Text ist für 1 bis 4 Einheiten freigegeben.'); } public function test_free_style_values_and_unknown_layouts_are_rejected(): void diff --git a/tests/Unit/WidgetRegistryTest.php b/tests/Unit/WidgetRegistryTest.php index ea5a314..41c0061 100644 --- a/tests/Unit/WidgetRegistryTest.php +++ b/tests/Unit/WidgetRegistryTest.php @@ -66,18 +66,56 @@ public function test_registration_rejects_keys_that_are_not_stable_identifiers() new WidgetRegistry([$this->customWidget('Teaser Box')]); } - public function test_every_widget_declares_a_minimum_width_within_four_units(): void + /** Gemeinsamer Layoutvertrag (ADR-38) für jede registrierte Art. */ + public function test_every_widget_declares_the_shared_layout_contract(): void { foreach ($this->registry()->all() as $key => $type) { - $this->assertGreaterThanOrEqual(1, $type->minUnits(), $key); - $this->assertLessThanOrEqual($type->preferredUnits(), $type->minUnits(), $key); - $this->assertLessThanOrEqual(4, $type->preferredUnits(), $key); + $units = $type->supportedUnits(); + $this->assertNotEmpty($units, $key); + $this->assertSame([], array_diff($units, [1, 2, 3, 4]), $key); + $this->assertSame(min($units), $type->minUnits(), $key); + $this->assertTrue($type->supportsUnits($type->preferredUnits()), $key); $this->assertNotEmpty($type->stages(), $key); + $this->assertNotSame('', $type->narrowBehavior(), $key); + $this->assertSame([], array_diff(array_keys($type->heights()), array_keys(WidgetType::HEIGHTS)), $key); + + if ($type->heights() !== []) { + $this->assertArrayHasKey($type->defaultHeight(), $type->heights(), $key); + $this->assertSame($type->heights(), $type->settingOptions()['height'], $key); + } } - $this->assertSame(2, $this->registry()->get('hero')->minUnits()); - $this->assertSame(2, $this->registry()->get('image_text')->minUnits()); - $this->assertSame(1, $this->registry()->get('catalog_cards')->minUnits()); + $this->assertSame([3, 4], $this->registry()->get('hero')->supportedUnits()); + $this->assertSame(['compact', 'normal', 'large'], array_keys($this->registry()->get('hero')->heights())); + $this->assertSame([1, 2, 3, 4], $this->registry()->get('image_text')->supportedUnits()); + $this->assertSame(['compact', 'normal', 'spacious'], array_keys($this->registry()->get('image_text')->heights())); + $this->assertSame(['auto', 'fill'], array_keys($this->registry()->get('call_to_action')->heights())); + $this->assertSame([2, 3, 4], $this->registry()->get('faq')->supportedUnits()); + $this->assertSame('3 oder 4', $this->registry()->get('hero')->unitsLabel()); + $this->assertSame('1 bis 4', $this->registry()->get('cards')->unitsLabel()); + } + + public function test_height_is_an_enumerated_setting_with_a_default(): void + { + $widget = $this->registry()->normalize([ + ['type' => 'hero', 'v' => 2, 'settings' => ['height' => 'large'], 'data' => ['heading' => 'X']], + ])[0]; + $this->assertSame('large', $widget['settings']['height']); + $this->assertSame('normal', $this->registry()->get('hero')->height(['settings' => []])); + + try { + $this->registry()->normalize([['type' => 'hero', 'v' => 2, 'settings' => ['height' => '900px'], 'data' => ['heading' => 'X']]]); + $this->fail('Freie Höhe wurde angenommen.'); + } catch (ValidationException $exception) { + $this->assertArrayHasKey('blocks.0.settings.height', $exception->errors()); + } + + try { + $this->registry()->normalize([['type' => 'prose', 'v' => 1, 'settings' => ['height' => 'compact'], 'data' => ['body' => 'Text']]]); + $this->fail('Höhe für eine Art ohne Höhenwahl wurde angenommen.'); + } catch (ValidationException $exception) { + $this->assertArrayHasKey('blocks.0.settings.height', $exception->errors()); + } } public function test_a_new_widget_type_works_through_the_contract_alone(): void @@ -112,7 +150,7 @@ public function test_unknown_type_and_unregistered_variant_are_rejected(): void } try { - $this->registry()->normalize([['type' => 'hero', 'v' => 1, 'variant' => 'gross-und-bunt', 'data' => ['heading' => 'X']]]); + $this->registry()->normalize([['type' => 'hero', 'v' => 2, 'variant' => 'gross-und-bunt', 'data' => ['heading' => 'X']]]); $this->fail('Unbekannte Variante wurde angenommen.'); } catch (ValidationException $exception) { $this->assertArrayHasKey('blocks.0.variant', $exception->errors()); @@ -204,13 +242,13 @@ public function test_legacy_blocks_are_read_as_version_one_envelopes(): void ], $widget); } - public function test_legacy_image_text_is_upgraded_to_version_two_on_read(): void + public function test_legacy_image_text_is_upgraded_to_the_current_version_on_read(): void { $legacy = ['type' => 'image_text', 'image' => 'cms/alt.jpg', 'alt' => 'Kinder im Kreis', 'body' => "Erster Absatz & mehr.\n\nZweiter ."]; $widget = $this->registry()->upcast($legacy); - $this->assertSame(2, $widget['v']); + $this->assertSame(3, $widget['v']); $this->assertSame('image_left', $widget['variant']); $this->assertSame(['image' => 'cms/alt.jpg'], $widget['refs']); $this->assertSame('Kinder im Kreis', $widget['data']['alt']); @@ -225,7 +263,7 @@ public function test_stored_version_one_envelope_is_upgraded_as_well(): void 'data' => ['image' => null, 'alt' => 'x', 'body' => 'Nur Text'], 'refs' => [], ]); - $this->assertSame(2, $widget['v']); + $this->assertSame(3, $widget['v']); $this->assertSame('abc', $widget['id']); $this->assertSame('image_left', $widget['variant']); $this->assertSame('

Nur Text

', $widget['data']['body']); diff --git a/vite.config.js b/vite.config.js index 19ec426..9270b47 100644 --- a/vite.config.js +++ b/vite.config.js @@ -11,7 +11,7 @@ export default defineConfig({ fonts: [ // Vorläufige Markenschriften (Website-Zielkonzept 7.2, nicht freigegeben); beim Build lokal abgelegt. bunny('Nunito', { - weights: [700, 800], + weights: [700, 800, 900], optimizedFallbacks: false, }), bunny('Source Sans 3', {