Skip to content

Commit

Permalink
fix: update route path and menu item links for consistency, add dropd…
Browse files Browse the repository at this point in the history
…own open class
  • Loading branch information
arodu committed Dec 28, 2024
1 parent ebce3c1 commit 6f60cd0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 147 deletions.
3 changes: 1 addition & 2 deletions src/CakeLtePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ public function routes(RouteBuilder $routes): void
{
$routes->plugin(
'CakeLte',
['path' => '/cake_lte'],
['path' => '/cakelte'],
function (RouteBuilder $builder): void {
// Add custom routes here
$builder->connect('/debug', ['controller' => 'Pages', 'action' => 'debug']);
$builder->connect('/sample', ['controller' => 'Pages', 'action' => 'sample']);
}
Expand Down
16 changes: 9 additions & 7 deletions src/View/CakeLteTrait.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace CakeLte\View;
Expand Down Expand Up @@ -29,6 +30,7 @@ public function initializeCakeLte(array $options = []): void
'className' => 'BsUtils.Menu',
'nestClass' => null,
'activeClass' => 'active',
'dropdownOpenClass' => 'menu-open',
'defaultIcon' => [
0 => 'bi bi-circle-fill',
1 => 'bi bi-circle',
Expand All @@ -39,18 +41,18 @@ public function initializeCakeLte(array $options = []): void
'menuTitle' => '<li class="nav-header">{{text}}</li>',
'icon' => '<i class="nav-icon {{icon}}"></i>',
'divider' => '<li><hr class="dropdown-divider"></li>',

'menuContainer' => '<ul class="nav sidebar-menu flex-column" data-lte-toggle="treeview" role="menu" data-accordion="false">{{items}}</ul>',
'menuItem' => '<li class="nav-item {{class}}">{{text}}{{nest}}</li>',
'menuItem' => '<li class="nav-item{{class}}{{dropdownOpenClass}}">{{text}}{{nest}}</li>',
'menuItemDisabled' => '<li class="nav-item"><a class="nav-link disabled" aria-disabled="true">{{icon}}<p>{{text}}</p></a></li>',
'menuItemLink' => '<a href="{{url}}" class="nav-link {{class}}{{activeClass}}">{{icon}}<p>{{text}}{{arrow}}</p></a>',
'menuItemLinkNest' => '<a href="{{url}}" class="nav-link {{class}}{{activeClass}}">{{icon}}<p>{{text}}<i class="nav-arrow bi bi-chevron-right"></i></p></a>',
'menuItemLink' => '<a href="{{url}}" class="nav-link{{class}}{{activeClass}}">{{icon}}<p>{{text}}{{append}}</p></a>',
'menuItemLinkNest' => '<a href="{{url}}" class="nav-link{{class}}{{activeClass}}">{{icon}}<p>{{text}}{{append}}<i class="nav-arrow bi bi-chevron-right"></i></p></a>',

'dropdownContainer' => '<ul class="nav nav-treeview">{{items}}</ul>',
'dropdownItem' => '<li class="nav-item">{{text}}{{nest}}</li>',
'dropdownItemDisabled' => '<li class="nav-item">{{text}}{{nest}}</li>',
'dropdownItemLink' => '<a href="{{url}}" class="nav-link">{{icon}}<p>{{text}}</p></a>',
'dropdownItemLinkNest' => '<a href="{{url}}" class="nav-link">{{icon}}<p>{{text}}<i class="nav-arrow bi bi-chevron-right"></i></p></a>',
'dropdownItemLink' => '<a href="{{url}}" class="nav-link{{activeClass}}">{{icon}}<p>{{text}}{{append}}</p></a>',
'dropdownItemLinkNest' => '<a href="{{url}}" class="nav-link{{activeClass}}">{{icon}}<p>{{text}}{{append}}<i class="nav-arrow bi bi-chevron-right"></i></p></a>',
],
]);
}
Expand Down
148 changes: 16 additions & 132 deletions templates/Pages/sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
* @var \App\View\AppView $this
*/

//$this->Menu->activeItem('firstItem');
$this->Menu->activeItem('0.1');

