Giter Club home page Giter Club logo

webantic-select's Introduction

Webantic Select

A lightweight, no-css select library.

Markup generated is super-minimal and confirms to RSCSS guidelines for easy styling.

Usage

Install with npm i --save @webantic/select

Just require (use something like browserify), give it either a text input element or a select element and you're good to go.

   var Select = require('@webantic/select')

   var myDropdown = new Select(document.querySelector(".js-select"), {
     options: [
      {
        text: 'One',
        value: 1,
        selected: true
      },
      {
        text: 'Two',
        value: 2
      },
      {
        text: 'Three',
        value: 3
      }
     ]
   })

If you use a select element, the options will be parsed automatically and used. So will the multiple attribute if present

When you're ready to grab the value from the DOM you can do so by looking for the element with the same name as your original input. You can also use the .value() method

e.g. if you used a select with a name of gender you should see a gender field in your formData still. (for multi-select elements you'll need to JSON.parse the value to get an array)

Config

You can pass a config object as a second argument to the constructor.

options: (required for text inputs). An array of options. e.g.

  [ 
    {
      value: 33,
      text: "thirty three",
      selected: true
    },
    {
      value: "Ad0s9a8dS",
      text: "Paul"
    }
  ]

position: (default fixed) either "absolute" or "fixed". Represents the css position type. If fixed is used the dropdown will disappear on scroll.

multiple: (default false) either true or false, if you want to enable multiple selections

search: (default false) either true or false, whether you want to enable text search in the dropdown - useful for big datasets.

text

viewport

isModal

oneOpen

classWrapper class for the mounted div

classValue class for the select

classOption class for the select option

inline true or false

webantic-select's People

Contributors

carlevans719 avatar joestephens avatar

Watchers

 avatar  avatar

webantic-select's Issues

Have to be careful when scrolling

Scroll too far and you run out of scroll space and start scrolling the body - which closes the select. We should maybe just prevent scrolling while the select is open?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.