GithubHelp home page GithubHelp logo

selectron's Introduction

!!! NOT ACTIVELY MAINTAINED !!!

I am no longer maintaining this proejct, if you want to take over, feel free to drop me a msg.

Selectron

An accessible jQuery custom select, styled with sass for easy customization
http://dahliacreative.github.io/selectron/

Installation

Bower

bower install --save jquery-selectron

Usage

HTML

<select class="selectron">
  <option value="">Please select something</option>
  <option value="1">Option 1</option>
  <option value="2">Option 2</option>
</select>

JS

$('.selectron').selectron();

Search

You can enable search by passing the option when you initialize the plugin.

$('.selectron').selectron({
  search: true
});

Alternativley you can enable/disable search on inidividual instances using a data attribute:

<select class="selectron" data-selectron-search="true">
  <option value="">Please select something</option>
  <option value="1">Option 1</option>
  <option value="2">Option 2</option>
</select>

Themes

There are three default themes, light, dark and block. The light theme is applied by default, to apply the dark theme simply add the selectron--dark class to your select, and to apply the block theme simply add selectron--block.

<select class="selectron selectron--dark">
  <option value="">Please select something</option>
  <option value="1">Option 1</option>
  <option value="2">Option 2</option>
</select>
<select class="selectron selectron--block">
  <option value="">Please select something</option>
  <option value="1">Option 1</option>
  <option value="2">Option 2</option>
</select>

Icons

You can add an icon to your options by simply adding a data-icon attribute to the option.

<select class="selectron selectron--dark">
  <option value="">Please select something</option>
  <option value="1" data-icon="http://placehold.it/30x20">Option 1</option>
  <option value="2" data-icon="http://placehold.it/30x20">Option 2</option>
</select>

Classes

Any classes you add to your select or option will get copied across to selectron, this is useful for custom themes or for adding icons to options.

<select class="selectron my-class">
  <option value="">Please select something</option>
  <option value="1" class="my-class">Option 1</option>
  <option value="2" class="my-class">Option 2</option>
</select>

Customization

Selectron has been written to be easily customized using Sass variables. To overwrite the defaults simply define your variables before the inclusion of selectron.sass.

Available variables

$selectron-border-radius:           4px !default
$selectron-border-width:            1px !default
$selectron-color-background-dark:   #363636 !default
$selectron-color-background-light:  #ffffff !default
$selectron-color-brand:             #f70c36 !default

$selectron-color-font-dark:         #666666 !default
$selectron-color-font-light:        #999999 !default
$selectron-font-family:             sans-serif !default
$selectron-font-size:               13px !default
$selectron-line-height:             1.2 !default
$selectron-text-align:              left !default

$selectron-max-width:               400px !default
$selectron-min-width:               200px !default
$selectron-height:                  50px !default
$selectron-options-max-height:      200px !default

$selectron-padding:                 17px 50px 18px 18px !default
$selectron-option-padding:          13px 18px 14px !default
$selectron-optgroup-padding:        13px 18px 14px 28px !default

$selectron-arrow-border-width:      2px !default
$selectron-arrow-border-radius:     0px !default
$selectron-arrow-size:              10px !default
$selectron-block-width:             50px !default

$selectron-max-icon-size:           50px !default
$selectron-icon-margin:             0 10px 0px 0 !default

Events

Selectron triggers a change event on the select;

Methods

Selectron provides an selectron.update method which when triggered on the select will re-populate the options. It also provides a selectron.change method which when triggered on the select will update the sellectron trigger to match the value of the select

License

Copyright (c) 2016 Simon Sturgess

Licensed under the MIT license.

selectron's People

Contributors

dahliacreative avatar carlkelly avatar kjbrum avatar

Stargazers

Abderrahim avatar Michael Andish avatar Koki Oyatsu avatar  avatar Andy Farmer avatar  avatar

Watchers

James Cloos avatar

selectron's Issues

Border-width

Ability to remove borders.

StopTheLag

kthnxbye xx

Prototype structure

Should use a prototype code base with public functions for each select. Allowing the ability for other functions to interact with selects, such as when another select is chosen and it changes the results in a different select.

Arrow :after

Could use a single pseudo element for the arrow. Make it square, then apply border bottom & right. Then rotate -45deg. ez

UI Issues

Not sure what's the use of this codes:
if (this.opts.search) {
firstOption.addClass('selectron__option--is-hovered');
}
Because of this, the first option "Please select category" gets selected every time. hence I had removed these lines and now I am not getting the issue.

Exclude "placeholder" option when typing

If you attempt to type an option, and the placeholder option (eg. Please select...) contains what you are typing, it jumps to that. It'd be good to exclude that option so that it doesn't get in the way.

drop down overflowing issue

when one inspect on browser & inspector boundry come near to it then when we click on it its dropdown is invisible.

Search bar no longer appears.

Great little plugin you have created.
The main reason I started using it was the ability to search from long lists. Now this functionality seems broken. I thought this was my own issue until I saw the same thing on your demo site. I tried versions 2.0.0, 2.0.5 and 2.0.6 I was not able to figure out the issue on my own at this time.

Accessiblity

I'm not sure you can say "An accessible jQuery custom select, styled with sass for easy customization" without the plugin including the appropriate aria attributes.

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.