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
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:
parent
dda250aaad
commit
23c36d28b5
179 changed files with 872 additions and 684 deletions
|
|
@ -4,6 +4,7 @@ namespace App\Filament\Pages;
|
|||
|
||||
use App\Models\Role;
|
||||
use App\Support\Audit;
|
||||
use App\Support\Icons;
|
||||
use App\Support\Navigation;
|
||||
use App\Support\Settings;
|
||||
use BackedEnum;
|
||||
|
|
@ -19,6 +20,7 @@ use Filament\Schemas\Components\Section;
|
|||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Illuminate\Support\Str;
|
||||
use UnitEnum;
|
||||
|
||||
|
|
@ -114,6 +116,9 @@ class MenuSettings extends Page
|
|||
TextInput::make('label')->label('Bezeichnung')->maxLength(60)
|
||||
->placeholder(fn (Get $get) => in_array($get('type'), ['link', 'group'], true) ? '' : 'wie Bereich bzw. Seite')
|
||||
->required(fn (Get $get) => in_array($get('type'), ['link', 'group'], true)),
|
||||
Select::make('icon')->label('Symbol')->placeholder('Ohne')->native(false)
|
||||
->options(Icons::options())->allowHtml()->searchable()
|
||||
->getSearchResultsUsing(fn (string $search) => Icons::search($search)),
|
||||
Toggle::make('subpages')->label('Unterseiten als Untermenü')->inline(false)
|
||||
->visible(fn (Get $get) => $get('type') === 'page'),
|
||||
Toggle::make('new_tab')->label('In neuem Tab öffnen')->inline(false)
|
||||
|
|
@ -142,7 +147,7 @@ class MenuSettings extends Page
|
|||
/**
|
||||
* @param array<string, mixed> $state
|
||||
*/
|
||||
private function itemLabel(array $state): string
|
||||
private function itemLabel(array $state): HtmlString
|
||||
{
|
||||
$navigation = app(Navigation::class);
|
||||
$type = (string) ($state['type'] ?? '');
|
||||
|
|
@ -160,7 +165,10 @@ class MenuSettings extends Page
|
|||
$kind = ['module' => 'Bereich', 'link' => 'Link', 'group' => 'Gruppe'][$type] ?? ($navigation->sourceTypes()[$type] ?? '');
|
||||
$children = count((array) ($state['children'] ?? []));
|
||||
|
||||
return $label.' · '.$kind.($children ? " · {$children} Unterpunkte" : '').(! empty($state['roles']) ? ' · eingeschränkt' : '');
|
||||
$text = e($label).' · '.e($kind).($children ? " · {$children} Unterpunkte" : '').(! empty($state['roles']) ? ' · eingeschränkt' : '');
|
||||
|
||||
return new HtmlString('<span style="display:inline-flex;align-items:center;gap:8px">'
|
||||
.(Icons::has($state['icon'] ?? null) ? Icons::svg($state['icon'], 16) : '').$text.'</span>');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -194,6 +202,7 @@ class MenuSettings extends Page
|
|||
'target' => isset($item['target']) ? (string) $item['target'] : null,
|
||||
'url' => $item['url'] ?? null,
|
||||
'label' => filled($item['label'] ?? null) ? trim($item['label']) : null,
|
||||
'icon' => Icons::has($item['icon'] ?? null) ? $item['icon'] : null,
|
||||
'subpages' => ! empty($item['subpages']),
|
||||
'new_tab' => ! empty($item['new_tab']),
|
||||
'roles' => array_values(array_map('intval', (array) ($item['roles'] ?? []))),
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Support\Icons;
|
||||
use App\Support\QuickLinks;
|
||||
use App\Support\Settings;
|
||||
use BackedEnum;
|
||||
|
|
@ -73,7 +74,10 @@ class QuickLinksSettings extends Page
|
|||
->columnSpan(2),
|
||||
Select::make('icon')
|
||||
->label('Symbol')
|
||||
->options(QuickLinks::ICONS)
|
||||
->options(Icons::options())
|
||||
->allowHtml()
|
||||
->searchable()
|
||||
->getSearchResultsUsing(fn (string $search) => Icons::search($search))
|
||||
->default('link')
|
||||
->required(),
|
||||
Toggle::make('new_tab')
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace App\Pagebuilder;
|
||||
|
||||
use App\Support\QuickLinks;
|
||||
use App\Support\Icons;
|
||||
use App\Support\RichText;
|
||||
use Closure;
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ final class Field
|
|||
/** Symbol aus dem Symbolsatz der Schnellzugriffe. */
|
||||
public static function icon(string $name, string $label, string $default = 'link'): self
|
||||
{
|
||||
return new self($name, 'icon', $label, ['default' => $default, 'choices' => QuickLinks::ICONS]);
|
||||
return new self($name, 'icon', $label, ['default' => $default, 'choices' => Icons::choices()]);
|
||||
}
|
||||
|
||||
/** Liste gleichartiger Einträge, z. B. Schaltflächen oder Galeriebilder. */
|
||||
|
|
@ -143,7 +143,7 @@ final class Field
|
|||
'image' => is_string($value) && preg_match('#^pagebuilder/[A-Za-z0-9/_.-]+$#', $value) && ! str_contains($value, '..') ? $value : null,
|
||||
'people', 'ids' => array_values(array_slice(array_unique(array_filter(array_map('intval', is_array($value) ? $value : []))), 0, $this->options['max'])),
|
||||
'table' => $this->sanitizeTable($value),
|
||||
'icon' => is_string($value) && array_key_exists($value, QuickLinks::ICONS) ? $value : $this->options['default'],
|
||||
'icon' => Icons::has($value) ? $value : $this->options['default'],
|
||||
'repeater' => $this->sanitizeRepeater($value),
|
||||
default => null,
|
||||
};
|
||||
|
|
|
|||
68
app/Support/Icons.php
Normal file
68
app/Support/Icons.php
Normal 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,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
@ -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,
|
||||
];
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue