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

@chayns/colors

v2.0.0

Published

JavaScript utility functions for the calculation of colors for chayns

Downloads

2,260

Readme

@chayns/colors

JavaScript utility functions for the calculation of colors for chayns

Usage

Installation

This package can be installed from npm using npm install @chayns/colors.

Color Model Value Ranges

RGB (Red - Green - Blue)

HEX

  • Three (four with transparency) components of each two hexadecimal characters, starting with a #.
  • Example: #00ff3d (chayns blue)

RGB255

  • r, g, b: 0 - 255
  • a (transparency, optional): 0 - 1

RGB1

  • r, g, b: 0 - 1
  • a (transparency, optional): 0 - 1

HSL and HSV

HSL (Hue - Saturation - Lightness)

  • h: 0 - 360
  • s, l: 0 - 1
  • a (transparency, optional): 0 - 1

HSV (Hue - Saturation - Value)

  • h: 0 - 360
  • s, v: 0 - 1
  • a (transparency, optional): 0 - 1

Available Functions

This package provides general functions to convert colors from one color model into another as well as chayns-specific functions for generating chayns colors. All functions allow the usage of colors with a transparency. You just have to add a to your color (fourth hexadecimal pair for HEX color).

You can import the functions like this: import { isHex } from @chayns/colors;.

Color model conversion functions:

  • rgb1ToRgb255(rgb1)
  • rgb1ToHex(rgb1)
  • rgb1ToHsl(rgb1)
  • rgb1ToHsv(rgb1)
  • rgb255ToRgb1(rgb255)
  • rgb255ToHex(rgb255)
  • rgb255ToHsl(rgb255)
  • rgb255ToHsv(rgb255)
  • hexToRgb1(hex)
  • hexToRgb255(hex)
  • hexToHsl(hex)
  • hexToHsv(hex)
  • hslToRgb1(hsl)
  • hslToRgb255(hsl)
  • hslToHex(hsl)
  • hslToHsv(hsl)
  • hsvToRgb1(hsv)
  • hsvToRgb255(hsv)
  • hsvToHex(hsv)
  • hsvToHsl(hsv)

Functions for normalizing and generating color strings:

  • normalizeHexString(hex)
  • normalizeRgbString(rgbString)
  • getRgb255String(rgb255)

Mixing functions:

  • mixHsv(color1, color2, weight)
  • mixHsl(color1, color2, weight)
  • mixRgb(color1, color2, weight)
  • mixHex(color1, color2, weight)

Lightening/darkening functions:

  • lightenHslColor(color, percent)
  • lightenHexColor(color, percent)
  • lightenHsvColor(color, percent)
  • lightenRgb255Color(color, percent)
  • darkenHexColor(color, percent)
  • darkenHslColor(color, percent)
  • darkenHsvColor(color, percent)
  • darkenRgb255Color(color, percent)

Type check functions:

  • isHex(value)
  • isRgbString(value)
  • isRgb255(value)
  • isRgb1(value)
  • isHsl(value)
  • isHsv(value)

Chayns-specific functions

  • getColorFromPalette(colorId, options)
    • options is an object of color, colorMode and secondaryColor
  • getAvailableColorList()

Releases

Releasenotes will be send and published via GitHub. To subscribe them, you just have to watch this repository.

Development

  1. Clone git repository
  2. Install npm packages
  3. Link with npm start
  4. Run tests with npm test

Publishing

Increase version with npm version patch or npm version minor and push the commit and version tag. The npm package will be published via GitHub Actions.

Troubleshooting

If you get the error SyntaxError: Unexpected token {, you have to update your node version to at least Node 10.