diff --git a/demos/init-app.php b/demos/init-app.php index 460800fceb..57d029ef85 100644 --- a/demos/init-app.php +++ b/demos/init-app.php @@ -153,10 +153,10 @@ public static function get_class(\Closure $createAnonymousClassFx): string $layout->addMenuItem(['Sliding Panel'], [$path . 'layout-panel'], $menu); $path = $demosUrl . 'basic/'; - $menu = $layout->addMenuGroup(['Basics', 'icon' => 'cubes']); + $menu = $layout->addMenuGroup(['Basics', 'label' => ['10', 'class.red' => true]]); $layout->addMenuItem('View', [$path . 'view'], $menu); - $layout->addMenuItem('Button', [$path . 'button'], $menu); - $layout->addMenuItem('Header', [$path . 'header'], $menu); + $layout->addMenuItem(['Button', 'label' => ['10', 'class.red' => true]], [$path . 'button'], $menu); + $layout->addMenuItem(['Header', 'icon' => 'edit'], [$path . 'header'], $menu); $layout->addMenuItem('Message', [$path . 'message'], $menu); $layout->addMenuItem('Labels', [$path . 'label'], $menu); $layout->addMenuItem('Menu', [$path . 'menu'], $menu); @@ -174,9 +174,11 @@ public static function get_class(\Closure $createAnonymousClassFx): string $layout->addMenuItem(['HTML Layout'], [$path . 'html-layout'], $menu); $layout->addMenuItem(['Conditional Fields'], [$path . 'jscondform'], $menu); + $layout->addMenuItem(['Chats', 'label' => ['10', 'class.red' => true]], [$path . '..']); + $path = $demosUrl . 'form-control/'; $menu = $layout->addMenuGroup(['Form Controls', 'icon' => 'keyboard outline']); - $layout->addMenuItem(['Input'], [$path . 'input2'], $menu); + $layout->addMenuItem(['Input', 'label' => ['10', 'class.red' => true]], [$path . 'input2'], $menu); $layout->addMenuItem('Input Decoration', [$path . 'input'], $menu); $layout->addMenuItem('Calendar', [$path . 'calendar'], $menu); $layout->addMenuItem(['Checkboxes'], [$path . 'checkbox'], $menu); diff --git a/docs/app.md b/docs/app.md index 06d4994e7a..dbd0f13fbb 100644 --- a/docs/app.md +++ b/docs/app.md @@ -447,8 +447,11 @@ $layout = $app->layout; $layout->menuLeft->addItem(['Welcome Page', 'icon' => 'gift'], ['index']); $layout->menuLeft->addItem(['Layouts', 'icon' => 'object group'], ['layouts']); -$EditGroup = $layout->menuLeft->addGroup(['Edit', 'icon' => 'edit']); -$EditGroup->addItem('Basics', ['edit/basic']); +$editGroup = $layout->menuLeft->addGroup(['Edit', 'icon' => 'edit']); +$editGroup->addItem('Basics', ['edit/basic']); + +$newsGroup = $layout->menuLeft->addGroup(['News', 'label' => ['28', 'class.red' => true]]); +$newsGroup->addItem('Emails', ['news/emails']); ``` :::{php:attr} menu diff --git a/src/Menu.php b/src/Menu.php index be505488bd..95e6ac828c 100644 --- a/src/Menu.php +++ b/src/Menu.php @@ -91,7 +91,7 @@ public function addMenu($name) $name = [$name]; } - $label = $name['title'] ?? $name['text'] ?? $name['name'] ?? $name[0] ?? null; + $label = $name['title'] ?? $name[0] ?? null; if ($label !== null) { $subMenu->template->set('label', $label); @@ -123,7 +123,7 @@ public function addGroup($name, string $template = 'menugroup.html') $name = [$name]; } - $title = $name['title'] ?? $name['text'] ?? $name['name'] ?? $name[0] ?? null; + $title = $name['title'] ?? $name[0] ?? null; if ($title !== null) { $group->template->set('title', $title); @@ -131,6 +131,8 @@ public function addGroup($name, string $template = 'menugroup.html') if (isset($name['icon'])) { Icon::addTo($group, [$name['icon']], ['Icon'])->removeClass('item'); + } elseif (isset($name['label'])) { + Label::addTo($group, [$name['label']], ['Icon'])->removeClass('item')->addClass('tiny'); } return $group;