diff --git a/packages/panels/resources/views/components/sidebar/group.blade.php b/packages/panels/resources/views/components/sidebar/group.blade.php index cc748f44bca..167564cc053 100644 --- a/packages/panels/resources/views/components/sidebar/group.blade.php +++ b/packages/panels/resources/views/components/sidebar/group.blade.php @@ -1,4 +1,6 @@ @props([ + 'active' => false, + 'activeIcon' => null, 'collapsible' => true, 'icon' => null, 'items' => [], @@ -10,7 +12,10 @@
  • $active, + ]) > @if ($label)
    (bool) $url, + 'bg-gray-100 dark:bg-white/5' => $active, 'cursor-pointer' => $collapsible, ]) > @if ($icon) ! $active, + 'text-primary-600 dark:text-primary-400' => $active, + ]) /> @endif ! $active, + 'text-primary-600 dark:text-primary-400' => $active + ]) > {{ $label }} diff --git a/packages/panels/resources/views/components/sidebar/index.blade.php b/packages/panels/resources/views/components/sidebar/index.blade.php index 22ba686d796..a4b48fa6b66 100644 --- a/packages/panels/resources/views/components/sidebar/index.blade.php +++ b/packages/panels/resources/views/components/sidebar/index.blade.php @@ -114,6 +114,8 @@ class="fi-sidebar-nav flex flex-col gap-y-7 overflow-y-auto overflow-x-hidden px
      @foreach ($navigation as $group) | Arrayable */ @@ -55,6 +59,20 @@ public function collapsible(bool | Closure | null $condition = true): static return $this; } + public function activeIcon(string | Closure | null $activeIcon): static + { + $this->activeIcon = $activeIcon; + + return $this; + } + + public function isActiveWhen(Closure $callback): static + { + $this->isActiveWhen = $callback; + + return $this; + } + public function icon(string | Closure | null $icon): static { $this->icon = $icon; @@ -99,6 +117,7 @@ public function url(string | Closure | null $url, bool | Closure $shouldOpenInNe { $this->openUrlInNewTab($shouldOpenInNewTab); $this->url = $url; + $this->isActiveWhen(fn () => request()->fullUrlIs($url) || request()->path() === trim($url, '/')); return $this; } @@ -114,6 +133,11 @@ public function getIcon(): ?string return $icon; } + public function getActiveIcon(): ?string + { + return $this->evaluate($this->activeIcon); + } + /** * @return array | Arrayable */ @@ -144,15 +168,13 @@ public function isCollapsible(): bool public function isActive(): bool { - foreach ($this->getItems() as $item) { - if (! $item->isActive()) { - continue; - } + $callback = $this->isActiveWhen; - return true; + if ($callback === null) { + return false; } - return false; + return (bool) $this->evaluate($callback); } public function hasItemIcons(): bool