Menü: Symbole je Menüpunkt, gemeinsame Symbolauswahl
All checks were successful
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 2m47s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 2m33s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 2m41s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 2m41s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 3m41s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 3m44s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 3m18s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 3m9s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m0s

- Optionales Symbol für jeden Menü- und Unterpunkt (Kopfzeile,
  Aufklappmenüs, „Mehr“, Handy-Menü)
- Gemeinsame Liste resources/icons/icons.json (66 Lucide-Symbole) für
  Menü, Schnellzugriffe und Pagebuilder; `npm run icons` erzeugt
  Frontend-Zuordnung und SVGs für die Vorschau im Admin
- Admin-Auswahl mit Symbolvorschau und Suche

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-26 14:14:52 +00:00
parent dda250aaad
commit 23c36d28b5
179 changed files with 872 additions and 684 deletions

68
app/Support/Icons.php Normal file
View file

@ -0,0 +1,68 @@
<?php
namespace App\Support;
/**
* Kuratierte Symbole (Lucide) für Menü, Schnellzugriffe und Pagebuilder.
* Liste: resources/icons/icons.json – nach Änderungen `npm run icons` ausführen.
*/
final class Icons
{
/** @var array<string, string>|null */
private static ?array $choices = null;
/** @var array<string, string>|null */
private static ?array $svg = null;
/**
* @return array<string, string> Name => Bezeichnung
*/
public static function choices(): array
{
return self::$choices ??= json_decode((string) file_get_contents(resource_path('icons/icons.json')), true);
}
public static function has(mixed $name): bool
{
return is_string($name) && array_key_exists($name, self::choices());
}
/**
* Vollständiges SVG, z. B. für Vorschauen im Admin-Bereich.
*/
public static function svg(string $name, int $size = 18): string
{
self::$svg ??= require resource_path('icons/svg.php');
$inner = self::$svg[$name] ?? '';
return '<svg xmlns="http://www.w3.org/2000/svg" width="'.$size.'" height="'.$size.'" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" style="flex-shrink:0">'.$inner.'</svg>';
}
/**
* Auswahl für Filament-Select mit ->allowHtml(): Symbol und Bezeichnung.
*
* @return array<string, string>
*/
public static function options(): array
{
return collect(self::choices())
->map(fn (string $label, string $name) => '<span style="display:inline-flex;align-items:center;gap:8px">'.self::svg($name).e($label).'</span>')
->all();
}
/**
* Suche in der Auswahl nach Bezeichnung oder Name (nicht im SVG-Markup).
*
* @return array<string, string>
*/
public static function search(string $query): array
{
$query = mb_strtolower(trim($query));
return array_intersect_key(self::options(), array_filter(
self::choices(),
fn (string $label, string $name) => $query === '' || str_contains(mb_strtolower($label), $query) || str_contains($name, $query),
ARRAY_FILTER_USE_BOTH,
));
}
}

View file

@ -107,7 +107,7 @@ class Navigation
/**
* Menü für die Kopfzeile. Einträge können Unterpunkte (children) haben.
*
* @return list<array{key: string, label: string, href: string|null, active: bool, new_tab: bool, children: list<array<string, mixed>>}>
* @return list<array{key: string, label: string, href: string|null, active: bool, icon: string|null, new_tab: bool, children: list<array<string, mixed>>}>
*/
public function items(Request $request, ?User $user = null): array
{
@ -144,7 +144,7 @@ class Navigation
}
return $items->sortBy('sort')
->map(fn (array $item) => ['key' => $item['key'], 'label' => $item['label'], 'href' => $item['href'], 'active' => (bool) $item['active'], 'new_tab' => false, 'children' => []])
->map(fn (array $item) => ['key' => $item['key'], 'label' => $item['label'], 'href' => $item['href'], 'active' => (bool) $item['active'], 'icon' => null, 'new_tab' => false, 'children' => []])
->values()
->all();
}
@ -197,7 +197,7 @@ class Navigation
}
foreach ((array) ($base['children'] ?? []) as $child) {
$children[] = ['key' => ($item['id'] ?? $type).'-'.md5($child['href']), 'label' => $child['label'], 'href' => $child['href'], 'active' => (bool) $child['active'], 'new_tab' => false, 'children' => []];
$children[] = ['key' => ($item['id'] ?? $type).'-'.md5($child['href']), 'label' => $child['label'], 'href' => $child['href'], 'active' => (bool) $child['active'], 'icon' => null, 'new_tab' => false, 'children' => []];
}
}
@ -212,6 +212,7 @@ class Navigation
'label' => $label,
'href' => $base['href'],
'active' => $base['active'] || collect($children)->contains('active', true),
'icon' => Icons::has($item['icon'] ?? null) ? $item['icon'] : null,
'new_tab' => $type === 'link' && ! empty($item['new_tab']),
'children' => $children,
];

View file

@ -7,37 +7,6 @@ namespace App\Support;
*/
class QuickLinks
{
/**
* Auswahl an Symbolen (Lucide-Namen). Das Portal bündelt genau diese Symbole,
* deshalb ist die Liste bewusst begrenzt.
*/
public const ICONS = [
'link' => 'Link',
'clock' => 'Uhr / Zeiterfassung',
'calendar-days' => 'Kalender / Dienstplan',
'plane' => 'Urlaub',
'receipt' => 'Reisekosten / Belege',
'graduation-cap' => 'Fortbildung',
'headset' => 'IT-Support',
'utensils' => 'Speiseplan',
'car' => 'Fahrdienst',
'file-text' => 'Formulare / Dokumente',
'book-open' => 'Handbuch / Richtlinien',
'users' => 'Personen / Teams',
'mail' => 'E-Mail',
'message-square' => 'Chat / Feedback',
'lightbulb' => 'Ideen',
'shield-check' => 'Datenschutz / Sicherheit',
'heart-handshake' => 'Soziales / MAV',
'building-2' => 'Standorte',
'wrench' => 'Technik / Hausmeister',
'monitor' => 'Anwendung',
'folder' => 'Ablage',
'phone' => 'Telefonbuch',
'megaphone' => 'Ankündigungen',
'briefcase' => 'Stellenangebote',
];
public function __construct(private readonly Settings $settings) {}
/**
@ -54,7 +23,7 @@ class QuickLinks
return array_values(array_map(fn (array $link) => [
'label' => (string) ($link['label'] ?? ''),
'url' => preg_match('#^(https?://|/)#i', (string) ($link['url'] ?? '')) ? (string) $link['url'] : '#',
'icon' => array_key_exists($link['icon'] ?? '', self::ICONS) ? $link['icon'] : 'link',
'icon' => Icons::has($link['icon'] ?? null) ? $link['icon'] : 'link',
'new_tab' => (bool) ($link['new_tab'] ?? false),
], $links));
}