Richte Karten im Abschnitt an der größten Karte aus und setze Kartenlinks an den unteren Rand
Zwei Gestaltungswerte am Abschnitt (Höhe der Karten, Link in der Karte), gespeichert nur bei Abweichung von der Vorgabe. Karten nebeneinander füllen die Zeilenhöhe (CSS); ein kleines Skript gleicht Zeilen untereinander an. Links im Fließtext bleiben unberührt (ADR-66). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
33310463fd
commit
62f3a33541
16 files changed
+475
-2
No files matched your search
@@ -462,6 +462,13 @@ private function normalizeStyle(array $style, string $prefix, array &$errors): a
|
||||
$result[$key] = $value;
|
||||
}
|
||||
|
||||
// Ergänzende Optionen stehen nur bei Abweichung von der Vorgabe im gespeicherten Stand.
|
||||
foreach (SectionStyle::OPTIONAL as $key => $default) {
|
||||
if (($result[$key] ?? $default) === $default) {
|
||||
unset($result[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($result['background'] === 'image') {
|
||||
$widgetErrors = new WidgetErrors;
|
||||
$refs = ImageRefFields::clean(['image' => $style['image'] ?? null, '_upload' => $style['_upload'] ?? null], $widgetErrors, errorKey: 'image');
|
||||
|
||||
@@ -132,6 +132,15 @@ private function renderSection(array $section, array $cells, int $index, RenderC
|
||||
$classes[] = 'section-overlay-'.$style['overlay'];
|
||||
}
|
||||
|
||||
// Karten im Abschnitt (ADR-66): nur bei Abweichung von der Vorgabe, damit die Ausgabe bestehender Seiten gleich bleibt.
|
||||
if ($style['cards_height'] === 'equal') {
|
||||
$classes[] = 'section-cards-equal';
|
||||
}
|
||||
|
||||
if ($style['cards_links'] === 'bottom') {
|
||||
$classes[] = 'section-cards-links-bottom';
|
||||
}
|
||||
|
||||
// Bedeutungswerte der Fläche (tokens.css): helle Schrift auf dunklen Flächen, gelber Fokus.
|
||||
$scope = match (true) {
|
||||
$hasImage && $style['overlay'] === 'dark' => 'scope-dark',
|
||||
|
||||
@@ -85,6 +85,27 @@ final class SectionStyle
|
||||
'bottom_right' => '100% 100%',
|
||||
];
|
||||
|
||||
/**
|
||||
* Karten im Abschnitt (ADR-66): Höhe aller Karten des Abschnitts. „Gleich hoch“ richtet alle Karten an der größten aus.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public const CARD_HEIGHTS = [
|
||||
'auto' => 'Nach Inhalt der Karte',
|
||||
'equal' => 'Alle so hoch wie die größte Karte',
|
||||
];
|
||||
|
||||
/**
|
||||
* Karten im Abschnitt (ADR-66): Lage des Links in Karten mit eigenem Link (Schaltfläche, „Mehr erfahren“). Links im
|
||||
* Fließtext einer Karte bleiben, wo sie stehen.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public const CARD_LINKS = [
|
||||
'text' => 'Direkt unter dem Text',
|
||||
'bottom' => 'Am unteren Rand der Karte',
|
||||
];
|
||||
|
||||
public const DEFAULTS = [
|
||||
'background' => 'default',
|
||||
'image' => null,
|
||||
@@ -97,6 +118,15 @@ final class SectionStyle
|
||||
'divider' => 'none',
|
||||
];
|
||||
|
||||
/**
|
||||
* Ergänzende Gestaltungsoptionen: Sie stehen nur im gespeicherten Stand, wenn sie von der Vorgabe abweichen, damit
|
||||
* Abschnitte ohne diese Optionen unverändert bleiben (Format und Vergleich mit dem letzten Stand).
|
||||
*/
|
||||
public const OPTIONAL = [
|
||||
'cards_height' => 'auto',
|
||||
'cards_links' => 'text',
|
||||
];
|
||||
|
||||
/**
|
||||
* Aufzählungsfelder und ihre zulässigen Werte.
|
||||
*
|
||||
@@ -113,6 +143,8 @@ public static function enums(): array
|
||||
'spacing_bottom' => self::SPACINGS,
|
||||
'gap' => self::SPACINGS,
|
||||
'divider' => self::DIVIDERS,
|
||||
'cards_height' => self::CARD_HEIGHTS,
|
||||
'cards_links' => self::CARD_LINKS,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -120,12 +152,12 @@ public static function enums(): array
|
||||
* Lesepfad: gespeicherte Werte; Unbekanntes fällt auf die Vorgabe zurück, damit alte oder fremde Daten
|
||||
* nie eine Seite brechen.
|
||||
*
|
||||
* @return array{background: string, image: ?string, focus: string, overlay: string, width: string, spacing_top: string, spacing_bottom: string, gap: string, divider: string}
|
||||
* @return array{background: string, image: ?string, focus: string, overlay: string, width: string, spacing_top: string, spacing_bottom: string, gap: string, divider: string, cards_height: string, cards_links: string}
|
||||
*/
|
||||
public static function fromStored(mixed $style): array
|
||||
{
|
||||
$style = is_array($style) ? $style : [];
|
||||
$result = self::DEFAULTS;
|
||||
$result = self::DEFAULTS + self::OPTIONAL;
|
||||
|
||||
foreach (self::enums() as $key => $options) {
|
||||
$value = $style[$key] ?? null;
|
||||
@@ -166,6 +198,14 @@ public static function summary(array $style): string
|
||||
$parts[] = 'Trenner: '.self::DIVIDERS[$style['divider']];
|
||||
}
|
||||
|
||||
if ($style['cards_height'] === 'equal') {
|
||||
$parts[] = 'Karten gleich hoch';
|
||||
}
|
||||
|
||||
if ($style['cards_links'] === 'bottom') {
|
||||
$parts[] = 'Kartenlinks unten';
|
||||
}
|
||||
|
||||
return implode(' · ', $parts);
|
||||
}
|
||||
|
||||
|
||||
@@ -148,6 +148,15 @@ private static function sectionSchema(): array
|
||||
->schema([
|
||||
Group::make(self::spacingFields())->statePath('style')->columns(['default' => 1, 'md' => 2]),
|
||||
]),
|
||||
Section::make('Karten')
|
||||
->description('Gilt für alle Karten dieses Abschnitts (Karten, Programm-, Modul-, Medien- und Themenkarten).')
|
||||
->extraAttributes(['class' => 'luf-nur-gestalten luf-gestaltung'])
|
||||
->collapsible(fn ($livewire): bool => ! self::onWorkplace($livewire))
|
||||
->collapsed(fn ($livewire): bool => ! self::onWorkplace($livewire))
|
||||
->compact()
|
||||
->schema([
|
||||
Group::make(self::cardFields())->statePath('style')->columns(['default' => 1, 'md' => 2]),
|
||||
]),
|
||||
Repeater::make('slots')
|
||||
->columnSpanFull()
|
||||
->label('Plätze im Raster')
|
||||
@@ -380,6 +389,29 @@ private static function backgroundFields(): array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Karten im Abschnitt: Höhe und Lage der Links.
|
||||
*
|
||||
* @return list<mixed>
|
||||
*/
|
||||
private static function cardFields(): array
|
||||
{
|
||||
return [
|
||||
Select::make('cards_height')
|
||||
->label('Höhe der Karten')
|
||||
->options(SectionStyle::CARD_HEIGHTS)
|
||||
->default(SectionStyle::OPTIONAL['cards_height'])
|
||||
->selectablePlaceholder(false)
|
||||
->hintIcon('heroicon-o-question-mark-circle', '„Alle so hoch wie die größte Karte“: Karten nebeneinander und untereinander in diesem Abschnitt werden so hoch wie die höchste. Auf schmalen Bildschirmen, wo die Karten untereinander stehen, behalten sie ihre eigene Höhe.'),
|
||||
Select::make('cards_links')
|
||||
->label('Link in der Karte')
|
||||
->options(SectionStyle::CARD_LINKS)
|
||||
->default(SectionStyle::OPTIONAL['cards_links'])
|
||||
->selectablePlaceholder(false)
|
||||
->hintIcon('heroicon-o-question-mark-circle', 'Gilt für Karten mit eigenem Link („Mehr erfahren“, Schaltfläche). „Am unteren Rand“ macht die Karten einer Zeile gleich hoch und setzt die Links auf eine Linie am unteren Kartenrand. Links im Fließtext einer Karte bleiben, wo sie stehen.'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<mixed>
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user