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

simple-selector

v4.0.0

Published

An es6 class to replace default select inputs with easy to style HTML.

Downloads

28

Readme

Simple Selector

Simple Selector is an es6 class used to create easily styleable select input. Simple Selector will create an HTML template that visually takes the place of your standard select tag.

Installation

npm i simple-selector
yarn add simple-selector
Note: Version 2.0.0+ includes breaking changes. You will need to update your working environment to reflect this update, or continue using the latest 1.5.0 release.
npm i [email protected]

Usage

<select name="my-select" id="MySelect" class="js-select">
	<option value="1">View All</option>
	<option value="2">Option 1</option>
	<option value="3">Option 2</option>
</select>
import SimpleSelector from 'simple-selector';

const select = document.querySelector('.js-select');

const Selector = new SimpleSelector(select, {
    placeholder: 'Select your favourite.',
});

Options

| Option | Type | Description | |--------|------|-------------| | search | Boolean or String (default: 'Search') | True / False to enable / disable String will be true and change the placeholder text. | | class | String (default: 'selector') | If you want more than one style of selector, you can change this class to suit your needs | | placeholder | String (default: placeholder attribute or 'Select') | Will update the default text on the Simple Selector | | autoClose | Boolean (default: true) | When multiple is false, autoClose: true will close the Selector when an option is clicked | | taglist | Boolean (default: false) | When multiple is true, taglist: true will display the selected options as tags in the select header |

Methods

The majority of the SimpleSelector functionality should happen automatically, although you may need to take control manually on some occations.

Update the options dynamically

If the options in the default select have been updated dynamically, simply call the reinit() method. You may also optionally need to call the update() method

SimpleSelector.reinit();
SimpleSelector.update();

Callbacks

Each of the following methods has a callback. These can be used with the on() method

  • reinit
  • update
  • open
  • close
  • filter
SimpleSelector.on('update', (selector) => {
    console.log('selector updated!');
});

SCSS Mixin - defaults

.selector {
  @include simple-selector (
    $min-width: 32rem,
    $border-radius: 0,
    $border-width: .1rem,

    $header-color: $black,
    $header-border-color: rgba($black, .2),
    $header-background-color: $white,
    $header-padding: 1rem 4rem 1rem 2rem,

    $chevron-color: $black,

    $list-border-color: rgba($black, .2),
    $list-background-color: $white,
    $list-padding: 0,

    $search-color: $black,
    $search-border-color: rgba($black, .2),
    $search-background-color: $white,

    $option-color: $black,
    $option-background-color: $white,
    $option-transition-speed: 0.3s,

    $option-color--hover: $black,
    $option-background-color--hover: rgba($black, .1),

    $option-color--active: $white,
    $option-background-color--active: rgba($black, .6),
  )
}

Browser Support

Desktop: Firefox 16+ ✓ Chrome 15+ ✓ Safari 5.1+ ✓ IE 10+ ✓

Mobile: Safari iOS 5.1+ ✓ Chrome Mobile 47+ ✓

Note: (Might work on earlier versions of chrome, but I couldn't test it.)

License

MIT