Offers by their own rules, seasonal photos per section, theme authoring tooling
- Special offers: kinds (rule, fixed dates, gap filler), package price, priority, highlight;
GapFinder detects calendar gaps (optionally waiving the minimum stay); OfferShowcase decides
what the website advertises and prices fixed dates/gaps with PriceCalculator; offers section
shows them side by side, as a list or rotating; hero can show the top offer. Appearances no
longer carry a featured offer.
- Sections get stable ids; appearances set photos per section ("Bilder je Baustein") and
sections can be limited to appearances. Photo pickers show thumbnails everywhere.
- Themes: themes:make (scaffold, never overwrites), themes:check (contract, build, markup,
colours, external resources, WCAG contrast), themes:preview (signed links per page and
appearance), signed ?theme= preview and preview action in the site form, inherited colour
tokens in the admin. Base CSS split into theme.css + reusable theme-base.css.
- docs/THEME-ERSTELLUNG.md: binding guide for building additional themes elsewhere.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bc77b64ea7
commit
7d0bc93abc
50 files changed
+2805
-259
No files matched your search
@@ -2,13 +2,19 @@
|
||||
|
||||
namespace App\Themes;
|
||||
|
||||
use App\Models\Appearance;
|
||||
use App\Themes\Sections\Section;
|
||||
use Filament\Forms\Components\Builder\Block;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Support\Facades\View as ViewFactory;
|
||||
|
||||
/**
|
||||
* The section catalogue from config/themes.php: builder blocks for the admin and rendering for the website.
|
||||
*
|
||||
* Every placed section carries data.id (a stable UUID, see Page::assignSectionIds) so appearances can
|
||||
* address it, and data.appearances (appearance ids; empty = always shown).
|
||||
*/
|
||||
class SectionRegistry
|
||||
{
|
||||
@@ -36,13 +42,33 @@ public function blocks(): array
|
||||
{
|
||||
return array_values(array_map(
|
||||
fn (string $class): Block => Block::make($class::key())
|
||||
->label($class::label())
|
||||
->label(fn (?array $state): string => $this->blockLabel($class, $state))
|
||||
->icon($class::icon())
|
||||
->schema($class::schema()),
|
||||
->schema([
|
||||
Hidden::make('id'),
|
||||
...$class::schema(),
|
||||
Select::make('appearances')
|
||||
->label('Nur anzeigen im Erscheinungsbild')
|
||||
->helperText('Leer = immer anzeigen. Z. B. ein Weihnachts-Baustein nur im Erscheinungsbild „Weihnachten“.')
|
||||
->options(fn (): array => Appearance::query()->orderByDesc('is_default')->orderBy('name')->pluck('name', 'id')->all())
|
||||
->multiple(),
|
||||
]),
|
||||
$this->all(),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a placed section is shown with the active appearance.
|
||||
*
|
||||
* @param array<string, mixed> $data
|
||||
*/
|
||||
public function isVisible(Theme $theme, array $data): bool
|
||||
{
|
||||
$appearances = array_map('intval', array_filter((array) ($data['appearances'] ?? [])));
|
||||
|
||||
return $appearances === [] || ($theme->appearance !== null && in_array($theme->appearance->id, $appearances, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the stored sections of a page; unknown or failing types are skipped (and reported),
|
||||
* so a page never breaks because of one section.
|
||||
@@ -55,7 +81,7 @@ public function render(Theme $theme, ?array $sections): array
|
||||
$views = [];
|
||||
foreach ($sections ?? [] as $index => $stored) {
|
||||
$section = $this->get($stored['type'] ?? '');
|
||||
if ($section === null || ! ViewFactory::exists($section->view())) {
|
||||
if ($section === null || ! ViewFactory::exists($section->view()) || ! $this->isVisible($theme, $stored['data'] ?? [])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -68,4 +94,22 @@ public function render(Theme $theme, ?array $sections): array
|
||||
|
||||
return $views;
|
||||
}
|
||||
|
||||
/**
|
||||
* "Text mit Bild · Ihr Zuhause an der Ostsee · nur: Winter" for the collapsed builder item.
|
||||
*
|
||||
* @param class-string<Section> $class
|
||||
* @param array<string, mixed>|null $state
|
||||
*/
|
||||
private function blockLabel(string $class, ?array $state): string
|
||||
{
|
||||
if ($state === null) {
|
||||
return $class::label();
|
||||
}
|
||||
|
||||
$appearances = array_filter((array) ($state['appearances'] ?? []));
|
||||
$only = $appearances === [] ? null : 'nur: '.Appearance::query()->whereKey($appearances)->pluck('name')->implode(', ');
|
||||
|
||||
return collect([$class::label(), $class::summary($state), $only])->filter()->implode(' · ');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user