JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 42
  • Score
    100M100P100Q72485F
  • License MIT

🎨 Fast color conversion tool made in TypeScript

Package Exports

  • @thednp/color
  • @thednp/color/dist/index.cjs.js
  • @thednp/color/src/index.ts

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@thednp/color) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Color

Coverage Status ci NPM Version NPM Downloads jsDeliver cypress version typescript version esbuild version

A TypeScript flavored fork of the excelent TinyColor optimized for ColorPicker with new features and improvements:

  • added support for HWB(a) colors (Hue, Whiteness, Blackness);
  • added support for CSS4 Color module (rgb(40 74 200 / 90%), hsl(227deg 67% 47% / 90%))
  • improved regular expressions;
  • tree shaking;
  • slightly faster performance;
  • stronger and more strict types.

Install

npm install @thednp/color

Quick Usage

import Color from "@thednp/color";

// provide a web colour, the constructor will determine
const myHEXColor = new Color("red", "hex").toString();
// => { r: 250, g: 0, b: 0, a: 1, ok: true, originalInput: 'red', ...}

// use the value where you need it
Object.assign(myElement.style, { color: myHEXColor.toString() });
// => #ff0000

Wiki

For a more detailed guide please visit the wiki page at Color Wiki!

Thanks

  • Brian Grinstead for his original TinyColor
  • Scott Cooper for his awesome version of TinyColor

License

Color is released under the MIT License