Skip to content

Commit

Permalink
allow customize panel urls.
Browse files Browse the repository at this point in the history
  • Loading branch information
Saifallak committed Oct 23, 2023
1 parent 30c9e00 commit 1a14c32
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions resources/views/panel-switch-menu.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class="w-5 h-5 text-white ms-auto shrink-0"
<x-filament::dropdown.list>
@foreach ($panels as $panel)
<x-filament::dropdown.list.item
:href="$canSwitchPanels && $panel->getId() !== $currentPanel->getId() ? '/' . $panel->getPath() : null"
:href="$canSwitchPanels && $panel->getId() !== $currentPanel->getId() ? ($urls[$panel->getId()] ?? ('/' . $panel->getPath())) : null"
:badge="str($labels[$panel->getId()] ?? $panel->getId())->substr(0, 2)->upper()"
tag="a"
>
Expand Down Expand Up @@ -66,7 +66,7 @@ class="flex flex-wrap items-center justify-center gap-4 md:gap-6"
>
@foreach ($panels as $panel)
<a
href="{{ $canSwitchPanels && $panel->getId() !== $currentPanel->getId() ? '/' . $panel->getPath() : '#' }}"
href="{{ $canSwitchPanels && $panel->getId() !== $currentPanel->getId() ? ($urls[$panel->getId()] ?? ('/' . $panel->getPath())) : '#' }}"
class="flex flex-col items-center justify-center flex-1 hover:cursor-pointer group panel-switch-card"
>
<div
Expand Down
15 changes: 15 additions & 0 deletions src/PanelSwitch.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class PanelSwitch

protected array | Closure $labels = [];

protected array | Closure $urls = [];

protected bool $renderIconAsImage = false;

protected string | Closure $modalHeading = 'Switch Panels';
Expand Down Expand Up @@ -80,6 +82,7 @@ public static function boot(): void
'isSimple' => $static->isSimple(),
'isSlideOver' => $static->isModalSlideOver(),
'labels' => $static->getLabels(),
'urls' => $static->getUrls(),
'modalWidth' => $static->getModalWidth(),
'panels' => $static->getPanels(),
'renderIconAsImage' => $static->getRenderIconAsImage(),
Expand Down Expand Up @@ -140,6 +143,13 @@ public function labels(array | Closure $labels): static
return $this;
}

public function urls(array | Closure $urls): static
{
$this->urls = $urls;

return $this;
}

public function modalWidth(string | Closure $width = null): static
{
$this->modalWidth = $width;
Expand Down Expand Up @@ -213,6 +223,11 @@ public function getLabels(): array
return (array) $this->evaluate($this->labels);
}

public function getUrls(): array
{
return (array) $this->evaluate($this->urls);
}

public function getModalWidth(): string
{
return $this->evaluate($this->modalWidth) ?? 'screen';
Expand Down

0 comments on commit 1a14c32

Please sign in to comment.