Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/segment-boneyard/menu
A menu UI element, with items that can be selected.
https://github.com/segment-boneyard/menu
Last synced: about 7 hours ago
JSON representation
A menu UI element, with items that can be selected.
- Host: GitHub
- URL: https://github.com/segment-boneyard/menu
- Owner: segment-boneyard
- Created: 2013-07-13T00:12:00.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-01-29T21:53:30.000Z (almost 11 years ago)
- Last Synced: 2024-04-09T16:31:12.413Z (7 months ago)
- Language: JavaScript
- Size: 270 KB
- Stars: 5
- Watchers: 38
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
Awesome Lists containing this project
README
# Menu
A menu UI element, with items that can be selected.
## Installation
$ component install segmentio/menu
## Example
For quick, standard menus, treat it as a constructor:```js
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.
```js
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');
```## API
### new Menu()
Initialize a new Menu the default item view:```html
```
### menu(View)
Create a new `Menu` constructor with the given `Item` view.
### .add(model | id)
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(id)
Select a menu item.
### .deselect()
Deselect all menu items.
## License
MIT