Skip to content

Commit

Permalink
Merge navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
francoism90 committed Apr 27, 2024
1 parent c5dd857 commit 03bbd4d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 57 deletions.
4 changes: 2 additions & 2 deletions resources/views/navigation/tabs.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@php
$current = $navigation->current();
$current = $actions->current();
@endphp

<div {{ $attributes
Expand All @@ -12,7 +12,7 @@
->withoutClass()
}}>
<nav class="{{ $attributes->classFor('layer') }}">
@foreach ($navigation->items as $action)
@foreach ($actions->items as $action)
<x-wireuse::actions-link
:$action
class="{{ $attributes->classFor('item') }}"
Expand Down
21 changes: 21 additions & 0 deletions src/Actions/Support/ActionGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,27 @@ public function filter(Closure $callback): array
return $this->filterItems($this->items, $callback);
}

public function current(): ?Action
{
$items = $this->filter(function (Action $item) {
$active = $this->active ?: $item->getActive();

if (is_bool($active)) {
return $active;
}

if (is_string($active) && $item->getName() === $active) {
return $item;
}

return $item->isRoute() || $item->isFullUrl();
});

return collect($items)
->sortByDesc(fn (Action $item) => count($item->getContainers()))
->first();
}

protected function filterItems(array $items, Closure $callback): array
{
$filtered = [];
Expand Down
4 changes: 2 additions & 2 deletions src/Navigation/Components/Tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
namespace Foxws\WireUse\Navigation\Components;

use Closure;
use Foxws\WireUse\Navigation\Support\Navigation;
use Foxws\WireUse\Actions\Support\ActionGroup;
use Foxws\WireUse\Views\Support\Component;
use Illuminate\View\View;

class Tabs extends Component
{
public function __construct(
public Navigation $navigation,
public ActionGroup $actions,
) {
}

Expand Down
43 changes: 0 additions & 43 deletions src/Navigation/Support/Navigation.php

This file was deleted.

10 changes: 0 additions & 10 deletions src/Navigation/Support/NavigationItem.php

This file was deleted.

0 comments on commit 03bbd4d

Please sign in to comment.