JSPM

@karim04/dropdown-menu

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q40739F
  • License MIT

Create ready-to-go dropdown menus in Javascript

Package Exports

  • @karim04/dropdown-menu
  • @karim04/dropdown-menu/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@karim04/dropdown-menu) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@karim04/dropdown-menu

a Javascript module that creates ready-to-go dropdown menus
Preview Image

installation

npm install --save @karim04/dropdown-menu

Usage

import the module in your code
import Dropdown from '@karim04/dropdown-menu';
and create a dropdown menu using:
const menuName = Dropdown.create(triggeringElement);

pass any element to the create method and it will create a dropdown menu for that element that will be toggled by clicking on that triggering element, and it returns you the dropdown menu object

disabling default styling

if you want to disable default styling to add your own, pass false to the second paramater in the create method

const menuName = Dropdown.create(triggeringElement, false);

Returned Object Methods and properties

Add Menu Item
menuName.add(itemElement, onClickFunc);

first arguement takes an element or a string and adds it to the menu as an item, and the second argument takes a function that is trigged when the item is clicked

menuName.menu;

returns the menu element that contains the items

element property
menuName.element;

returns the parent element that triggers the menu

License

This project is licensed under the MIT license.