luna-menu
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

Luna Menu

Simple menu.

Demo

https://luna.liriliri.io/?path=/story/menu

Install

Add the following script and style to your page.

<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/luna-menu/luna-menu.css" />
<script src="//cdn.jsdelivr.net/npm/luna-menu/luna-menu.js"></script>

You can also get it on npm.

npm install luna-menu --save
import 'luna-menu/luna-menu.css'
import LunaMenu from 'luna-menu'

Usage

const menu = new LunaMenu()
menu.append({
  type: 'normal',
  label: 'New File',
  click() {
    console.log('New File clicked')
  }
})
menu.show(0, 0)

Api

append(options: IMenuItemOptions): void

Append menu item.

insert(pos: number, options: IMenuItemOptions): void

Inert menu item to given position.

show(x: number, y: number, parent?: LunaComponent): void

Show menu at target position.

static build(template: any[]): LunaComponent

Create menu from template.

Types

IMenuItemOptions

  • label(string): Menu label.
  • submenu(LunaComponent): Sub menu.
  • type('normal' | 'separator' | 'submenu'): Menu type.
  • click(function): Click event handler.

Readme

Keywords

Package Sidebar

Install

npm i luna-menu

Weekly Downloads

4

Version

0.1.2

License

MIT

Unpacked Size

232 kB

Total Files

18

Last publish

Collaborators

  • surunzi