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

new(items = \@items, type => 'sidebar', collapsible => 0, collapsed => 0)>

Each item is a hash with a label, a route, an optional icon and badge, or separator. The type is sidebar or topbar.

render

The navigation, with a toggle when a sidebar is collapsible.

on_navigate($route)

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.

SLOT ACCESSORS

items, type, collapsible, collapsed - the slots as methods

SEE ALSO

Chandra::Tabs, Chandra::Component, Chandra::App