A menu UI element, with items that can be selected.
$ component install segmentio/menu
For quick, standard menus, treat it as a constructor:
var Menu = require('menu');
var menu = new Menu()
.add('One')
.add('Two')
.add('Three');
menu.select('Three');
Or, for more complex menus, you can use it as a factory, passing in your own MenuItem
view.
var MenuItem = require('./menu-item')
, createMenu = require('menu');
var Menu = createMenu(MenuItem);
var menu = new Menu()
.add('One')
.add('Two')
.add('Three');
menu.select('Three');
Initialize a new Menu the default item view:
<li class="menu-item {slug}-menu-item"><a>{text || id}</a></li>
Create a new Menu
constructor with the given Item
view.
Add an item to the menu with either a model
or an id
string. The default item view uses the model's text
and/or id
field to populate it's DOM.
Select a menu item.
Deselect all menu items.
MIT