Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ewc-lib/ewc-menu

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ewc-lib/ewc-menu

![Screenshot](./screenshot.png)

  • 0.1.7-alpha
  • latest
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

Screenshot

Screenshot

API

There are the following properties:

  • data - set contents of the menu. expects a map, key=main-menu item, value=[array of sub-menu items]. see example below.
  • select - sets currently selected item. expects a key of the map or the id of a sub-menu.
  • onSelect - a callback which is called when a menu/submenu item was selected
    • callback signature: myCallback(subMenuId, menuId, isMainMenuItem)
      • isMainMenuItem === true means, main-menu item was selected
        • Note: subMenuId === menuId in that case

Note: Any menu-item-id === name/text of the item.

Usage with WebPack

package.json

"dependencies": {
  "@ewc-lib/ewc-menu": "latest"
}

webpack.config.js

...

module: {
  rules: [
    {
      test: /\.css$/i,
      use: [
        'style-loader',
        'css-loader'
      ]
    }
  ]
}

index.html

<body>
  <ewc-menu></ewc-menu>
  <script>
    document.addEventListener('DOMContentLoaded', function () {
      const el = document.getElementsByTagName("ewc-menu")[0]
      const d = new Map()
      d.set("FILE", ["Open","Save","Close"])
      d.set("EDIT", ["Copy","Cut","Paste"])
      d.set("HELP", ["Help","About"])
      el.data = d
      el.onSelect = (subMenuId, menuId, isMainMenuItem) => 
        alert(`Menu selection: ${menuId} ${subMenuId}\nWas a main menu item selected? -> ${isMainMenuItem}`)
      el.select = "Cut"
    })
  </script>
</body>

main.js

import "@ewc-lib/ewc-menu"

FAQs

Package last updated on 07 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc