Skip to content

Commit

Permalink
breadcrumbs wip
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Nov 26, 2023
1 parent dc53eba commit c89103a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
15 changes: 9 additions & 6 deletions resources/views/components/layout/breadcrumbs.blade.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<ol class="breadcrumb-list app-header__breadcrumb">
<li>
<a href="/">Dashboard</a>
</li>
<li>
<span aria-current="page">Products</span>
</li>
@foreach($breadcrumbs as $item)
<li>
@if($loop->last)
<span aria-current="page">{{ $item['label'] }}</span>
@else
<a href="{{ $item['uri'] }}">{{ $item['label'] }}</a>
@endif
</li>
@endforeach
</ol>
2 changes: 2 additions & 0 deletions src/Root.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public function boot(): void
foreach ($this->booting as $callback) {
call_user_func_array($callback, [$this]);
}

$this->breadcrumbs->pattern($this->getPath(), __('Dashboard'));
}

/**
Expand Down
34 changes: 34 additions & 0 deletions src/View/Components/Layout/Breadcrumbs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Cone\Root\View\Components\Layout;

use Cone\Root\Root;
use Illuminate\Http\Request;
use Illuminate\View\Component;
use Illuminate\View\View;

class Breadcrumbs extends Component
{
/**
* The HTTP request.
*/
protected Request $request;

/**
* Create a new component instance.
*/
public function __construct(Request $request)
{
$this->request = $request;
}

/**
* Get the view / view contents that represent the component.
*/
public function render(): View
{
return $this->view('root::components.layout.breadcrumbs', [
'breadcrumbs' => Root::instance()->breadcrumbs->resolve($this->request),
]);
}
}

0 comments on commit c89103a

Please sign in to comment.