1.0.2 • Published 3 years ago

@irfanismail/mon-dropdown v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

mon-dropdown

MonDropdown a feature-rich dropdown Vue2 component. It focuses on bringing the best of Vue's features to achieve common & advanced behavior patterns while giving you the freedom to style the component to your liking. Built-to-work with TailwindCSS.

mon-dropdown-gif

Demo

Getting Started

// npm
npm i @irfanismail/mon-dropdown

// yarn
yarn add @irfanismail/mon-dropdown

Usage

  1. Table of Props
PropsTypeDefault
labelstring
labelClassstring
contentClassstring'mon-dropdown-content'
enterActiveClassstring'mon-dropdown-enter-active'
enterClassstring'mon-dropdown-enter'
enterToClassstring'mon-dropdown-enter-to
leaveActiveClassstring'mon-dropdown-leave-active'
leaveClassstring'mon-dropdown-leave'
leaveToClassstring'mon-dropdown-leave-to'
anchorbooleanfalse
dropUpbooleanfalse
persistentbooleanfalse
disableClickAwaybooleanfalse
disableEscbooleanfalse
openOnMountbooleanfalse
  1. Combinations of Slots & Props
<!-- Basic Dropdown -->
props: 
* label
* labelClass
* anchor
* dropUp
* persistent
* disableClickAway
* disableEsc
* openOnMount 
  <mon-dropdown [...props]>
      <template #content="{ close, toggle }">...</template>
  </mon-dropdown>
  
<!-- Custom Trigger -->
props: 
* anchor
* dropUp
* persistent
* disableClickAway
* disableEsc
* openOnMount 

  <mon-dropdown [...props]>
    <template #trigger="{ toggle, open }">...</template>
    <template #content="{ toggle, close }">...</template>
  </mon-dropdown>
  
  1. Lifecycle Hooks
HooksType
before-openfunction
after-openfunction
before-closefunction
after-closefunction

Check the Demo on how to use dropdown lifecycle hooks

  1. Handling Dropdown Behavior outside Usual Scope

There will be times, you will find yourselves needing to trigger dropdown behaviors outside of the normal scope (eg. clicking a button). MonDropdown provides three (3) internal functions that can be accessed through Vue's ref="..." & $refs.

The three (3) functions are:

  • toggleDropdown()
  • openDropdown()
  • closeDropdown()

Check the Demo on how to use dropdown's internal functions

License

MIT License

Contact

Irfan Ismail - @irfancoder - irfan.ismail96@gmail.com