Menu
Menu component with structural styling to give you a clean slate.
Installation
$ npm install menu-component
Features
- events for composition
- structural CSS letting you decide on style
- fluent API
- arrow key navigation
Events
show
when shownhide
when hiddenremove
(item) when an item is removedclear
when the menu has been clearedselect
(item) when an item is selected*
menu item events are emitted when clicked
Example
var Menu = ; var menu = ; menu; menu; menu; { e; menu; menu;};
API
Menu()
Create a new Menu
:
var Menu = ;var menu = ;var menu = ;
Menu#add([slug], text, [fn])
Add a new menu item with the given text
, optional slug
and callback fn
.
Using events to handle selection:
menu; menu;
Using callbacks:
menu;
Using a custom slug, otherwise "hello" is generated
from the text
given, which may conflict with "rich"
styling like icons within menu items, or i18n.
menu; menu; menu;
Menu#remove(slug)
Remove an item by the given slug
:
menu;menu;
Or with custom slugs:
menu;menu;
Menu#clear()
Clears the menu.
menuclear;
Menu#has(slug)
Check if a menu item is present.
menu; menu;// => true menu;// => true menu;// => false
Menu#moveTo(x, y)
Move the menu to (x, y)
.
Menu#show()
Show the menu.
Menu#hide()
Hide the menu.
License
MIT