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,6 +2,7 @@
|
||||
|
||||
namespace App\Themes\Sections;
|
||||
|
||||
use App\Filament\Forms\Components\PhotoSelect;
|
||||
use App\Models\Page;
|
||||
use App\Models\Photo;
|
||||
use App\Themes\Theme;
|
||||
@@ -17,6 +18,15 @@
|
||||
*/
|
||||
abstract class Section
|
||||
{
|
||||
/** One photo (field holds a photo id). */
|
||||
public const SLOT_SINGLE = 'single';
|
||||
|
||||
/** Several chosen photos (field holds a list of ids). */
|
||||
public const SLOT_MULTIPLE = 'multiple';
|
||||
|
||||
/** Photos picked automatically (e.g. by category); an appearance may replace or precede them. */
|
||||
public const SLOT_COLLECTION = 'collection';
|
||||
|
||||
abstract public static function key(): string;
|
||||
|
||||
abstract public static function label(): string;
|
||||
@@ -39,6 +49,28 @@ public static function schema(): array
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Photo places an appearance can fill with seasonal photos ("Bilder je Baustein").
|
||||
*
|
||||
* @return array<string, array{label: string, type: string, max?: int}>
|
||||
*/
|
||||
public static function photoSlots(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Short text identifying a placed section in admin lists, e.g. its heading.
|
||||
*
|
||||
* @param array<string, mixed> $data
|
||||
*/
|
||||
public static function summary(array $data): ?string
|
||||
{
|
||||
$text = $data['heading'] ?? $data['title'] ?? null;
|
||||
|
||||
return filled($text) ? str(strip_tags((string) $text))->replace('*', '')->limit(50)->toString() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Variables for the view.
|
||||
*
|
||||
@@ -75,6 +107,55 @@ protected function photos(?array $ids): Collection
|
||||
return new Collection(array_values(array_filter(array_map(fn ($id) => $photos->get((int) $id), $ids))));
|
||||
}
|
||||
|
||||
/**
|
||||
* The seasonal photo the active appearance sets for a single slot of this placed section.
|
||||
*
|
||||
* @param array<string, mixed> $data
|
||||
*/
|
||||
protected function seasonalPhoto(Theme $theme, array $data, string $slot): ?Photo
|
||||
{
|
||||
return $this->seasonalPhotos($theme, $data, $slot)?->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* The seasonal photos the active appearance sets for a slot of this placed section, null if none.
|
||||
*
|
||||
* @param array<string, mixed> $data
|
||||
* @return Collection<int, Photo>|null
|
||||
*/
|
||||
protected function seasonalPhotos(Theme $theme, array $data, string $slot): ?Collection
|
||||
{
|
||||
$ids = $theme->sectionPhotoIds($data['id'] ?? null, $slot);
|
||||
if ($ids === []) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$photos = $this->photos($ids);
|
||||
|
||||
return $photos->isEmpty() ? null : $photos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Photos of a collection slot: the automatic photos, replaced or preceded by the seasonal ones.
|
||||
*
|
||||
* @param array<string, mixed> $data
|
||||
* @param Collection<int, Photo> $automatic
|
||||
* @return Collection<int, Photo>
|
||||
*/
|
||||
protected function withSeasonalPhotos(Theme $theme, array $data, string $slot, Collection $automatic): Collection
|
||||
{
|
||||
$seasonal = $this->seasonalPhotos($theme, $data, $slot);
|
||||
if ($seasonal === null) {
|
||||
return $automatic;
|
||||
}
|
||||
|
||||
if ($theme->sectionPhotoMode($data['id'] ?? null) === 'prepend') {
|
||||
return $seasonal->merge($automatic)->unique('id')->values();
|
||||
}
|
||||
|
||||
return $seasonal;
|
||||
}
|
||||
|
||||
protected function pageUrl(?string $slug): ?string
|
||||
{
|
||||
if (blank($slug)) {
|
||||
@@ -85,15 +166,13 @@ protected function pageUrl(?string $slug): ?string
|
||||
}
|
||||
|
||||
/**
|
||||
* Select field listing the website photos.
|
||||
* Select field listing the website photos with thumbnails.
|
||||
*/
|
||||
protected static function photoSelect(string $name, string $label, bool $multiple = false): Select
|
||||
{
|
||||
return Select::make($name)
|
||||
return PhotoSelect::make($name)
|
||||
->label($label)
|
||||
->options(fn (): array => Photo::query()->orderBy('category')->orderBy('sort_order')->pluck('alt_text', 'id')->all())
|
||||
->multiple($multiple)
|
||||
->searchable();
|
||||
->multiple($multiple);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user