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 🙏

© 2026 – Pkg Stats / Ryan Hefner

arjandev32-color-picker

v1.0.0

Published

A color picker in javascript

Downloads

11

Readme

A ColorPicker in JavaScript

this module is a class with which you can make a colorpicker:

class ColorPicker{
  parent: htmlElement //parent element of the color-picker
  initialColor: string // itial color of the color-picker
  name: string // name of the color-picker
  colorFormat: string // color format of color-picker which are "RGBA", "HSLA" and "HEX"
  layout: array[object]// layout of color-picker components
  draggable: boolean // makes the color-picker draggable
  width: number // width of the color-picker
  styleSheet: object[string] // a stylesheet for the components of the color-picker 
  intialClipBoardSwatches: array[string] // initial swacthes within the clipboard 
}

layout

layout is an array of objects and those objects are components that determine the structure of the color-picker.

these components are:

  • modal: color gradient surface.

  • textInputField: container for the text input.

    • textInput
    • colorDisplay
  • clipboard: a color clipboard.

    • clipBoardField: container for the clipboard text-input.
      • clipBoardTextInput: text-input for the clipboard container.
    • clipBoardSwatchContainer: container for clipboard swatches.
  • ranges : container for color sliders.

    • hueRange: slider that controls the hue of the current color.
    • opacityRange: slider that controls the opacity of the current color.
  • custom: custom container that can be any html element.

example

[
  {type:"modal"},
  {type:"textInputField",layout:[{type:"colorDisplay"},{type:"textInput"},]},
  {type:"clipBoard",style:"width:200px;",layout:[
    {type:"clipBoardInputField",layout:[{type:"clipBoardTextInput"}]},
    {type:"clipBoardSwatchContainer",swatchLimit:20}
  ]},
  {type:"ranges", layout:[{type:"hueRange"},{type:"opacityRange"}]},
  {type:"custom",data:container},
]

styleSheet

similar to layout, but it's instead an object of conponents where each component is a string of custom css styles.

example

:{
  BG:"width:210px; background-color:white;",
  dragBar:"width:210px; background-color:rgb(235,235,235);",
  modal:"width:200px; height:100px; border-radius:5px;",
  textInputField:"width:200px;",
  colorDisplay:"margin-right:10px;",
  textInput:"color:black; box-shadow:1px 20px rgba(25, 25, 25, 0); outline:none;border-radius: 5px;text-align:center;width:75%;background-color:rgb(235,235,235); border:none; height:25px;",
  clipBoard:"width:200px;",
  clipBoardInputField:"width:200px; height:40px;",
  clipBoardTextInput:"outline:none; border-radius: 5px;width:100%;background-color:rgb(235,235,235); border:none;text-align:center;height:25px;rgb(25,25,40);",
  clipBoardSwatchContainer:"width:200px; box-shadow:1px 1px 50px rgba(23, 23, 23, 0.3); max-height:100px;",
  ranges:"width:200px; height:40px;",
  clipBoardSwatch:"width:15px;height:15px;",
  clipBoardSwatchCapsule:"width:30px;height:30px;box-shadow: 1px 1px 10px rgba(23, 23, 23, 0.3);"
}

this class also consist of 2 function:

function iniit() // initializes the color-picker
function update(styleSheet:object) // updates the style of the color-picker

in order to recieve color data from the color-picker you must add an eventlistener to the document who's type should be the name that you've given to the color-picker.

example

document.addEventListener("colorpicker",(e)=>{
  component.style.backgroundColor = e.detail.rgba
})

in order to update the color-picker state with your own color input you must create a custom event who's type should be "update-" + (the name you've given to the color-picker).

example

let InputColor = new CustomEvent("update-colorpicker",{detail:{input:"orange"}})
document.dispatchEvent(InputColor)

in order to use add the code below in your html

  <link rel="stylesheet" href="cp.css"/>
  <script type="module" src="cp.js" defer></script>