Verdichte Seitenaufbau und Abschnittsgestaltung im CMS
- Seitenaufbau: Bausteine als Miniaturvorschau in Desktop-Proportion (verkleinert, Höhe begrenzt); Abschnittskopf „Abschnitt N“ mit knapper Angabe zu Raster und abweichender Gestaltung, vollständig im Titel; Plätze ohne eigenen Kopf, nur über Lage und Breite; Aktionen benennen Abschnitt oder Baustein. - Seitenkopf kompakter; Erläuterungen als aufrufbare Hilfe; kein Rahmen „Inhalt der Seite“, keine leeren Abstände ausgeblendeter Teile. - „Abschnitt gestalten“: knappe Leiste mit „Zum Seitenaufbau“ und Hilfe, keine wiederholte Zusammenfassung; Einstellungen in Raster und Breite, Hintergrund, Abstände und Trenner; Erklärungen als Hinweis. Rückkehr an den Abschnitt. - Tests: Gruppen speichern gemeinsam; Texte bewusst angepasst. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
dd3ee39f69
commit
5548106c31
10 files changed
+322
-110
No files matched your search
@@ -37,7 +37,8 @@ public static function repeater(string $name = 'sections'): Repeater
|
||||
->label('Abschnitte')
|
||||
->hiddenLabel()
|
||||
->schema(self::sectionSchema())
|
||||
->itemLabel(fn (array $state, ?int $index): string => self::sectionLabel($state, $index))
|
||||
->columns(['default' => 1, 'xl' => 2])
|
||||
->itemLabel(fn (array $state, ?int $index): HtmlString => self::sectionLabel($state, $index))
|
||||
->addActionLabel('Abschnitt hinzufügen')
|
||||
->addBetweenActionLabel('Abschnitt hier einfügen')
|
||||
->defaultItems(0)
|
||||
@@ -48,6 +49,7 @@ public static function repeater(string $name = 'sections'): Repeater
|
||||
->deletable()
|
||||
->maxItems(PageSections::MAX_SECTIONS)
|
||||
->cloneAction(fn (Action $action): Action => $action
|
||||
->label('Abschnitt duplizieren')
|
||||
->tooltip('Abschnitt duplizieren')
|
||||
->action(function (array $arguments, Repeater $component): void {
|
||||
// Die Kopie steht direkt hinter dem Original (Filament hängt sie sonst ans Seitenende).
|
||||
@@ -56,14 +58,15 @@ public static function repeater(string $name = 'sections'): Repeater
|
||||
$component->shouldPartiallyRenderAfterActionsCalled() ? $component->partiallyRender() : null;
|
||||
}))
|
||||
->deleteAction(fn (Action $action): Action => $action
|
||||
->label('Abschnitt löschen')
|
||||
->tooltip('Abschnitt löschen')
|
||||
->requiresConfirmation()
|
||||
->modalHeading('Abschnitt löschen?')
|
||||
->modalDescription('Der Abschnitt und die Widgets darin werden aus dem Entwurf entfernt. Bereits gespeicherte Revisionen bleiben erhalten.')
|
||||
->modalSubmitActionLabel('Löschen'))
|
||||
->moveUpAction(fn (Action $action): Action => $action->tooltip('Abschnitt nach oben'))
|
||||
->moveDownAction(fn (Action $action): Action => $action->tooltip('Abschnitt nach unten'))
|
||||
->reorderAction(fn (Action $action): Action => $action->tooltip('Abschnitt ziehen'))
|
||||
->moveUpAction(fn (Action $action): Action => $action->label('Abschnitt nach oben')->tooltip('Abschnitt nach oben'))
|
||||
->moveDownAction(fn (Action $action): Action => $action->label('Abschnitt nach unten')->tooltip('Abschnitt nach unten'))
|
||||
->reorderAction(fn (Action $action): Action => $action->label('Abschnitt ziehen')->tooltip('Abschnitt ziehen'))
|
||||
->extraItemActions([
|
||||
// Seiten-Arbeitsplatz (EditPage): Raster und Gestaltung im eigenen Kontext statt an jedem Abschnitt.
|
||||
Action::make('gestalten')
|
||||
@@ -75,8 +78,8 @@ public static function repeater(string $name = 'sections'): Repeater
|
||||
->visible(fn ($livewire): bool => is_object($livewire) && method_exists($livewire, 'openAbschnitt'))
|
||||
->action(fn (array $arguments, Repeater $component) => $component->getLivewire()->openAbschnitt((string) $arguments['item'])),
|
||||
])
|
||||
->collapseAction(fn (Action $action): Action => $action->tooltip('Abschnitt einklappen'))
|
||||
->expandAction(fn (Action $action): Action => $action->tooltip('Abschnitt aufklappen'))
|
||||
->collapseAction(fn (Action $action): Action => $action->label('Abschnitt einklappen')->tooltip('Abschnitt einklappen'))
|
||||
->expandAction(fn (Action $action): Action => $action->label('Abschnitt aufklappen')->tooltip('Abschnitt aufklappen'))
|
||||
->extraAttributes(['class' => 'luf-sections'])
|
||||
->columnSpanFull();
|
||||
}
|
||||
@@ -88,36 +91,50 @@ private static function sectionSchema(): array
|
||||
{
|
||||
return [
|
||||
Hidden::make('id'),
|
||||
ToggleButtons::make('layout')
|
||||
->label('Raster')
|
||||
->options(self::layoutOptions())
|
||||
->default(SectionLayouts::DEFAULT)
|
||||
->required()
|
||||
->inline()
|
||||
->live()
|
||||
->disableOptionWhen(fn (string $value, Get $get): bool => self::filledCount($get('slots')) > SectionLayouts::slotCount($value))
|
||||
->helperText(fn (Get $get): ?string => self::filledCount($get('slots')) > 1
|
||||
? 'Raster mit weniger Plätzen als eingesetzten Widgets sind gesperrt. Entfernen oder verschieben Sie zuerst ein Widget; beim Wechsel geht kein Widget verloren.'
|
||||
: null)
|
||||
->afterStateUpdated(function (?string $state, Get $get, Set $set): void {
|
||||
$set('slots', self::arrangeSlots($get('slots'), $state ?? SectionLayouts::DEFAULT));
|
||||
})
|
||||
->extraAttributes(['class' => 'luf-layout-picker'])
|
||||
->extraFieldWrapperAttributes(['class' => 'luf-nur-gestalten']),
|
||||
Section::make('Gestaltung des Abschnitts')
|
||||
->description(fn (Get $get): string => SectionStyle::summary(is_array($get('style')) ? $get('style') : []))
|
||||
->icon('heroicon-o-swatch')
|
||||
// Im Seiten-Arbeitsplatz nur im Kontext „Abschnitt gestalten“ sichtbar und dort aufgeklappt.
|
||||
->collapsible(fn ($livewire): bool => ! (is_object($livewire) && method_exists($livewire, 'openAbschnitt')))
|
||||
->collapsed(fn ($livewire): bool => ! (is_object($livewire) && method_exists($livewire, 'openAbschnitt')))
|
||||
->extraAttributes(['class' => 'luf-nur-gestalten'])
|
||||
// Abschnittsgestaltung in drei Gruppen. Im Seiten-Arbeitsplatz nur im Kontext „Abschnitt gestalten“
|
||||
// sichtbar und dort offen; beim Anlegen einer Seite an jedem Abschnitt, eingeklappt.
|
||||
Section::make('Raster und Breite')
|
||||
->columnSpanFull()
|
||||
->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::styleFields())
|
||||
->statePath('style')
|
||||
->columns(['default' => 1, 'md' => 2, 'xl' => 4]),
|
||||
ToggleButtons::make('layout')
|
||||
->label('Raster')
|
||||
->options(self::layoutOptions())
|
||||
->default(SectionLayouts::DEFAULT)
|
||||
->required()
|
||||
->inline()
|
||||
->live()
|
||||
->disableOptionWhen(fn (string $value, Get $get): bool => self::filledCount($get('slots')) > SectionLayouts::slotCount($value))
|
||||
->helperText(fn (Get $get): ?string => self::filledCount($get('slots')) > 1
|
||||
? 'Raster mit weniger Plätzen als eingesetzten Widgets sind gesperrt. Entfernen oder verschieben Sie zuerst ein Widget; beim Wechsel geht kein Widget verloren.'
|
||||
: null)
|
||||
->afterStateUpdated(function (?string $state, Get $get, Set $set): void {
|
||||
$set('slots', self::arrangeSlots($get('slots'), $state ?? SectionLayouts::DEFAULT));
|
||||
})
|
||||
->extraAttributes(['class' => 'luf-layout-picker']),
|
||||
Group::make([self::widthField()])->statePath('style')->columns(['default' => 1, 'md' => 2]),
|
||||
]),
|
||||
Section::make('Hintergrund')
|
||||
->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::backgroundFields())->statePath('style')->columns(['default' => 1, 'md' => 2]),
|
||||
]),
|
||||
Section::make('Abstände und Trenner')
|
||||
->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::spacingFields())->statePath('style')->columns(['default' => 1, 'md' => 2]),
|
||||
]),
|
||||
Repeater::make('slots')
|
||||
->columnSpanFull()
|
||||
->label('Plätze im Raster')
|
||||
->hiddenLabel()
|
||||
->schema([
|
||||
@@ -127,8 +144,8 @@ private static function sectionSchema(): array
|
||||
->deletable(false)
|
||||
->reorderableWithDragAndDrop()
|
||||
->reorderableWithButtons(false)
|
||||
->reorderAction(fn (Action $action): Action => $action->tooltip('Widget auf einen anderen Platz ziehen'))
|
||||
->itemLabel(fn (array $state, ?int $index, Get $get): string => self::slotLabel($state, $index, $get('layout')))
|
||||
->reorderAction(fn (Action $action): Action => $action->label('Baustein auf einen anderen Platz ziehen')->tooltip('Baustein auf einen anderen Platz ziehen'))
|
||||
->itemLabel(fn (array $state, ?int $index, Get $get): HtmlString => self::slotLabel($state, $index, $get('layout')))
|
||||
->default(fn (): array => self::arrangeSlots([], SectionLayouts::DEFAULT))
|
||||
->extraAttributes(fn (Get $get): array => [
|
||||
'class' => 'luf-slots',
|
||||
@@ -137,10 +154,27 @@ private static function sectionSchema(): array
|
||||
];
|
||||
}
|
||||
|
||||
private static function onWorkplace(mixed $livewire): bool
|
||||
{
|
||||
return is_object($livewire) && method_exists($livewire, 'openAbschnitt');
|
||||
}
|
||||
|
||||
private static function widthField(): Select
|
||||
{
|
||||
return Select::make('width')
|
||||
->label('Inhaltsbreite')
|
||||
->options(SectionStyle::WIDTHS)
|
||||
->default('standard')
|
||||
->selectablePlaceholder(false)
|
||||
->hintIcon('heroicon-o-question-mark-circle', 'Ein Hintergrund reicht immer über die ganze Bildschirmbreite.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Hintergrund; Bild, Ausschnitt und Überlagerung nur beim Hintergrund „Bild“.
|
||||
*
|
||||
* @return list<mixed>
|
||||
*/
|
||||
private static function styleFields(): array
|
||||
private static function backgroundFields(): array
|
||||
{
|
||||
return [
|
||||
Select::make('background')
|
||||
@@ -149,35 +183,6 @@ private static function styleFields(): array
|
||||
->default('default')
|
||||
->selectablePlaceholder(false)
|
||||
->live(),
|
||||
Select::make('width')
|
||||
->label('Breite')
|
||||
->options(SectionStyle::WIDTHS)
|
||||
->default('standard')
|
||||
->selectablePlaceholder(false)
|
||||
->helperText('Ein Hintergrund reicht immer über die ganze Bildschirmbreite.'),
|
||||
Select::make('spacing_top')
|
||||
->label('Abstand oben')
|
||||
->options(SectionStyle::SPACINGS)
|
||||
->default(SectionStyle::DEFAULTS['spacing_top'])
|
||||
->selectablePlaceholder(false)
|
||||
->helperText('Vor dem Inhalt. Zwischen zwei Abschnitten addieren sich „unten“ und „oben“; „Kein Abstand“ lässt einen Einstieg direkt unter der Kopfzeile beginnen.'),
|
||||
Select::make('spacing_bottom')
|
||||
->label('Abstand unten')
|
||||
->options(SectionStyle::SPACINGS)
|
||||
->default(SectionStyle::DEFAULTS['spacing_bottom'])
|
||||
->selectablePlaceholder(false)
|
||||
->helperText('Nach dem Inhalt. Bei eigener Fläche liegen beide Abstände innerhalb der Fläche.'),
|
||||
Select::make('gap')
|
||||
->label('Widget-Abstand')
|
||||
->options(SectionStyle::SPACINGS)
|
||||
->default(SectionStyle::DEFAULTS['gap'])
|
||||
->selectablePlaceholder(false)
|
||||
->helperText('Zwischen den Plätzen dieses Abschnitts, nebeneinander und gestapelt. Abstände innerhalb eines Widgets bleiben Sache des Widgets.'),
|
||||
Select::make('divider')
|
||||
->label('Trenner zum nächsten Abschnitt')
|
||||
->options(SectionStyle::DIVIDERS)
|
||||
->default('none')
|
||||
->selectablePlaceholder(false),
|
||||
...array_map(
|
||||
fn ($field) => $field->visible(fn (Get $get): bool => $get('background') === 'image')->columnSpan(['default' => 1, 'md' => 2]),
|
||||
ImageRefFields::fields('Hintergrundbild'),
|
||||
@@ -187,18 +192,50 @@ private static function styleFields(): array
|
||||
->options(SectionStyle::FOCUS)
|
||||
->default('center')
|
||||
->selectablePlaceholder(false)
|
||||
->helperText('Dieser Bereich bleibt auf schmalen Bildschirmen sichtbar.')
|
||||
->hintIcon('heroicon-o-question-mark-circle', 'Dieser Bereich bleibt auf schmalen Bildschirmen sichtbar.')
|
||||
->visible(fn (Get $get): bool => $get('background') === 'image'),
|
||||
Select::make('overlay')
|
||||
->label('Überlagerung')
|
||||
->options(SectionStyle::OVERLAYS)
|
||||
->default('light')
|
||||
->selectablePlaceholder(false)
|
||||
->helperText('Sorgt für lesbaren Text auf dem Bild.')
|
||||
->hintIcon('heroicon-o-question-mark-circle', 'Sorgt für lesbaren Text auf dem Bild.')
|
||||
->visible(fn (Get $get): bool => $get('background') === 'image'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<mixed>
|
||||
*/
|
||||
private static function spacingFields(): array
|
||||
{
|
||||
return [
|
||||
Select::make('spacing_top')
|
||||
->label('Abstand oben')
|
||||
->options(SectionStyle::SPACINGS)
|
||||
->default(SectionStyle::DEFAULTS['spacing_top'])
|
||||
->selectablePlaceholder(false)
|
||||
->hintIcon('heroicon-o-question-mark-circle', 'Vor dem Inhalt. Zwischen zwei Abschnitten addieren sich „unten“ und „oben“; „Kein Abstand“ lässt einen Einstieg direkt unter der Kopfzeile beginnen.'),
|
||||
Select::make('spacing_bottom')
|
||||
->label('Abstand unten')
|
||||
->options(SectionStyle::SPACINGS)
|
||||
->default(SectionStyle::DEFAULTS['spacing_bottom'])
|
||||
->selectablePlaceholder(false)
|
||||
->hintIcon('heroicon-o-question-mark-circle', 'Nach dem Inhalt. Bei eigener Fläche liegen beide Abstände innerhalb der Fläche.'),
|
||||
Select::make('gap')
|
||||
->label('Widget-Abstand')
|
||||
->options(SectionStyle::SPACINGS)
|
||||
->default(SectionStyle::DEFAULTS['gap'])
|
||||
->selectablePlaceholder(false)
|
||||
->hintIcon('heroicon-o-question-mark-circle', 'Zwischen den Plätzen dieses Abschnitts, nebeneinander und gestapelt. Abstände innerhalb eines Widgets bleiben Sache des Widgets.'),
|
||||
Select::make('divider')
|
||||
->label('Trenner zum nächsten Abschnitt')
|
||||
->options(SectionStyle::DIVIDERS)
|
||||
->default('none')
|
||||
->selectablePlaceholder(false),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gespeicherte Abschnitte (PageSections::read) als Formularzustand.
|
||||
*
|
||||
@@ -495,7 +532,7 @@ private static function editorColumns(mixed $layout): string
|
||||
/**
|
||||
* @param array<string, mixed> $state
|
||||
*/
|
||||
private static function sectionLabel(array $state, ?int $index): string
|
||||
private static function sectionLabel(array $state, ?int $index): HtmlString
|
||||
{
|
||||
$layout = SectionLayouts::has($state['layout'] ?? null) ? $state['layout'] : SectionLayouts::DEFAULT;
|
||||
$registry = app(WidgetRegistry::class);
|
||||
@@ -509,16 +546,48 @@ private static function sectionLabel(array $state, ?int $index): string
|
||||
}
|
||||
}
|
||||
|
||||
$label = 'Abschnitt '.(($index ?? 0) + 1).' · Raster '.SectionLayouts::short($layout)
|
||||
.' · '.SectionStyle::summary(is_array($state['style'] ?? null) ? $state['style'] : []);
|
||||
// Kurz sichtbar: Nummer, Raster und nur abweichende Gestaltung. Vollständig im Titel und für Screenreader.
|
||||
$style = SectionStyle::fromStored(is_array($state['style'] ?? null) ? $state['style'] : []);
|
||||
$meta = ['Raster '.SectionLayouts::short($layout)];
|
||||
if ($style['background'] !== 'default') {
|
||||
$meta[] = SectionStyle::BACKGROUNDS[$style['background']] ?? $style['background'];
|
||||
}
|
||||
if ($style['width'] !== 'standard') {
|
||||
$meta[] = SectionStyle::WIDTHS[$style['width']] ?? $style['width'];
|
||||
}
|
||||
if ($style['divider'] !== 'none') {
|
||||
$meta[] = 'Trenner';
|
||||
}
|
||||
if ($names === []) {
|
||||
$meta[] = 'noch leer';
|
||||
}
|
||||
|
||||
return $names === [] ? $label.' · noch leer' : $label.' · '.implode(', ', $names);
|
||||
$name = 'Abschnitt '.(($index ?? 0) + 1);
|
||||
$full = 'Raster '.SectionLayouts::short($layout).' · '.SectionStyle::summary($style)
|
||||
.($names === [] ? ' · noch leer' : ' · '.implode(', ', $names));
|
||||
|
||||
return new HtmlString('<span class="luf-abschnitt" title="'.e($full).'"><span class="luf-abschnitt-nr">'.e($name).'</span>'
|
||||
.'<span class="luf-abschnitt-meta" aria-hidden="true">'.e(implode(' · ', $meta)).'</span>'
|
||||
.'<span class="vw-sr">: '.e($full).'</span></span>');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $state
|
||||
*/
|
||||
private static function slotLabel(array $state, ?int $index, mixed $layout): string
|
||||
private static function slotLabel(array $state, ?int $index, mixed $layout): HtmlString
|
||||
{
|
||||
$text = self::slotText($state, $index, $layout);
|
||||
|
||||
// Plätze zeigen sich über Lage und Breite; benannt werden sie nur für Screenreader oder bei einem Problem.
|
||||
return str_contains($text, 'passt nicht') || str_contains($text, 'außerhalb')
|
||||
? new HtmlString('<span class="luf-platz-warnung">'.e($text).'</span>')
|
||||
: new HtmlString('<span class="vw-sr">'.e($text).'</span>');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $state
|
||||
*/
|
||||
private static function slotText(array $state, ?int $index, mixed $layout): string
|
||||
{
|
||||
$layout = SectionLayouts::has($layout) ? $layout : SectionLayouts::DEFAULT;
|
||||
$units = SectionLayouts::units($layout);
|
||||
|
||||
Reference in new issue
Block a user