GithubHelp home page GithubHelp logo

glebkema / jquery-stylize-select Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 55 KB

This plugin adds blocks around the selection field and creates the necessary event handlers. You can stylize the look of these blocks using the CSS. The plugin simplifies website development.

License: MIT License

CSS 29.07% JavaScript 47.90% HTML 23.02%
jquery-plugin select custom-select

jquery-stylize-select's People

Contributors

glebkema avatar

Watchers

 avatar  avatar

jquery-stylize-select's Issues

Provide a way to style the selected list item

It is required to set styles through CSS for the list item that is currently selected.

The selected <option> can be styled through :selected. But the plugin does not pass this property to the corresponding <li> item.

For example, a plugin can add and remove a style class when the user selects a new item from the list. Like .custom-select__selected or something like that.

Need a convenient way to run the plugin

The plugin currently uses too many entities:

  • It adds specific CSS class names for inherent CSS properties.
  • It is required to call the jQuery method for the selector with the select field that the user wants to style.
  • The user can define their own CSS classes for the HTML layout that will be compiled by the plugin.

So, we already have 3 types of CSS classes:

  1. define target select \field
  2. provide oligatory CSS properties
  3. apply user CSS properties

I would like to simplify the start method and to make the final ierarchy of CSS clases more predictable. For example:

  • User can start the plugin without JS-code:
    • by adding of specific CSS class name (as Owl Carousel);
    • by adding of specific data attributes (as FancyBox).
  • User can define the structure of CSS clases:
    • by the data atributes;
    • by setting of the plugin defaults;
    • by the array of options for the plugin function.

Remove the `hidden` style class

Currently the plugin uses 6 style classes. It;s too many, I guess.
And the tole of the hidden class is to add the display:none; property only.

So the plugin can work with the display property and use the ,hide() and .show() methods without any additional style classes.

Use a label for the select field

The original <select> tag is used in conjunction with the <label> tag. But this plugin does not create any blocks with the label content and its functionality.

I usually customize the selection box to use it without any label. But for other users the label may be important. And, of course, if the original select has a label, then this plugin should suggest a way to use the contents of this label.

Also clicking on the label should work.

Change plugin name and function name

There are a few jQuery Custom Select Plugins with the .customSelect() function:

Because of this, users can get confused, and methods can start to override each other.

In addition, this plugin is intended for developers, and not for end users. Therefore, the name of the plugin should create the correct user expectations.

What names best describe the purpose of the plugin and its function?

Focus disappears after selecting an option in the drop-down list

When I choose an item in the drop-down list by pressing the Space or Enter, Ithe drop-down list closes and... focus dissappeers.

It seems to me that it will be logical and predictable if in such situations the focus moves to the main select field.

In this case the user will be able to continue browsing the web page using the keyboard.

Need tests

  • Need to quickly test new features.
  • Must automatically verify that old features still work well.

Support for the up and down arrow keys in the drop-down list

At present the plugin plays good with keys Tab, Space and Esc.

It would be nice to provide ⬆️ and ⬇️ for wslking up and down throw the drop-down-list

On the main field ⬇️ opens 📜 . On second click ⬇️ leads to the top of 📜.
In 📜 man can walk by ⬆️ and ⬇️ .
On the top of 📜 ⬆️ leads to the main field und closes 📜 by the next click ⬆️ .

Need the way to use images in the options layout

Let's add the way to use images in the layout of options.

For example, a user may add some of the data attributes to the options of the original selection field. Based on these attributes, the plugin adds some HTML block or style attribute to the resulting list. After that, the user can customize the appearance of these images using CSS properties.

Something like that:

<option value="apple" data-image="/images/apple.jpg">Apple</option>

I prefer to use theese images as a background image. But perhaps someone needs the iamge in the <img> tag or in the some additional HTML block.

<li rel="apple" style="background-image:url('/images/apple.jpg');">Apple</li>
<li rel="apple">
	<img class="custom-select__image" src="/images/apple.jpg" />
	Apple
</li>
<li rel="apple">
	<div class="icon-box">
		<div class="icon-box__image" src="/images/apple.jpg"></div>
	</div>
	Apple
</li>

Provide public methods

It is necessary to make the options selected, hidden / visible and disabled / enabled by special methods from external scripts without knowledge of the CSS classes used by the plugin.

Something like this:

var selectSomething = $('.select-something).stylizeSelect();
selectSomething.getOption('value').makeDisabled();

Or maybe like this:

$('.select-something).stylizeSelect();
$('.select-something).getOption('value').makeDisabled();

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.