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

high-select

v0.2.0

Published

custom select element with custom search records and using html in option with custom style.

Downloads

7

Readme

high-select

high-select is a custom element looks like classic select HTML element but with more capabilities like putting HTML tags in its options, customizing search records for any options and customizing its styles.

Installation

You can use high-select via script tag or NPM.

Script Tag

add below tag to your html document

<script  type="module" src='https://unpkg.com/[email protected]/lib/high-select.js'></script>

NPM

 npm install high-select --save

once you installed the package, you can add this tag to your html document

<script  type="module" src='node_modules/high-select/lib/high-select.js'></script>

Usage

first, create your high-select tag

<high-select></high-select>

then add some high-options inside it

<high-select>
    <high-option> option 1 </high-option>
    <high-option> option 2 </high-option>
    <high-option> option 3 </high-option>
    <high-option> option 4 </high-option>
    <high-option> option 5 </high-option>
</high-select>

your high-select element is ready.

How does it work?

high-select let you select an option from a list of them, like the classic one. so the value of selected option will be the value of the select element.

value of an option

until you give an option a value attribute, the option's innerText would be the value of that. so if values of your options are unreadable or coded or ... give options the value attribute like this:

<high-option value="1"> Option 1 </high-option>

default value of select

if you give an option a selected attribute, it would be the high-select value untill user change it. otherwise the first option would be selected by default.

search

to enable search in options you should give the high-select a search attribute.

<high-select search></high-select>

arrow

to enable arrow in options you should give the high-select a arrow attribute.

<high-select arrow></high-select>

animated

to enable animation in options you should give the high-select a animated attribute.

<high-select animated></high-select>

customize the search

give options a record attribute and put your records there, when user search for something, high-select search for any string in the record attribute and innerText of all options to find the match.

<high-select search>
    <high-option value="1" record="one uno"> option 1 </high-option>
</high-select>

above option would be found one search input of "1", "o", "one", "uno"

using html in options

you can use any html tags in the high-options tags including img, ... , but you must give the option a title attribute, so when user select the option, title would be shown as selected option.

<high-select animated arrow search>
    <high-option>Select a country</high-option>
    <high-option value="it" title="italy">
        <img src="an-image-of-italy">    
    <high-option>
    <high-option value="fr" title="france">
        <img src="an-image-of-france">    
    <high-option>
</high-select>

disabling

you can disable high-select and its options at any time, just give them a disabled attribute.

manipulating by javascript

high-select state could be accessed and change via javascript.

getting select value

select the high-select element and get its value property.

document.querySelector("high-select").value;

changing the select value

put the value in the high-select value property.

document.querySelector("high-select").value = "it";

if the value you give high-select would not be available in options, it simply ignore it.

change options selected property

if you give any options of high-select a selected property. the option change the select value.

document.querySelector("high-select").children[2].selected = true;

change event

you can catch the change event of high-select by listening to it. whenever the value change by user interacting with element, high-select tells you.

document.querySelector("high-select").addEventListener("change", function(){
    console.log(this.value);
});

user Experience

user could interact with high-select via mouse and keyboard easily. (Enter, Esc, Arrow down, Arrow up, Home, End)

styling

customize high-select styles.

high-select's HTML structure

high-select use shadow dom for the most part of itself, so styling it would not be so easy, the structure of its shadow dom is like this:

there is an element with id of caller, caller would call the list of options which it is in another element with id bigot. inside bigot we have search which contains an input element and holder which hold the options.

styling variables

there is list of css variable that make you able to change the shadow dom's elements style:

--caller-padding

--caller-background

--caller-shadow

--caller-color

--caller-border-radius

--caller-disabled-color

--caller-disabled-background

--caller-hover-cursor

--caller-hover-background

--caller-hover-color

--caller-focus-outline

--arrow-font-size

--arrow-margin

--arrow-color

--bigot-shadow

--bigot-background

--bigot-border

--input-outline

--input-margin

--input-width

--input-border-width

--input-border-color

--input-border-style

--input-font

--input-padding

--input-color

--input-background

--animated-time

--option-padding

--option-border

--option-hover-background

--option-hover-color

--option-disabled-background

--option-disabled-color

--option-active-background

--option-active-color

--option-selected-background

--option-selected-color

please suggest us if you think there could be more variables needed.

problem and issues

  • currently high-select not working properly in iframe and a tranformed container, any idea about how to fix it?

  • edge has issues with display properties of shadow dom elements.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin new-feature
  5. Submit a pull request :D

License

MIT LICENSE