|
| 1 | +@props([ |
| 2 | + 'panels', |
| 3 | + 'currentPanel', |
| 4 | + 'labels' => [], |
| 5 | + 'icons' => [], |
| 6 | + 'renderIconAsImage' => false, |
| 7 | +]) |
| 8 | + |
| 9 | +@php |
| 10 | + $defaultIcon = 'heroicon-o-square-2-stack'; |
| 11 | + $defaultImage = 'https://raw.githubusercontent.com/bezhanSalleh/filament-panel-switch/3.x/art/banner.jpg'; |
| 12 | +@endphp |
| 13 | + |
| 14 | +<ul class="space-y-2"> |
| 15 | + @foreach ($panels as $id => $url) |
| 16 | + @php |
| 17 | + $isCurrentPanel = $id === $currentPanel->getId(); |
| 18 | + $panelLabel = $labels[$id] ?? str($id)->ucfirst(); |
| 19 | + $panelIcon = $icons[$id] ?? $defaultIcon; |
| 20 | + @endphp |
| 21 | + |
| 22 | + <li> |
| 23 | + <a |
| 24 | + href="{{ $url }}" |
| 25 | + @class([ |
| 26 | + "flex items-center gap-x-4 p-3 rounded-xl transition duration-75", |
| 27 | + "hover:bg-gray-50 dark:hover:bg-white/5" => ! $isCurrentPanel, |
| 28 | + "bg-primary-50 dark:bg-primary-400/10 pointer-events-none" => $isCurrentPanel, |
| 29 | + ]) |
| 30 | + > |
| 31 | + {{-- Icon --}} |
| 32 | + @if ($renderIconAsImage) |
| 33 | + <img |
| 34 | + class="h-10 w-10 shrink-0 rounded-lg object-cover" |
| 35 | + src="{{ $icons[$id] ?? $defaultImage }}" |
| 36 | + alt="{{ $panelLabel }}" |
| 37 | + > |
| 38 | + @else |
| 39 | + <x-filament::icon |
| 40 | + :icon="$panelIcon" |
| 41 | + @class([ |
| 42 | + "h-6 w-6 shrink-0", |
| 43 | + "text-gray-400 dark:text-gray-500" => ! $isCurrentPanel, |
| 44 | + "text-primary-600 dark:text-primary-400" => $isCurrentPanel, |
| 45 | + ]) |
| 46 | + /> |
| 47 | + @endif |
| 48 | + |
| 49 | + {{-- Label --}} |
| 50 | + <span |
| 51 | + @class([ |
| 52 | + "flex-1 text-sm font-medium", |
| 53 | + "text-gray-700 dark:text-gray-200" => ! $isCurrentPanel, |
| 54 | + "text-primary-600 dark:text-primary-400" => $isCurrentPanel, |
| 55 | + ]) |
| 56 | + > |
| 57 | + {{ $panelLabel }} |
| 58 | + </span> |
| 59 | + |
| 60 | + {{-- Indicator --}} |
| 61 | + @if ($isCurrentPanel) |
| 62 | + <x-filament::icon |
| 63 | + icon="heroicon-m-check-circle" |
| 64 | + class="h-5 w-5 shrink-0 text-primary-600 dark:text-primary-400" |
| 65 | + /> |
| 66 | + @else |
| 67 | + <x-filament::icon |
| 68 | + icon="heroicon-m-chevron-right" |
| 69 | + class="h-5 w-5 shrink-0 text-gray-400 dark:text-gray-500" |
| 70 | + /> |
| 71 | + @endif |
| 72 | + </a> |
| 73 | + </li> |
| 74 | + @endforeach |
| 75 | +</ul> |
0 commit comments