NAME
Chandra::Nav - Navigation component (sidebar/topbar)
SYNOPSIS
use Chandra::Nav;
my $nav = Chandra::Nav->new(
type => 'sidebar',
items => [
{ label => 'Dashboard', icon => "\x{1F4CA}", route => '/' },
{ label => 'Users', icon => "\x{1F465}", route => '/users' },
{ separator => 1 },
{ label => 'Settings', icon => "\x{2699}", route => '/settings' },
],
collapsible => 1,
);
$app->theme('dark');
$app->css(Chandra::Nav->css);
$app->set_content('<div style="display:flex;height:100vh;"><div id="nav"></div><div id="content" style="flex:1;padding:20px;"></div></div>');
$nav->mount($app, '#nav');
METHODS
-
Each item is a hash with a
label, aroute, an optionaliconandbadge, orseparator. The type issidebarortopbar. render-
The navigation, with a toggle when a sidebar is collapsible.
-
Marks the route active, navigates the app when it can, and updates.
on_toggle-
Collapses or expands, and updates.
css-
The navigation's stylesheet.
prototype,set_prototype-
Object::Proto's prototype accessors.