NAME

Ado::UI::Menu - A user interface component

SYNOPSIS

my $menu = Ado::UI::Menu->new;
$menu->items(
  {icon => 'dashboard', title => 'Dashboard'},
  {icon => 'content',   title => 'Content'},
  {icon => 'settings',  title => 'Settings'}
);

$menu->items->last->add_item(
  icon => 'users', title => 'Users', url => '/ado-users');

DESCRIPTION

Ado::UI::Menu is a UI component created for populating the main menu in the administration interface of an Ado-based application. It can be used also in the site area by Ado::Plugin::Site. Every menu-item is an instance of Ado::UI::Menu too.

ATTRIBUTES

Ado::UI::Menu inherits all attributes from Mojo::Base and implements the following new ones.

$item->header(1)
$item->header; #this item is a header item

Boolean. Is this menu-item a header or not.

icon

$item->icon('dashboard');
$item->icon; # dashboard

String. Used to set CSS class for the icon. See http://semantic-ui.com/elements/icon.html, http://fortawesome.github.io/Font-Awesome/icons/.

title

$item->title('Dashboard');
$item->title; # Dashboard

String. Used to display the text of the menu item.

url

$item->url('/ado-users');
$item->url;# '/ado-users'

METHODS

Ado::UI::Menu inherits all methods from Mojo::Base and implements the following new ones.

items

Creates a Mojo::Collection of Ado::UI::Menus or returns an empty one.

$menu->items(
  {icon => 'block layout', title =>'Templates', url=>'/ado-templates'},
  {icon => 'users', title =>'Users', url=>'/ado-users'},
);
my $items_level2 = $menu->items->first(sub{shift->title =~/^Sett/})->items;

add_item

Adds an item at the end of the "items" collection and returns $self.

# 'users'
$menu->add_item(icon => 'users', title =>'Users',url=>'/ado-users')
  ->items->last->icon;

SEE ALSO

Ado::Plugin::Admin, Mojo::Collection

AUTHOR

Krasimir Berov

COPYRIGHT AND LICENSE

Copyright 2015 Krasimir Berov.

This program is free software, you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License v3 (LGPL-3.0). You may copy, distribute and modify the software provided that modifications are open source. However, software that includes the license may release under a different license.

See http://opensource.org/licenses/lgpl-3.0.html for more information.