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

reinvented-color-wheel

v0.4.0

Published

A vanilla-js touch-friendly HSV color picker inspired by Farbtastic Color Picker.

Downloads

3,410

Readme

Reinvented Color Wheel

npm jsDelivr

image

A vanilla-js touch-friendly HSV color picker inspired by Farbtastic Color Picker.

Demo

Characteristics

  • HSV (hue, saturation, value) cylindrical color model (unlike Farbtastic that takes HSL)
  • Touch-friendly
  • No need jQuery
  • Lightweight (JS + CSS ~ 3.1 KB minified + gzipped)

Installation

via npm (with a module bundler)

$ npm install reinvented-color-wheel
import "reinvented-color-wheel/css/reinvented-color-wheel.min.css";
import ReinventedColorWheel from "reinvented-color-wheel";

via CDN (jsDelivr)

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/reinvented-color-wheel.min.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script>/* `window.ReinventedColorWheel` object is available */</script>

or for modern browsers:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/reinvented-color-wheel.min.css">
<script type="module">
  import ReinventedColorWheel from "https://cdn.jsdelivr.net/npm/[email protected]/es/reinvented-color-wheel.bundle.min.js";
</script>

Download directly

reinvented-color-wheel.min.css
reinvented-color-wheel.min.js

Usage

// create a new color picker
var colorWheel = new ReinventedColorWheel({
  // appendTo is the only required property. specify the parent element of the color wheel.
  appendTo: document.getElementById("my-color-picker-container"),

  // followings are optional properties and their default values.

  // initial color (can be specified in hsv / hsl / rgb / hex)
  hsv: [0, 100, 100],
  // hsl: [0, 100, 50],
  // rgb: [255, 0, 0],
  // hex: "#ff0000",

  // appearance
  wheelDiameter: 200,
  wheelThickness: 20,
  handleDiameter: 16,
  wheelReflectsSaturation: true,

  // handler
  onChange: function (color) {
    // the only argument is the ReinventedColorWheel instance itself.
    // console.log("hsv:", color.hsv[0], color.hsv[1], color.hsv[2]);
  },
});

// set color in HSV / HSL / RGB / HEX
colorWheel.hsv = [240, 100, 100];
colorWheel.hsl = [120, 100, 50];
colorWheel.rgb = [255, 128, 64];
colorWheel.hex = '#888888';

// get color in HSV / HSL / RGB / HEX
console.log("hsv:", colorWheel.hsv[0], colorWheel.hsv[1], colorWheel.hsv[2]);
console.log("hsl:", colorWheel.hsl[0], colorWheel.hsl[1], colorWheel.hsl[2]);
console.log("rgb:", colorWheel.rgb[0], colorWheel.rgb[1], colorWheel.rgb[2]);
console.log("hex:", colorWheel.hex);

// please call redraw() after changing some appearance properties.
colorWheel.wheelDiameter = 400;
colorWheel.wheelThickness = 40;
colorWheel.redraw();

Web Components

This package contains the Web Components wrapping the color wheel.
The tag is <reinvented-color-wheel>.
The options above except for appendTo can be specified with kebab-case, and each option is optional.

<!-- CSS is included in JS: no <link> is needed. -->
<script src="reinvented-color-wheel/webcomponents/index.js"></script>

<reinvented-color-wheel
  hex="#ff3e00"
  wheel-diameter="200"
  wheel-thickness="20"
  handle-diameter="16"
  wheel-reflects-saturation="false"
></reinvented-color-wheel>

<!-- hsv, hsl or rgb can be specified as a comma-separated string. -->
<reinvented-color-wheel rgb="255,62,0"></reinvented-color-wheel>

React Component

This package contains the React component wrapping the color wheel.
The options above except for appendTo can be specified, and each option is optional.

import React from 'react'
import ReinventedColorWheel from 'reinvented-color-wheel/react'
import 'reinvented-color-wheel/css/reinvented-color-wheel.min.css'

const App = () => {
  const [hex, setHex] = React.useState('#000000')
  return (
    <>
      <ReinventedColorWheel
        // hsv={[0, 100, 100]}
        // hsl={[0, 100, 50]}
        // rgb={[255, 0, 0]}
        // hex="#ff0000"
        hex={hex}
        wheelDiameter={200}
        wheelThickness={20}
        handleDiameter={16}
        wheelReflectsSaturation
        onChange={({ hex }) => setHex(hex)}
      />
      <input value={hex} onChange={e => setHex(e.target.value)} />
    </>
  )
}

License

WTFPL

Sister Package

lch-color-wheel: L*C*h color wheel