Feature #2 : Breadcrumbs

This commit is contained in:
Daeng Deni Mardaeni 2024-08-05 14:24:31 +07:00
parent 0c2bb15b58
commit 8bfc23fa23
6 changed files with 1173 additions and 1065 deletions

View File

@ -5,14 +5,15 @@ use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware; use Illuminate\Foundation\Configuration\Middleware;
return Application::configure(basePath: dirname(__DIR__)) return Application::configure(basePath: dirname(__DIR__))
->withRouting( ->withRouting(web:
web: __DIR__.'/../routes/web.php', __DIR__ . '/../routes/web.php',
commands: __DIR__ . '/../routes/console.php', commands: __DIR__ . '/../routes/console.php',
health: '/up', health: '/up'
) )
->withMiddleware(function (Middleware $middleware) { ->withMiddleware(function (Middleware $middleware) {
//
}) })
->withExceptions(function (Exceptions $exceptions) { ->withExceptions(function (Exceptions $exceptions) {
// //
})->create(); })
->create();

View File

@ -6,6 +6,7 @@
"license": "MIT", "license": "MIT",
"require": { "require": {
"php": "^8.2", "php": "^8.2",
"diglactic/laravel-breadcrumbs": "^9.0",
"joshbrw/laravel-module-installer": "^2.0", "joshbrw/laravel-module-installer": "^2.0",
"laravel/framework": "^11.9", "laravel/framework": "^11.9",
"laravel/tinker": "^2.9", "laravel/tinker": "^2.9",

75
config/breadcrumbs.php Normal file
View File

@ -0,0 +1,75 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| View Name
|--------------------------------------------------------------------------
|
| Choose a view to display when Breadcrumbs::render() is called.
| Built in templates are:
|
| - 'breadcrumbs::bootstrap5' - Bootstrap 5
| - 'breadcrumbs::bootstrap4' - Bootstrap 4
| - 'breadcrumbs::bulma' - Bulma
| - 'breadcrumbs::foundation6' - Foundation 6
| - 'breadcrumbs::json-ld' - JSON-LD Structured Data
| - 'breadcrumbs::materialize' - Materialize
| - 'breadcrumbs::tailwind' - Tailwind CSS
| - 'breadcrumbs::uikit' - UIkit
|
| Or a custom view, e.g. '_partials/breadcrumbs'.
|
*/
'view' => 'layouts.breadcrumbs',
/*
|--------------------------------------------------------------------------
| Breadcrumbs File(s)
|--------------------------------------------------------------------------
|
| The file(s) where breadcrumbs are defined. e.g.
|
| - base_path('routes/breadcrumbs.php')
| - glob(base_path('breadcrumbs/*.php'))
|
*/
'files' => base_path('routes/breadcrumbs.php'),
/*
|--------------------------------------------------------------------------
| Exceptions
|--------------------------------------------------------------------------
|
| Determine when to throw an exception.
|
*/
// When route-bound breadcrumbs are used but the current route doesn't have a name (UnnamedRouteException)
'unnamed-route-exception' => true,
// When route-bound breadcrumbs are used and the matching breadcrumb doesn't exist (InvalidBreadcrumbException)
'missing-route-bound-breadcrumb-exception' => true,
// When a named breadcrumb is used but doesn't exist (InvalidBreadcrumbException)
'invalid-named-breadcrumb-exception' => true,
/*
|--------------------------------------------------------------------------
| Classes
|--------------------------------------------------------------------------
|
| Subclass the default classes for more advanced customisations.
|
*/
// Manager
'manager-class' => Diglactic\Breadcrumbs\Manager::class,
// Generator
'generator-class' => Diglactic\Breadcrumbs\Generator::class,
];

View File

@ -0,0 +1,19 @@
@unless ($breadcrumbs->isEmpty())
<div class="flex [.header_&amp;]:below-lg:hidden items-center gap-1.25 text-xs lg:text-sm font-medium mb-2.5 lg:mb-0" data-reparent="true" data-reparent-mode="prepend|lg:prepend" data-reparent-target="#content_container|lg:#header_container">
@foreach ($breadcrumbs as $breadcrumb)
@if (!is_null($breadcrumb->url) && !$loop->last)
<li class="breadcrumb-item"></li>
<span class="text-gray-600">
<a href="{{ $breadcrumb->url }}">{{ $breadcrumb->title }}</a>
</span>
<i class="ki-filled ki-right text-gray-500 text-3xs">
</i>
@else
<span class="text-gray-700">
{{ $breadcrumb->title }}
</span>
@endif
@endforeach
</div>
@endunless

View File

@ -2,7 +2,7 @@
data-sticky="true" data-sticky-class="shadow-sm dark:border-b dark:border-b-coal-100" data-sticky-name="header" data-sticky="true" data-sticky-class="shadow-sm dark:border-b dark:border-b-coal-100" data-sticky-name="header"
id="header"> id="header">
<!-- begin: container --> <!-- begin: container -->
<div class="container-fixed flex justify-between items-stretch lg:gap-4" id="header_container"> <div class="container-fluid flex justify-between items-stretch lg:gap-4" id="header_container">
<div class="flex gap-1 lg:hidden items-center -ml-1"> <div class="flex gap-1 lg:hidden items-center -ml-1">
<a class="shrink-0" href="{{ url('/') }}"> <a class="shrink-0" href="{{ url('/') }}">
<img class="max-h-[25px] w-full" src="assets/media/app/logo-agi-mini.png"/> <img class="max-h-[25px] w-full" src="assets/media/app/logo-agi-mini.png"/>
@ -22,7 +22,10 @@
<div class="flex items-stretch" data-reparent="true" data-reparent-mode="prepend|lg:prepend" <div class="flex items-stretch" data-reparent="true" data-reparent-mode="prepend|lg:prepend"
data-reparent-target="body|lg:#megamenu_container"> data-reparent-target="body|lg:#megamenu_container">
</div> </div>
@yield('breadcrumbs')
</div> </div>
<div class="flex items-center gap-2 lg:gap-3.5"> <div class="flex items-center gap-2 lg:gap-3.5">
<div class="dropdown" data-dropdown="true" data-dropdown-offset="70px, 10px" data-dropdown-placement="bottom-end" <div class="dropdown" data-dropdown="true" data-dropdown-offset="70px, 10px" data-dropdown-placement="bottom-end"
data-dropdown-trigger="click|lg:click"> data-dropdown-trigger="click|lg:click">

9
routes/breadcrumbs.php Normal file
View File

@ -0,0 +1,9 @@
<?php // routes/breadcrumbs.php
// Note: Laravel will automatically resolve `Breadcrumbs::` without
// this import. This is nice for IDE syntax and refactoring.
use Diglactic\Breadcrumbs\Breadcrumbs;
// This import is also not required, and you could replace `BreadcrumbTrail $trail`
// with `$trail`. This is nice for IDE type checking and completion.
use Diglactic\Breadcrumbs\Generator as BreadcrumbTrail;