Füge großes Symbol neben dem Absatz und Links in der Merkmalszeile hinzu
Nach der ersten Sichtung auf luf-test: - Einstellung "Größe des Symbols" (settings.symbol_size = large) bei Überschrift und Handlungsaufruf: das Symbol steht groß links neben Überschrift, Text und Schaltfläche, bei höchstens 24 rem Slotbreite darüber. Vorgabe bleibt das kleine Symbol vor der Überschrift. Ohne gewähltes Symbol hat die Größe keine Wirkung. - Merkmalszeile: je Merkmal optional Linkziel (SafeUrl) und Linktext (Vorgabe "Mehr erfahren", ohne Linkziel verworfen). Die Einstellung "Darstellung der Links" wählt für das Widget kleiner Textlink (Vorgabe) oder Pille. Der zugängliche Name des Links nennt das Merkmal. - Auf dunklen Flächen steht auch das große Symbol auf einer weißen Scheibe. - Doku: Die Tabelle in cms-widget-registry.md war durch meinen früheren Absatz zerrissen (Zeile "Höhe" stand außerhalb) und ist wieder in Ordnung. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ad581cb545
commit
3c7a71532f
14 files changed
+270
-12
No files matched your search
@@ -36,6 +36,34 @@ final class HeadingAccent
|
||||
|
||||
public const BRUSH_LABEL = ['Pinselstrich', 'Gelbe Unterstreichung unter der Überschrift (freigegebenes Motiv aus dem Brand-Kit). Vorgabe: ohne.'];
|
||||
|
||||
/** @var array<string, string> */
|
||||
public const SIZE = ['large' => 'Groß, links neben dem ganzen Absatz'];
|
||||
|
||||
public const SIZE_LABEL = ['Größe des Symbols', 'Vorgabe: klein, vor der Überschrift. „Groß“ stellt das Symbol links neben Überschrift und Text; bei wenig Platz steht es darüber. Wirkt nur, wenn ein Symbol gewählt ist.'];
|
||||
|
||||
/** @var array<string, string> */
|
||||
public const LINK_STYLE = ['text' => 'Kleiner Textlink', 'pill' => 'Pille (Schaltfläche)'];
|
||||
|
||||
public const LINK_STYLE_LABEL = ['Darstellung der Links', 'Wie die Links der Merkmale aussehen. Vorgabe: kleiner Textlink. Merkmale ohne Link zeigen nichts.'];
|
||||
|
||||
/**
|
||||
* Großes Symbol links neben dem ganzen Absatz: nur mit gültigem Symbol und Einstellung „large“.
|
||||
*
|
||||
* @param array<string, mixed> $settings
|
||||
*/
|
||||
public static function isLarge(array $settings): bool
|
||||
{
|
||||
return self::symbol($settings) !== null && ($settings['symbol_size'] ?? null) === 'large';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $settings
|
||||
*/
|
||||
public static function linkStyle(array $settings): string
|
||||
{
|
||||
return ($settings['link_style'] ?? null) === 'pill' ? 'pill' : 'text';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gültiger Symbolname aus den Einstellungen eines Widgets oder null.
|
||||
*
|
||||
|
||||
@@ -93,17 +93,17 @@ public function dataFields(): array
|
||||
|
||||
public function settings(): array
|
||||
{
|
||||
return ['symbol' => HeadingAccent::SYMBOLS];
|
||||
return ['symbol' => HeadingAccent::SYMBOLS, 'symbol_size' => HeadingAccent::SIZE];
|
||||
}
|
||||
|
||||
public function settingGroups(): array
|
||||
{
|
||||
return ['Aussehen' => ['symbol']];
|
||||
return ['Aussehen' => ['symbol', 'symbol_size']];
|
||||
}
|
||||
|
||||
public function settingLabels(): array
|
||||
{
|
||||
return ['symbol' => HeadingAccent::SYMBOL_LABEL];
|
||||
return ['symbol' => HeadingAccent::SYMBOL_LABEL, 'symbol_size' => HeadingAccent::SIZE_LABEL];
|
||||
}
|
||||
|
||||
public function clean(array $data, array $refs, WidgetErrors $errors): array
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Domain\Cms\Widgets\Support\HeadingAccent;
|
||||
use App\Domain\Cms\Widgets\Support\SafeUrl;
|
||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||
use App\Domain\Cms\Widgets\WidgetType;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
@@ -20,6 +21,8 @@
|
||||
*/
|
||||
class FeaturesWidget extends WidgetType
|
||||
{
|
||||
private const DEFAULT_LINK_LABEL = 'Mehr erfahren';
|
||||
|
||||
public function key(): string
|
||||
{
|
||||
return 'features';
|
||||
@@ -75,9 +78,26 @@ public function dataRules(): array
|
||||
'items.*.symbol' => ['required', 'string', Rule::in(array_keys(HeadingAccent::SYMBOLS))],
|
||||
'items.*.title' => ['required', 'string', 'max:60'],
|
||||
'items.*.text' => ['nullable', 'string', 'max:200'],
|
||||
'items.*.url' => ['nullable', 'string', 'max:500'],
|
||||
'items.*.link_label' => ['nullable', 'string', 'max:60'],
|
||||
];
|
||||
}
|
||||
|
||||
public function settings(): array
|
||||
{
|
||||
return ['link_style' => HeadingAccent::LINK_STYLE];
|
||||
}
|
||||
|
||||
public function settingGroups(): array
|
||||
{
|
||||
return ['Aussehen' => ['link_style']];
|
||||
}
|
||||
|
||||
public function settingLabels(): array
|
||||
{
|
||||
return ['link_style' => HeadingAccent::LINK_STYLE_LABEL];
|
||||
}
|
||||
|
||||
public function dataFields(): array
|
||||
{
|
||||
return [
|
||||
@@ -87,6 +107,16 @@ public function dataFields(): array
|
||||
Select::make('symbol')->label('Symbol')->options(HeadingAccent::SYMBOLS)->required(),
|
||||
TextInput::make('title')->label('Kurztitel')->required()->maxLength(60),
|
||||
Textarea::make('text')->label('Satz')->rows(2)->maxLength(200),
|
||||
TextInput::make('url')
|
||||
->label('Linkziel (optional)')
|
||||
->maxLength(500)
|
||||
->rule(SafeUrl::rule())
|
||||
->helperText('Seitenpfad wie /materialien oder eine http(s)-Adresse. Leer lassen für ein Merkmal ohne Link.'),
|
||||
TextInput::make('link_label')
|
||||
->label('Linktext')
|
||||
->maxLength(60)
|
||||
->placeholder(self::DEFAULT_LINK_LABEL)
|
||||
->helperText('Nur mit Linkziel. Leer: „'.self::DEFAULT_LINK_LABEL.'“.'),
|
||||
])
|
||||
->minItems(2)
|
||||
->maxItems(4)
|
||||
@@ -101,10 +131,19 @@ public function dataFields(): array
|
||||
public function clean(array $data, array $refs, WidgetErrors $errors): array
|
||||
{
|
||||
foreach ($data['items'] as $index => $item) {
|
||||
$hasUrl = filled($item['url'] ?? null);
|
||||
|
||||
if ($hasUrl && ! SafeUrl::isSafe($item['url'])) {
|
||||
$errors->add("data.items.$index.url", SafeUrl::message());
|
||||
}
|
||||
|
||||
$data['items'][$index] = [
|
||||
'symbol' => $item['symbol'],
|
||||
'title' => $item['title'],
|
||||
'text' => filled($item['text'] ?? null) ? $item['text'] : null,
|
||||
'url' => $hasUrl ? $item['url'] : null,
|
||||
// Ein Linktext ohne Linkziel wird verworfen, damit nichts Verstecktes gespeichert bleibt.
|
||||
'link_label' => $hasUrl && filled($item['link_label'] ?? null) ? $item['link_label'] : null,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -124,10 +163,12 @@ public function resolve(array $widget, RenderContext $context): array
|
||||
'symbol' => HeadingAccent::symbol(['symbol' => $item['symbol'] ?? null]),
|
||||
'title' => $item['title'],
|
||||
'text' => $item['text'] ?? null,
|
||||
'url' => SafeUrl::isSafe($item['url'] ?? null) ? $item['url'] : null,
|
||||
'linkLabel' => filled($item['link_label'] ?? null) ? $item['link_label'] : self::DEFAULT_LINK_LABEL,
|
||||
];
|
||||
}
|
||||
|
||||
return ['items' => $items];
|
||||
return ['items' => $items, 'linkStyle' => HeadingAccent::linkStyle($widget['settings'] ?? [])];
|
||||
}
|
||||
|
||||
public function summary(array $widget): string
|
||||
|
||||
@@ -76,19 +76,21 @@ public function settings(): array
|
||||
{
|
||||
return [
|
||||
'symbol' => HeadingAccent::SYMBOLS,
|
||||
'symbol_size' => HeadingAccent::SIZE,
|
||||
'accent' => HeadingAccent::BRUSH,
|
||||
];
|
||||
}
|
||||
|
||||
public function settingGroups(): array
|
||||
{
|
||||
return ['Aussehen' => ['symbol', 'accent']];
|
||||
return ['Aussehen' => ['symbol', 'symbol_size', 'accent']];
|
||||
}
|
||||
|
||||
public function settingLabels(): array
|
||||
{
|
||||
return [
|
||||
'symbol' => HeadingAccent::SYMBOL_LABEL,
|
||||
'symbol_size' => HeadingAccent::SIZE_LABEL,
|
||||
'accent' => HeadingAccent::BRUSH_LABEL,
|
||||
];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user