Ergänze Farbe aus der Palette und Schriftgrößen je Widget
CI Feature / test (push) Failing after 5m29s
CI Feature / test (push) Failing after 5m29s
Gemeinsamer Vertrag in WidgetType (typography(), paletteTarget()) mit den Einstellungen heading_size, text_size und palette; WidgetAppearance setzt Klassen und Eigenschaften an der Hülle, nur wenn ein Wert gewählt ist. Eine absolute Größenskala aus den Designwerten gilt in jedem Widget gleich; ohne Wahl bleibt die bisherige Größe. Die Palettenfarbe färbt je Art die Fläche des Widgets (hull) oder dessen eigene Fläche (face). Der Verwendungsnachweis der Palette zählt jetzt auch Widgets, damit die Bestätigung einer Farbänderung und die Sperre beim Entfernen greifen. Der Vertragstest für Einstellungsgruppen nimmt die gemeinsamen Schlüssel bewusst aus, weil sie eigene Gruppen im Editor haben. ADR-68, Abnahme unter docs/ux/verwaltung/abnahme/widget-flaeche-schrift.md. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
63ad125859
commit
2b00905f00
36 files changed
+910
-12
No files matched your search
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Domain\Cms\Sections\SectionLayouts;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Domain\Cms\Widgets\Support\WidgetAppearance;
|
||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||
use App\Domain\Cms\Widgets\WidgetRenderer;
|
||||
use App\Domain\Cms\Widgets\WidgetType;
|
||||
@@ -152,7 +153,11 @@ public static function block(WidgetType $type): Block
|
||||
}
|
||||
|
||||
$options = $type->settingOptions();
|
||||
$labels = $type->settingLabels();
|
||||
$labels = $type->settingLabels() + [
|
||||
'heading_size' => WidgetAppearance::HEADING_LABEL,
|
||||
'text_size' => WidgetAppearance::TEXT_LABEL,
|
||||
'palette' => WidgetAppearance::PALETTE_LABEL,
|
||||
];
|
||||
$hiddenWhen = $type->settingHiddenWhen();
|
||||
|
||||
$field = function (string $key) use ($options, $labels, $type, $icons, $hiddenWhen): Select|ToggleButtons|ViewField {
|
||||
@@ -171,7 +176,7 @@ public static function block(WidgetType $type): Block
|
||||
? SymbolField::make('symbol', $labels[$key][0] ?? 'Symbol')->live()->columnSpanFull()
|
||||
: Select::make($key)
|
||||
->label($labels[$key][0] ?? Str::headline($key))
|
||||
->placeholder('Vorgabe der Darstellung')
|
||||
->placeholder(in_array($key, ['heading_size', 'text_size'], true) ? 'Bisherige Größe des Widgets' : 'Vorgabe der Darstellung')
|
||||
->options($options[$key])
|
||||
->live());
|
||||
|
||||
@@ -196,6 +201,20 @@ public static function block(WidgetType $type): Block
|
||||
$display[] = Section::make('Aufbau')->compact()->schema($layout);
|
||||
}
|
||||
|
||||
// Schrift und Farbe (ADR-68) gehören allen Arten, die sie anbieten, und stehen in eigenen Gruppen nach „Aufbau“.
|
||||
$sizeKeys = array_values(array_filter(['heading_size', 'text_size'], fn (string $key): bool => isset($options[$key])));
|
||||
if ($sizeKeys !== []) {
|
||||
$display[] = Section::make('Schrift')->compact()->schema([
|
||||
Grid::make(['default' => 1, 'md' => 2])->schema(array_map($field, $sizeKeys))->statePath('settings'),
|
||||
]);
|
||||
}
|
||||
|
||||
if (isset($options['palette'])) {
|
||||
$display[] = Section::make('Farbe')->compact()->schema([
|
||||
Group::make([WidgetPaletteField::make('palette')->live()])->statePath('settings'),
|
||||
]);
|
||||
}
|
||||
|
||||
$grouped = [];
|
||||
foreach ($type->settingGroups() as $title => $keys) {
|
||||
$keys = array_values(array_filter($keys, fn (string $key): bool => isset($options[$key]) && $key !== 'height'));
|
||||
@@ -207,7 +226,7 @@ public static function block(WidgetType $type): Block
|
||||
}
|
||||
}
|
||||
|
||||
$rest = array_values(array_filter(array_keys($options), fn (string $key): bool => $key !== 'height' && ! in_array($key, $grouped, true)));
|
||||
$rest = array_values(array_filter(array_keys($options), fn (string $key): bool => $key !== 'height' && ! in_array($key, WidgetAppearance::KEYS, true) && ! in_array($key, $grouped, true)));
|
||||
if ($rest !== []) {
|
||||
$display[] = Section::make($grouped === [] && $layout === [] ? 'Einstellungen' : 'Weitere Einstellungen')->compact()->schema([
|
||||
Grid::make(['default' => 1, 'md' => 2])->schema(array_map($field, $rest))->statePath('settings'),
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Support;
|
||||
|
||||
use App\Domain\Cms\Widgets\Support\WidgetAppearance;
|
||||
use App\Domain\Design\DesignPalette;
|
||||
use Filament\Forms\Components\ViewField;
|
||||
|
||||
/**
|
||||
* Farbe eines Widgets als Kacheln (ADR-68): „Ohne Farbe“ und die Farben der zentralen Palette. Das Feld ist das Feld
|
||||
* „palette“ der Einstellungen des Widgets und speichert die Kennung der Farbe (nie einen Farbwert). Die Kacheln sehen aus wie
|
||||
* die des Abschnitts (BackgroundField); sie unterscheiden sich nur dadurch, dass es keine festen Markenflächen und kein
|
||||
* Hintergrundbild gibt.
|
||||
*/
|
||||
final class WidgetPaletteField
|
||||
{
|
||||
public static function make(string $name = 'palette'): ViewField
|
||||
{
|
||||
return ViewField::make($name)
|
||||
->label(WidgetAppearance::PALETTE_LABEL[0])
|
||||
->view('filament.cms.widget-farbe')
|
||||
->hiddenLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{id: string, label: string, bg: ?string, fg: ?string, kind: string}>
|
||||
*/
|
||||
public static function tiles(): array
|
||||
{
|
||||
$tiles = [['id' => '', 'label' => 'Ohne Farbe', 'bg' => null, 'fg' => null, 'kind' => 'default']];
|
||||
|
||||
foreach (DesignPalette::slots() as $slot) {
|
||||
$tiles[] = ['id' => $slot['id'], 'label' => $slot['name'], 'bg' => $slot['bg'], 'fg' => $slot['fg'], 'kind' => 'palette'];
|
||||
}
|
||||
|
||||
return $tiles;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user