Behebe Farbe heller und dunkler Palettenwidgets in verschachtelten Flächen
CI Feature / test (push) Failing after 7m49s
CI Feature / test (push) Failing after 7m49s
Die Gegenprüfung zeigte drei Fehler beim Verschachteln: Ein helles Palettenwidget in einem dunklen Abschnitt erbte aufgehellte Textfarben, Karten ohne eigene Fläche (kompakte Liste, Trennstrich) blieben mit Palettenfarbe unlesbar, und Symbole auf dunklen Palettenkarten verschwanden. - Die Hülle trägt immer scope-dark oder scope-light; Gegenregeln stellen die Werte der hellen Fläche wieder her. - paletteTarget() erhält die Hülle; Karten ohne eigene Fläche färben das ganze Widget. - Dunkle Palettenkarten erhalten die runde weiße Symbolscheibe. Tests für Farbziel und scope-light, Screenshots und Abnahme ergänzt. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2b00905f00
commit
4817fe9455
24 files changed
+88
-36
No files matched your search
@@ -63,10 +63,11 @@ public static function options(WidgetType $type): array
|
||||
/**
|
||||
* Klassen an der Hülle des Widgets, mit führendem Leerzeichen; leer, wenn nichts gesetzt ist.
|
||||
*
|
||||
* @param array<string, mixed> $settings
|
||||
* @param array<string, mixed> $widget Hülle der Instanz (variant, settings)
|
||||
*/
|
||||
public static function classes(WidgetType $type, array $settings): string
|
||||
public static function classes(WidgetType $type, array $widget): string
|
||||
{
|
||||
$settings = is_array($widget['settings'] ?? null) ? $widget['settings'] : [];
|
||||
$classes = [];
|
||||
|
||||
$heading = self::valid($settings, 'heading_size', self::HEADING, 'heading', $type);
|
||||
@@ -79,13 +80,13 @@ public static function classes(WidgetType $type, array $settings): string
|
||||
$classes[] = 'widget-ts widget-ts-'.$text;
|
||||
}
|
||||
|
||||
$slot = self::slot($type, $settings);
|
||||
$slot = self::slot($type, $widget);
|
||||
if ($slot !== null) {
|
||||
$classes[] = 'widget-palette widget-palette--'.$type->paletteTarget();
|
||||
$classes[] = 'widget-palette widget-palette--'.$type->paletteTarget($widget);
|
||||
|
||||
if (ColorContrast::isDarkSurface($slot['fg'], $slot['bg'])) {
|
||||
$classes[] = 'scope-dark';
|
||||
}
|
||||
// Dunkel oder hell steht immer ausdrücklich an der Hülle: Ein helles Widget in einem dunklen Abschnitt darf die
|
||||
// Regeln der dunklen Fläche nicht erben (scope-light ist dafür die Gegenmarke, siehe widgets.css).
|
||||
$classes[] = ColorContrast::isDarkSurface($slot['fg'], $slot['bg']) ? 'scope-dark' : 'scope-light';
|
||||
}
|
||||
|
||||
return $classes === [] ? '' : ' '.implode(' ', $classes);
|
||||
@@ -94,11 +95,11 @@ public static function classes(WidgetType $type, array $settings): string
|
||||
/**
|
||||
* Eigenschaften der Farbe als style-Attribut mit führendem Leerzeichen; leer ohne Farbe.
|
||||
*
|
||||
* @param array<string, mixed> $settings
|
||||
* @param array<string, mixed> $widget Hülle der Instanz (variant, settings)
|
||||
*/
|
||||
public static function style(WidgetType $type, array $settings): string
|
||||
public static function style(WidgetType $type, array $widget): string
|
||||
{
|
||||
$slot = self::slot($type, $settings);
|
||||
$slot = self::slot($type, $widget);
|
||||
|
||||
if ($slot === null) {
|
||||
return '';
|
||||
@@ -115,14 +116,14 @@ public static function style(WidgetType $type, array $settings): string
|
||||
/**
|
||||
* Die gewählte Farbe, wenn die Art sie anbietet und sie in der Palette noch vorhanden ist.
|
||||
*
|
||||
* @param array<string, mixed> $settings
|
||||
* @param array<string, mixed> $widget Hülle der Instanz (variant, settings)
|
||||
* @return array{id: string, name: string, bg: string, fg: string}|null
|
||||
*/
|
||||
public static function slot(WidgetType $type, array $settings): ?array
|
||||
public static function slot(WidgetType $type, array $widget): ?array
|
||||
{
|
||||
$id = $settings['palette'] ?? null;
|
||||
$id = is_array($widget['settings'] ?? null) ? ($widget['settings']['palette'] ?? null) : null;
|
||||
|
||||
if ($type->paletteTarget() === null || ! is_string($id)) {
|
||||
if ($type->paletteTarget($widget) === null || ! is_string($id)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public function typography(): array
|
||||
}
|
||||
|
||||
/** Farbe aus der Palette wirkt auf die eigene Fläche des Widgets (ADR-68). */
|
||||
public function paletteTarget(): ?string
|
||||
public function paletteTarget(array $widget = []): ?string
|
||||
{
|
||||
return 'face';
|
||||
}
|
||||
|
||||
@@ -81,10 +81,15 @@ public function typography(): array
|
||||
return ['heading', 'text'];
|
||||
}
|
||||
|
||||
/** Farbe aus der Palette wirkt auf die eigene Fläche des Widgets (ADR-68). */
|
||||
public function paletteTarget(): ?string
|
||||
/**
|
||||
* Farbe aus der Palette (ADR-68): Karten mit eigener Fläche nehmen die Farbe selbst an. Die kompakte Liste und Karten mit
|
||||
* Trennstrich haben keine Fläche; dort färbt die Farbe das ganze Widget, sonst stünde helle Schrift auf hellem Grund.
|
||||
*/
|
||||
public function paletteTarget(array $widget = []): ?string
|
||||
{
|
||||
return 'face';
|
||||
$flat = ($widget['variant'] ?? null) === 'compact' || ($widget['settings']['divider'] ?? null) === 'line';
|
||||
|
||||
return $flat ? 'hull' : 'face';
|
||||
}
|
||||
|
||||
public function key(): string
|
||||
|
||||
@@ -29,7 +29,7 @@ public function typography(): array
|
||||
}
|
||||
|
||||
/** Farbe aus der Palette wirkt auf die Fläche des ganzen Widgets (ADR-68). */
|
||||
public function paletteTarget(): ?string
|
||||
public function paletteTarget(array $widget = []): ?string
|
||||
{
|
||||
return 'hull';
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public function typography(): array
|
||||
}
|
||||
|
||||
/** Farbe aus der Palette wirkt auf die Fläche des ganzen Widgets (ADR-68). */
|
||||
public function paletteTarget(): ?string
|
||||
public function paletteTarget(array $widget = []): ?string
|
||||
{
|
||||
return 'hull';
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public function typography(): array
|
||||
}
|
||||
|
||||
/** Farbe aus der Palette wirkt auf die Fläche des ganzen Widgets (ADR-68). */
|
||||
public function paletteTarget(): ?string
|
||||
public function paletteTarget(array $widget = []): ?string
|
||||
{
|
||||
return 'hull';
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public function typography(): array
|
||||
}
|
||||
|
||||
/** Farbe aus der Palette wirkt auf die Fläche des ganzen Widgets (ADR-68). */
|
||||
public function paletteTarget(): ?string
|
||||
public function paletteTarget(array $widget = []): ?string
|
||||
{
|
||||
return 'hull';
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public function typography(): array
|
||||
}
|
||||
|
||||
/** Farbe aus der Palette wirkt auf die eigene Fläche des Widgets (ADR-68). */
|
||||
public function paletteTarget(): ?string
|
||||
public function paletteTarget(array $widget = []): ?string
|
||||
{
|
||||
return 'face';
|
||||
}
|
||||
@@ -352,7 +352,7 @@ public function resolve(array $widget, RenderContext $context): array
|
||||
'actions' => PremiumFields::actions($widget['data']),
|
||||
'focus' => PremiumFields::focus($widget['data'], 64, 43),
|
||||
// Eine gewählte Farbe aus der Palette (ADR-68) hat Vorrang vor „Hintergrund des Widgets“.
|
||||
'surface' => WidgetAppearance::slot($this, $widget['settings']) !== null ? 'palette' : (in_array($surface, ['cream', 'clear', 'navy'], true) ? $surface : 'cream'),
|
||||
'surface' => WidgetAppearance::slot($this, $widget) !== null ? 'palette' : (in_array($surface, ['cream', 'clear', 'navy'], true) ? $surface : 'cream'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ public function typography(): array
|
||||
}
|
||||
|
||||
/** Farbe aus der Palette wirkt auf die Fläche des ganzen Widgets (ADR-68). */
|
||||
public function paletteTarget(): ?string
|
||||
public function paletteTarget(array $widget = []): ?string
|
||||
{
|
||||
return 'hull';
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public function typography(): array
|
||||
}
|
||||
|
||||
/** Farbe aus der Palette wirkt auf die Fläche des ganzen Widgets (ADR-68). */
|
||||
public function paletteTarget(): ?string
|
||||
public function paletteTarget(array $widget = []): ?string
|
||||
{
|
||||
return 'hull';
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public function typography(): array
|
||||
}
|
||||
|
||||
/** Farbe aus der Palette wirkt auf die Fläche des ganzen Widgets (ADR-68). */
|
||||
public function paletteTarget(): ?string
|
||||
public function paletteTarget(array $widget = []): ?string
|
||||
{
|
||||
return 'hull';
|
||||
}
|
||||
|
||||
@@ -78,8 +78,8 @@ public function renderWidget(array $widget, RenderContext $context, bool $first
|
||||
$heightClass = $height !== null ? ' widget-height-'.e($height) : '';
|
||||
|
||||
// Schriftgrößen und Farbe (ADR-68): Klassen und Eigenschaften nur, wenn ein Wert gesetzt ist; sonst bleibt die Hülle unverändert.
|
||||
$appearance = WidgetAppearance::classes($type, $widget['settings']);
|
||||
$surface = WidgetAppearance::style($type, $widget['settings']);
|
||||
$appearance = WidgetAppearance::classes($type, $widget);
|
||||
$surface = WidgetAppearance::style($type, $widget);
|
||||
|
||||
return '<section class="block widget widget-'.e(str_replace('_', '-', $widget['type'])).' widget-variant-'.e(str_replace('_', '-', $widget['variant'])).$heightClass.$appearance.'"'.$id.$surface.'>'
|
||||
.$inner
|
||||
|
||||
@@ -233,9 +233,12 @@ public function typography(): array
|
||||
/**
|
||||
* Wo die Farbe aus der Palette (ADR-68) wirkt: 'hull' färbt die Fläche des ganzen Widgets (mit Innenabstand), 'face'
|
||||
* färbt die eigene Fläche des Widgets (Karten, Handlungsaufruf, Bild und Text, Hinweis), damit keine zweite Fläche
|
||||
* dahinter steht. Null: Das Widget bietet keine Farbe an.
|
||||
* dahinter steht. Null: Das Widget bietet keine Farbe an. Eine Art darf nach Variante und Einstellungen des Widgets
|
||||
* entscheiden (Karten ohne eigene Fläche färben das Widget, nicht die Karte); ohne Angabe gilt der Grundwert der Art.
|
||||
*
|
||||
* @param array<string, mixed> $widget Hülle der Instanz (variant, settings); leer für die Art allgemein
|
||||
*/
|
||||
public function paletteTarget(): ?string
|
||||
public function paletteTarget(array $widget = []): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user