# ceri-dropdown

> a advanced dropdown menu

Latest version **0.2.1** (published 2017-09-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install ceri-dropdown
pnpm add ceri-dropdown
yarn add ceri-dropdown
bun add ceri-dropdown
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2017-09-07 |
| First published | 2017-03-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | * |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Paul Pflugradt |
| Maintainers | paulpflug |
| Keywords | dropdown, component, ceri |

## Links

- npm: https://www.npmjs.com/package/ceri-dropdown
- Repository: https://github.com/ceri-comps/ceri-dropdown
- Homepage: https://github.com/ceri-comps
- Issues: https://github.com/ceri-comps/ceri-dropdown/issues
- npm.io page: https://npm.io/package/ceri-dropdown

## Dependencies (1)

- [ceri](https://npm.io/package/ceri.md) ^1.0.26

## Recent versions

- 0.2.1 (latest) — 2017-09-07
- 0.2.0 — 2017-09-07
- 0.1.0 — 2017-07-16
- 0.0.6 — 2017-07-04
- 0.0.5 — 2017-03-24
- 0.0.4 — 2017-03-19
- 0.0.3 — 2017-03-18
- 0.0.2 — 2017-03-18
- 0.0.1 — 2017-03-18

## README

# ceri-dropdown

a advanced dropdown/up/left/right menu.

Features:
- plain JS - no dependencies
- themeable
- use in your markup - easy to reason about
- aware of the viewport - automatically changes opening direction to be visible

### [Demo](https://ceri-comps.github.io/ceri-dropdown)

# Install

```sh
npm install --save-dev ceri-dropdown
```

## Usage
- [general ceri component usage instructions](https://github.com/cerijs/ceri#i-want-to-use-a-component-built-with-ceri)
- in your project
```coffee
window.customElements.define("ceri-dropdown", require("ceri-dropdown"))
```
```html
<!-- as sibling (preferred) -->
<button>Click to open dropdown</button>
<ceri-dropdown>
  <li><span>Line 1</span></li>
</ceri-dropdown>
<!-- as child -->
<button>Click to open dropdown
  <ceri-dropdown>
    <li><span>Line 1</span></li>
  </ceri-dropdown>
</button>
```

For examples see [`dev/`](dev/).

#### Props
Name | type | default | description
---:| --- | ---| ---
gutter | Number | 0 | horizontal offset
anchor | String | overlay ? "nw" : "sw" | point of the parent where it will be attached
keep-open | Boolean | false | will be not close on click outside of dropdown
constrain-width | Boolean | false | fix width to parent width
overlay | Boolean | false | will overlay parent
hover | Boolean | false | open on hover instead click
open | Boolean | false | set to open / close
on-body | Boolean | false | will be positioned on body instead of sibling/parent element. [Detailed description](#positioning)

#### Events
Name |  description
---:| ---
toggled(open:Boolean) | emitted before open and after close

#### Positioning
There are two ways of positioning. The default is in-place, the other possibility is on `body`.
- The in-place positioning can be problematic when you have an `overflow:hidden` combined with a `position:absolute|relative|fixed` element in the parent chain and the dropdown is overflowing.
- the `body` positioning can be problematic when the parent is moving relative to `body` or when you depend on inheritance of styles.

#### Themes
- [ceri-materialize](https://github.com/ceri-comps/ceri-materialize)
```html
<button class=btn>Click me!</button>
<ceri-dropdown class=materialize constrain-width overlay>
  <li><span>Content</span></li>
  <li><span>Content2</span></li>
</ceri-dropdown>
```

#### Custom animation
- read the documentation of the [animate mixin](https://github.com/cerijs/ceri#animate).
- read and understand the default enter and leave animation in [src/dropdown.coffee](src/dropdown.coffee)
- you can provide a custom animation like this:
```coffee
# application wide
CEDD = require("ceri-dropdown")
CEDD.prototype.enter = (o) -> # your new enter animation
CEDD.prototype.leave = (o) -> # your new leave animation
window.customElements.define("ceri-dropdown", CEDD)

# single instance
# get a ref to your instance of ceri-dropdown somehow
# then overwrite the animations directly
ceDD.enter = (o) -> # your new enter animation
ceDD.leave = (o) -> # your new leave animation
```

# Development
Clone repository.
```sh
npm install
npm run dev
```
Browse to `http://localhost:8080/`.

## Notable changes
#### 0.2.0
- use ceri-materialize@2

## License
Copyright (c) 2017 Paul Pflugradt
Licensed under the MIT license.

---
_Source: https://npm.io/package/ceri-dropdown · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
