Nimm die Symbolbibliothek mit Katalog auf: 58 neue Symbole, Titel und Gruppen je Schlüssel
Import mit stabilen Schlüsseln (kebab-case, _v03 vor Grundfassung, Alternativen und .old ausgelassen), Grenzen neu gemessen, HeadingAccent::symbols() liest aus dem Katalog. Die 16 bisherigen Schlüssel bleiben gültig; acht gleichnamige Dateien der Bibliothek ersetzen den alten Satz nicht. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
580b27451c
commit
edca8e864c
222 files changed
+1329
-35
No files matched your search
@@ -2,32 +2,27 @@
|
||||
|
||||
namespace App\Domain\Cms\Widgets\Support;
|
||||
|
||||
use App\Support\Brand\SymbolCatalog;
|
||||
|
||||
/**
|
||||
* Zulässige Kleingrafiken des Brand-Kits als Auswahl im CMS (ADR-30: nur feste Werte, nie freie Dateinamen).
|
||||
*
|
||||
* Die Schlüssel sind Dateinamen aus resources/svg/brand/symbole/. Nicht angeboten werden die gelbe Unterstreichung
|
||||
* (eigene Einstellung „Pinselstrich“) und die Signalstrahlen (Markenakzent des Einstiegs). Eine Prüfung im Test stellt
|
||||
* sicher, dass jeder Schlüssel eine vorhandene Datei hat.
|
||||
* Die Schlüssel sind Dateinamen aus resources/svg/brand/symbole/, Titel und Gruppen stehen im Katalog
|
||||
* (App\Support\Brand\SymbolCatalog, Datei _katalog.json). Nicht angeboten werden die gelbe Unterstreichung (eigene
|
||||
* Einstellung „Pinselstrich“) und die Signalstrahlen (Markenakzent des Einstiegs). Eine Prüfung im Test stellt sicher,
|
||||
* dass jeder Schlüssel eine vorhandene Datei und einen Katalogeintrag hat.
|
||||
*/
|
||||
final class HeadingAccent
|
||||
{
|
||||
/** @var array<string, string> */
|
||||
public const SYMBOLS = [
|
||||
'bildung' => 'Bildung',
|
||||
'buch' => 'Buch',
|
||||
'download' => 'Download',
|
||||
'filmklappe' => 'Filmklappe',
|
||||
'filmstreifen' => 'Filmstreifen',
|
||||
'gruppe' => 'Gruppe',
|
||||
'merkblatt' => 'Merkblatt',
|
||||
'muskelarm' => 'Starker Arm',
|
||||
'paket' => 'Paket',
|
||||
'pause-hand' => 'Pause (Hand)',
|
||||
'play' => 'Abspielen',
|
||||
'schutzschild' => 'Schutzschild',
|
||||
'sprechblase-fragezeichen' => 'Frage (Sprechblase)',
|
||||
'uebungsblatt' => 'Übungsblatt',
|
||||
];
|
||||
/**
|
||||
* Angebotene Symbole: Schlüssel => Titel, geordnet nach Gruppe. Einzige Quelle für Prüfung und Auswahl.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function symbols(): array
|
||||
{
|
||||
return SymbolCatalog::options();
|
||||
}
|
||||
|
||||
/** @var array<string, string> */
|
||||
public const BRUSH = ['brush' => 'Gelber Pinselstrich unter der Überschrift'];
|
||||
@@ -156,7 +151,7 @@ public static function symbol(array $settings): ?string
|
||||
{
|
||||
$name = $settings['symbol'] ?? null;
|
||||
|
||||
return is_string($name) && array_key_exists($name, self::SYMBOLS) ? $name : null;
|
||||
return is_string($name) && array_key_exists($name, self::symbols()) ? $name : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -94,7 +94,7 @@ public function dataFields(): array
|
||||
public function settings(): array
|
||||
{
|
||||
return [
|
||||
'symbol' => HeadingAccent::SYMBOLS,
|
||||
'symbol' => HeadingAccent::symbols(),
|
||||
'symbol_size' => HeadingAccent::SIZE,
|
||||
'symbol_align' => HeadingAccent::ALIGN,
|
||||
'accent' => HeadingAccent::BRUSH,
|
||||
|
||||
@@ -88,7 +88,7 @@ public function dataRules(): array
|
||||
'items.*.title' => ['required', 'string', 'max:120'],
|
||||
'items.*.text' => ['nullable', 'string', 'max:500'],
|
||||
'items.*.url' => ['nullable', 'string', 'max:500'],
|
||||
'items.*.symbol' => ['nullable', 'string', Rule::in(array_keys(HeadingAccent::SYMBOLS))],
|
||||
'items.*.symbol' => ['nullable', 'string', Rule::in(array_keys(HeadingAccent::symbols()))],
|
||||
'items.*.image' => ['nullable'],
|
||||
'items.*._upload' => ['nullable'],
|
||||
];
|
||||
@@ -126,7 +126,7 @@ public function dataFields(): array
|
||||
TextInput::make('title')->label('Titel')->required()->maxLength(120),
|
||||
Select::make('symbol')
|
||||
->label('Symbol (optional)')
|
||||
->options(HeadingAccent::SYMBOLS)
|
||||
->options(HeadingAccent::symbols())
|
||||
->placeholder('Kein Symbol')
|
||||
->helperText('Kleine Grafik aus dem Brand-Kit über dem Titel. Größe und Ausrichtung im Reiter „Darstellung“.'),
|
||||
Textarea::make('text')->label('Beschreibung')->rows(2)->maxLength(500),
|
||||
|
||||
@@ -87,7 +87,7 @@ public function dataFields(): array
|
||||
public function settings(): array
|
||||
{
|
||||
return [
|
||||
'symbol' => HeadingAccent::SYMBOLS,
|
||||
'symbol' => HeadingAccent::symbols(),
|
||||
'symbol_size' => HeadingAccent::SIZE,
|
||||
'symbol_align' => HeadingAccent::ALIGN,
|
||||
];
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
/**
|
||||
* Merkmalszeile nach den Entwürfen des Brand-Kits (04_visuelle_entwuerfe): ein bis zwölf Merkmale nebeneinander,
|
||||
* je mit Symbol, Kurztitel und einem Satz. Die Spaltenzahl folgt der Anzahl der Einträge und der Breite; es gibt keine
|
||||
* zweite Einstellung dafür. Das Symbol stammt aus der festen Auswahl (HeadingAccent::SYMBOLS), nie aus einem
|
||||
* zweite Einstellung dafür. Das Symbol stammt aus der festen Auswahl (HeadingAccent::symbols()), nie aus einem
|
||||
* freien Dateinamen.
|
||||
*/
|
||||
class FeaturesWidget extends WidgetType
|
||||
@@ -100,7 +100,7 @@ public function dataRules(): array
|
||||
{
|
||||
return [
|
||||
'items' => ['required', 'array', 'min:1', 'max:12'],
|
||||
'items.*.symbol' => ['required', 'string', Rule::in(array_keys(HeadingAccent::SYMBOLS))],
|
||||
'items.*.symbol' => ['required', 'string', Rule::in(array_keys(HeadingAccent::symbols()))],
|
||||
'items.*.title' => ['required', 'string', 'max:60'],
|
||||
'items.*.text' => ['nullable', 'string', 'max:200'],
|
||||
'items.*.url' => ['nullable', 'string', 'max:500'],
|
||||
@@ -139,7 +139,7 @@ public function dataFields(): array
|
||||
Repeater::make('items')
|
||||
->label('Merkmale')
|
||||
->schema([
|
||||
Select::make('symbol')->label('Symbol')->options(HeadingAccent::SYMBOLS)->required(),
|
||||
Select::make('symbol')->label('Symbol')->options(HeadingAccent::symbols())->required(),
|
||||
TextInput::make('title')->label('Kurztitel')->required()->maxLength(60),
|
||||
Textarea::make('text')->label('Satz')->rows(2)->maxLength(200),
|
||||
TextInput::make('url')
|
||||
|
||||
@@ -75,7 +75,7 @@ public function dataFields(): array
|
||||
public function settings(): array
|
||||
{
|
||||
return [
|
||||
'symbol' => HeadingAccent::SYMBOLS,
|
||||
'symbol' => HeadingAccent::symbols(),
|
||||
'symbol_size' => HeadingAccent::SIZE,
|
||||
'symbol_align' => HeadingAccent::ALIGN,
|
||||
'accent' => HeadingAccent::BRUSH,
|
||||
|
||||
@@ -113,7 +113,7 @@ public function settings(): array
|
||||
return [
|
||||
'heading_level' => PremiumFields::HEADING_LEVELS,
|
||||
'accent' => ['underline' => 'Gelbe Unterstreichung', 'rays' => 'Unterstreichung und Signalstrahlen', 'none' => 'Ohne Akzent'],
|
||||
'symbol' => HeadingAccent::SYMBOLS,
|
||||
'symbol' => HeadingAccent::symbols(),
|
||||
'symbol_size' => HeadingAccent::SIZE,
|
||||
'symbol_align' => HeadingAccent::ALIGN,
|
||||
];
|
||||
|
||||
@@ -115,7 +115,7 @@ public function settings(): array
|
||||
return [
|
||||
'surface' => ['cream' => 'Creme (Markenfläche)', 'clear' => 'Ohne eigene Fläche', 'navy' => 'Navy (dunkel)'],
|
||||
'heading_level' => PremiumFields::HEADING_LEVELS,
|
||||
'symbol' => HeadingAccent::SYMBOLS,
|
||||
'symbol' => HeadingAccent::symbols(),
|
||||
'symbol_size' => HeadingAccent::SIZE,
|
||||
'symbol_align' => HeadingAccent::ALIGN,
|
||||
];
|
||||
|
||||
@@ -73,7 +73,7 @@ public function dataFields(): array
|
||||
public function settings(): array
|
||||
{
|
||||
return [
|
||||
'symbol' => HeadingAccent::SYMBOLS,
|
||||
'symbol' => HeadingAccent::symbols(),
|
||||
'symbol_size' => HeadingAccent::SIZE,
|
||||
'symbol_align' => HeadingAccent::ALIGN,
|
||||
];
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support\Brand;
|
||||
|
||||
/**
|
||||
* Katalog der Kleingrafiken: deutscher Titel, Gruppe und Suchwörter je Symbol.
|
||||
*
|
||||
* Quelle ist resources/svg/brand/symbole/_katalog.json. Der Schlüssel ist der Dateiname ohne Endung und wird dauerhaft in
|
||||
* Seitendaten gespeichert (nie umbenennen). Ein Symbol mit "angeboten": false (gelbe Unterstreichung, Signalstrahlen) hat
|
||||
* eine eigene Einstellung und erscheint nicht in der Auswahl. Ein Test stellt sicher, dass jede Datei einen Eintrag hat.
|
||||
*/
|
||||
final class SymbolCatalog
|
||||
{
|
||||
/** @var array{gruppen: list<string>, symbole: array<string, array<string, mixed>>}|null */
|
||||
private static ?array $data = null;
|
||||
|
||||
/** @var array<string, string>|null */
|
||||
private static ?array $options = null;
|
||||
|
||||
/**
|
||||
* Auswahl für Prüfung und Auswahlfelder: Schlüssel => Titel, geordnet nach Gruppe und Titel.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function options(): array
|
||||
{
|
||||
return self::$options ??= (function (): array {
|
||||
$options = [];
|
||||
|
||||
foreach (self::groups() as $group) {
|
||||
foreach ($group['items'] as $item) {
|
||||
$options[$item['key']] = $item['title'];
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
})();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{name: string, items: list<array{key: string, title: string, search: string}>}>
|
||||
*/
|
||||
public static function groups(): array
|
||||
{
|
||||
$data = self::data();
|
||||
$groups = array_map(fn (string $name): array => ['name' => $name, 'items' => []], $data['gruppen']);
|
||||
|
||||
foreach ($data['symbole'] as $key => $entry) {
|
||||
$index = $entry['gruppe'] ?? null;
|
||||
|
||||
if (($entry['angeboten'] ?? true) === false || ! is_int($index) || ! isset($groups[$index])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$groups[$index]['items'][] = [
|
||||
'key' => $key,
|
||||
'title' => (string) $entry['titel'],
|
||||
'search' => mb_strtolower($entry['titel'].' '.($entry['suche'] ?? '')),
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($groups as &$group) {
|
||||
usort($group['items'], fn (array $a, array $b): int => strcmp(self::sortKey($a['title']), self::sortKey($b['title'])));
|
||||
}
|
||||
unset($group);
|
||||
|
||||
return array_values(array_filter($groups, fn (array $group): bool => $group['items'] !== []));
|
||||
}
|
||||
|
||||
public static function title(string $key): ?string
|
||||
{
|
||||
$title = self::data()['symbole'][$key]['titel'] ?? null;
|
||||
|
||||
return is_string($title) ? $title : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Schlüssel, zu denen der Katalog einen Eintrag hat (auch nicht angebotene).
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
public static function keys(): array
|
||||
{
|
||||
return array_keys(self::data()['symbole']);
|
||||
}
|
||||
|
||||
private static function sortKey(string $title): string
|
||||
{
|
||||
return strtr(mb_strtolower($title), ['ä' => 'a', 'ö' => 'o', 'ü' => 'u', 'ß' => 'ss']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{gruppen: list<string>, symbole: array<string, array<string, mixed>>}
|
||||
*/
|
||||
private static function data(): array
|
||||
{
|
||||
return self::$data ??= (function (): array {
|
||||
$file = resource_path('svg/brand/symbole/_katalog.json');
|
||||
$data = is_file($file) ? json_decode((string) file_get_contents($file), true) : null;
|
||||
|
||||
return is_array($data) && is_array($data['gruppen'] ?? null) && is_array($data['symbole'] ?? null)
|
||||
? $data
|
||||
: ['gruppen' => [], 'symbole' => []];
|
||||
})();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user