npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ceri-dropdown

v0.2.1

Published

a advanced dropdown menu

Downloads

5

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

Install

npm install --save-dev ceri-dropdown

Usage

window.customElements.define("ceri-dropdown", require("ceri-dropdown"))
<!-- 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/.

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

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

<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.
  • read and understand the default enter and leave animation in src/dropdown.coffee
  • you can provide a custom animation like this:
# 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.

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.