$navbar = [
'active' => [
'firstItem' => [
'label' => __('Active'),
'url' => '#',
],
Expand Down Expand Up @@ -41,135 +44,37 @@
[
'label' => __('Disabled'),
'url' => '#',
'type' => $this->Menu::ITEM_TYPE_DISABLED,
'disabled' => true,
],
];

$this->Menu->activeItem('active');

?>

<div class="card">
<div class="card mb-4">
<div class="card-body">
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-expanded="false">Dropdown</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
<li>
<hr class="dropdown-divider">
</li>
<li><a class="dropdown-item" href="#">Separated link</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</li>
</ul>
<?= $this->Menu->render($navbar, ['menuClass' => 'nav']) ?>
</div>

<div class="card-body">
<?= $this->Menu->render($navbar, ['menu.class' => 'nav']) ?>
<?= $this->Menu->render($navbar, ['menuClass' => 'nav nav-pills']) ?>
</div>

<div class="card-body">
<?= $this->Menu->render($navbar, ['menu.class' => 'nav nav-pills']) ?>
<?= $this->Menu->render($navbar, ['menuClass' => 'nav nav-tabs']) ?>
</div>
<div class="card-body">
<?= $this->Menu->render($navbar, ['menu.class' => 'nav nav-tabs']) ?>
<?= $this->Menu->render($navbar, ['menuClass' => 'nav nav-underline']) ?>
</div>

</div>


<div class="card card-danger card-outline mb-4">
<!--begin::Header-->
<div class="card-header">
<div class="card-title">MenuHelper</div>
<div class="card-body">
<?= $this->Menu->render($navbar, ['menuClass' => 'nav nav-pills nav-fill']) ?>
</div>
<!--end::Header-->
<!--begin::Body-->
<div class="card-body">
<nav class="navbar navbar-expand-lg bg-body-tertiary">
<div class="container-fluid">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<?= $this->Menu->render($navbar, ['menu.class' => 'navbar-nav me-auto mb-2 mb-lg-0']) ?>

<?php

/*
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item "><a href="#" class="nav-link ">Home</a></li>
<li class="nav-item "><a href="#" class="nav-link ">Link</a></li>
<li class="nav-item dropdown"><a href="#" class="nav-link dropdown-toggle" role="button" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</a>
<ul class="dropdown-menu">
<li><a href="#" class="dropdown-item ">Action</a></li>
<li><a href="#" class="dropdown-item ">Another action</a></li>
<li>
<hr class="dropdown-divider">
</li>
<li><a href="#" class="dropdown-item ">Something else here</a></li>
</ul>
</li>
<li class="nav-item"><a class="nav-link disabled" aria-disabled="true">Disabled</a></li>
</ul>
*/


/*
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item"><a class="nav-link" href="#">Link</a></li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Dropdown
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li>
<hr class="dropdown-divider">
</li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</li>
</ul>
*/ ?>

<form class="d-flex" role="search">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search" data-sharkid="__6">
<button class="btn btn-outline-success" type="submit">Search</button>
</form>
</div>
</div>
</nav>
<?= $this->Menu->render($navbar, ['menuClass' => 'nav flex-column nav-pills']) ?>
</div>
<!--end::Body-->
</div>



<div class="card card-danger card-outline mb-4">
<!--begin::Header-->
<div class="card-header">
<div class="card-title">Navbar</div>
<div class="card-title">MenuHelper</div>
</div>
<!--end::Header-->
<!--begin::Body-->
Expand All @@ -181,28 +86,7 @@
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item"><a class="nav-link" href="#">Link</a></li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Dropdown
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li>
<hr class="dropdown-divider">
</li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</li>
</ul>
<?= $this->Menu->render($navbar, ['menuClass' => 'navbar-nav me-auto mb-2 mb-lg-0']) ?>
<form class="d-flex" role="search">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search" data-sharkid="__6">
<button class="btn btn-outline-success" type="submit">Search</button>
Expand All @@ -212,4 +96,4 @@
</nav>
</div>
<!--end::Body-->
</div>
</div>
8 changes: 2 additions & 6 deletions templates/element/sidebar/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@
],
'simpleLink' => [
'label' => __('Simple Link'),


'badge' => ['text' => __('New'), 'color' => 'danger'],


'url' => ['controller' => 'Pages', 'action' => 'display', 'home', 'plugin' => false],
'append' => '<span class="nav-badge badge text-bg-danger me-3">New</span>',
//'icon' => 'fas fa-th text-danger',
'show' => function () {
// logic condition to show item, return a bool
Expand All @@ -34,7 +30,7 @@
],
'debug' => [
'label' => __('Debug'),
'url' => 'cake_lte/debug',
'url' => 'cakelte/debug',
//'icon' => 'fas fa-th text-danger',
],
'theme' => [
Expand Down

0 comments on commit 6f60cd0

Please sign in to comment.