1.0.19 • Published 6 years ago

@sushi-ui/su-dropdown v1.0.19

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Su-Dropdown

Dropdown component.

Installing

yarn install @sushi-ui/su-dropdown

or

npm install @sushi-ui/su-dropdown

Setup

import '@sushi-ui/su-dropdown/lib/su-dropdown.css'
import SuDropdown from '@sushi-ui/su-dropdown'

or

<link rel="stylesheet" href="node_modules/@sushi-ui/su-dropdown/lib/su-dropdown.css">
<script src="node_modules/@sushi-ui/su-dropdown/lib/su-dropdown.js"></script>

Getting started

The .su-Dropdown and .su-Dropdown-content classes are mandatory in the markup. The .su-Dropdown-content element needs to be sibling to the trigger element. Only the trigger element and the element with class .su-Dropdown-content must be inside the .su-Dropdown wrapper element. Feel free to style the su-Dropdown-content element.

Minimum HTML markup

<div class="su-Dropdown">
  <button>trigger</button>
  <div class="su-Dropdown-content">
    // dropdown content
  </div>
</div>

Create a new dropdown instance

const el = document.querySelector('.su-Dropdown')
const dropdown = new SuDropdown(el, options)

Options

PropTypeDefaultValid optionsDesc
offsetXNumber0Any number-
offsetYNumber0Any number-
paddingNumber16Any numberPadding from boundary element
boundariesString,HTMLElementviewportscrollParent, window, viewport or any DOM element
placementStringbottom-startauto, top, right, bottom, leftOption can also have modifier (-start, -end)
closeOnClickInsideBooleanfalsetrue/false-
closeOnClickOutsideBooleantruetrue/false-

API

toggle()

Show/hide dropdown

show()

Show dropdown

hide()

Hide dropdown

destroy()

Remove all event listeneres from the dropdown component.

Events

Dispatches from the dropdown node element

show

Triggers on show

hide

Triggers on show

License

This project is licensed under the MIT License - see the LICENSE.md file for details

1.0.19

6 years ago

1.0.18

6 years ago

1.0.17

6 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.0

6 years ago