Designiteration 1 auf Grundlage des Brand-UI-Kits (vorläufige Werte): - Kopfzeile mit konstanter Box und zwei Zuständen (großzügig, kompakt beim Scrollen) ohne Layoutsprung; Navigation bricht nie um, sondern verkürzt erst den Kontozugang und schaltet dann in den Menümodus. Scrollbalken-Reserve, gemeinsames Breitenmodell (Lesebereich, Standard, Breit, Vollbreite), Wortmarke und Inhalt fluchten. - Fokusfalle im Mobilmenü schließt auch den Weg von der Menü-Schaltfläche in den Inhalt. - Fußbereich mit Grundzeile für rechtliche Links und grünem Bogen. - Markenakzente (Unterstreichung, Strahlen, Bogen) als Komponenten. - Hero: Varianten Markenbühne (randlos) und Editorial, zweite Schaltfläche, Bildausschnitt. Bild und Text: Bildformat und Ausschnitt. Karten: hervorgehobene erste Karte, ganze Karte klickbar. Programmkarten mit Markentafel. Alles additiv, ohne neue Version. Testanpassungen: Die Website-Wortmarke trägt jetzt brand-lockup, die erste Hero-Schaltfläche button-brand (beabsichtigte Gestaltung). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
89 lines
2.8 KiB
PHP
89 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Domain\Cms\Widgets;
|
|
|
|
use Illuminate\Support\HtmlString;
|
|
|
|
/**
|
|
* Einziger Darstellungsweg für Widgets: öffentliche Seite, ganzseitige Vorschau und Blockvorschau im Editor
|
|
* verwenden dieselbe Blade-Ansicht je Widget-Art.
|
|
*/
|
|
class WidgetRenderer
|
|
{
|
|
public function __construct(private readonly WidgetRegistry $registry) {}
|
|
|
|
/**
|
|
* @param array<int|string, mixed>|null $blocks gespeicherte Bausteine (Altformat oder Hülle)
|
|
*/
|
|
public function renderAll(?array $blocks, RenderContext $context): HtmlString
|
|
{
|
|
$html = '';
|
|
$position = 0;
|
|
|
|
foreach (array_values($blocks ?? []) as $block) {
|
|
if (! is_array($block)) {
|
|
continue;
|
|
}
|
|
|
|
$widget = $this->registry->upcast($block);
|
|
|
|
if ($widget === null) {
|
|
if ($context->preview) {
|
|
$html .= '<section class="block widget-unknown"><p class="preview-note">Unbekannter Baustein „'.e((string) ($block['type'] ?? '')).'“ wird öffentlich nicht angezeigt.</p></section>';
|
|
}
|
|
|
|
continue;
|
|
}
|
|
|
|
$rendered = $this->renderWidget($widget, $context, $position === 0);
|
|
|
|
if ($rendered !== '') {
|
|
$html .= $rendered;
|
|
$position++;
|
|
}
|
|
}
|
|
|
|
return new HtmlString($html);
|
|
}
|
|
|
|
/**
|
|
* Ob die Instanz randlos dargestellt werden darf (siehe WidgetType::bleeds).
|
|
*
|
|
* @param array<string, mixed> $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.
|
|
*
|
|
* @param array<string, mixed> $widget aktuelle Hülle
|
|
*/
|
|
public function renderWidget(array $widget, RenderContext $context, bool $first = false): string
|
|
{
|
|
$type = $this->registry->get($widget['type']);
|
|
|
|
$inner = trim(view($type->view(), [
|
|
'widget' => $widget,
|
|
'data' => $widget['data'],
|
|
'refs' => $widget['refs'],
|
|
'variant' => $widget['variant'],
|
|
'settings' => $widget['settings'],
|
|
'first' => $first,
|
|
'context' => $context,
|
|
] + $type->resolve($widget, $context))->render());
|
|
|
|
if ($inner === '') {
|
|
return '';
|
|
}
|
|
|
|
$id = is_string($widget['id'] ?? null) ? ' id="abschnitt-'.e($widget['id']).'"' : '';
|
|
|
|
return '<section class="block widget widget-'.e(str_replace('_', '-', $widget['type'])).' widget-variant-'.e(str_replace('_', '-', $widget['variant'])).'"'.$id.'>'
|
|
.$inner
|
|
.'</section>';
|
|
}
|
|
}
|