0.1.3 • Published 10 months ago

luna-menu v0.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

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.
0.1.3

10 months ago

0.1.2

1 year ago

0.1.1

3 years ago

0.1.0

4 years ago