Skip to content

Commit 9259d9d

Browse files
committed
fixed and improved
1 parent 8c8f53f commit 9259d9d

7 files changed

Lines changed: 397 additions & 96 deletions

File tree

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
<a href="https://filamentphp.com/docs/4.x/introduction/overview">
88
<img alt="FILAMENT 4.x" src="https://img.shields.io/badge/FILAMENT-4.x-EBB304?style=for-the-badge">
99
</a>
10+
<a href="https://filamentphp.com/docs/5.x/introduction/overview">
11+
<img alt="FILAMENT 5.x" src="https://img.shields.io/badge/FILAMENT-5.x-EBB304?style=for-the-badge">
12+
</a>
1013
<a href="https://packagist.org/packages/bezhansalleh/filament-panel-switch">
1114
<img alt="Packagist" src="https://img.shields.io/packagist/v/bezhansalleh/filament-panel-switch.svg?style=for-the-badge&logo=packagist">
1215
</a>
@@ -93,8 +96,8 @@ The Panel Switch Plugin for Filament offers a robust and customizable component
9396

9497
| Package Version | Filament Version |
9598
|----------------|---------------------|
96-
| [v1](https://github.com/bezhanSalleh/filament-panel-switch/tree/1.x) | [v3](https://filamentphp.com/docs/3.x/panels/installation) |
97-
| v2 | [v4](https://filamentphp.com/docs/4.x/introduction/overview) |
99+
| [1.x](https://github.com/bezhanSalleh/filament-panel-switch/tree/1.x) | [3.x](https://filamentphp.com/docs/3.x/panels/installation) |
100+
| 2.x | [4.x](https://filamentphp.com/docs/4.x/introduction/overview) & [5.x](https://filamentphp.com/docs/5.x/introduction/overview) |
98101

99102
## Installation
100103

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
],
2525
"require": {
2626
"php": "^8.2",
27-
"filament/filament": "^4.0",
27+
"filament/filament": "^4.0|^5.0",
2828
"illuminate/support": "^11.28|^12.0",
2929
"league/uri": "^7.0",
3030
"spatie/laravel-package-tools": "^1.9"
@@ -45,7 +45,6 @@
4545
}
4646
},
4747
"scripts": {
48-
"post-autoload-dump": "@php ./vendor/bin/testbench package:discover --ansi",
4948
"format": "vendor/bin/pint"
5049
},
5150
"config": {
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
@props([
2+
'panels',
3+
'currentPanel',
4+
'labels' => [],
5+
'icons' => [],
6+
'iconSize' => 32,
7+
'renderIconAsImage' => false,
8+
])
9+
10+
@php
11+
$defaultIcon = 'heroicon-s-square-2-stack';
12+
$defaultImage = 'https://raw.githubusercontent.com/bezhanSalleh/filament-panel-switch/3.x/art/banner.jpg';
13+
@endphp
14+
15+
<div class="flex flex-wrap items-center justify-center gap-4 md:gap-6">
16+
@foreach ($panels as $id => $url)
17+
@php
18+
$isCurrentPanel = $id === $currentPanel->getId();
19+
$panelLabel = $labels[$id] ?? str($id)->ucfirst();
20+
$panelIcon = $icons[$id] ?? $defaultIcon;
21+
@endphp
22+
23+
<a
24+
href="{{ $url }}"
25+
class="flex flex-col items-center justify-center hover:cursor-pointer group panel-switch-card"
26+
>
27+
<div
28+
@class([
29+
"p-2 bg-white rounded-lg shadow-md dark:bg-gray-800 panel-switch-card-section",
30+
"group-hover:ring-2 group-hover:ring-primary-600" => ! $isCurrentPanel,
31+
"ring-2 ring-primary-600" => $isCurrentPanel,
32+
])
33+
>
34+
@if ($renderIconAsImage)
35+
<img
36+
class="rounded-lg panel-switch-card-image"
37+
style="width: {{ $iconSize * 4 }}px; height: {{ $iconSize * 4 }}px;"
38+
src="{{ $icons[$id] ?? $defaultImage }}"
39+
alt="{{ $panelLabel }}"
40+
>
41+
@else
42+
@svg($panelIcon, 'text-primary-600 panel-switch-card-icon', ['style' => 'width: ' . ($iconSize * 4) . 'px; height: ' . ($iconSize * 4). 'px;'])
43+
@endif
44+
</div>
45+
<span
46+
@class([
47+
"mt-2 text-sm font-medium text-center break-words panel-switch-card-title",
48+
"text-gray-400 dark:text-gray-200 group-hover:text-primary-600 group-hover:dark:text-primary-400" => ! $isCurrentPanel,
49+
"text-primary-600 dark:text-primary-400" => $isCurrentPanel,
50+
])
51+
>
52+
{{ $panelLabel }}
53+
</span>
54+
</a>
55+
@endforeach
56+
</div>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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

Comments
 (0)