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

@daybridge/color-system

v1.0.3

Published

Scripts and utilities for systematically generating color palettes informed by color science

Downloads

770

Readme

Daybridge Color System

Introduction

Daybridge uses the OKLCH color model. This model is a perceptually uniform color space, which means it takes into account how human vision perceives color. Compared to other color systems like RGB or HSL, OKLCH provides more consistent results when generating color variations, as the perceived difference between colors is consistent across the color space. This leads to more uniform and aesthetically pleasing color schemes.

This package helps with generating the L (luminance) and C (chroma) values for our color palettes. Once these are selected, it will be possible to choose an arbitrary value for the hue H. Thanks to the properties of OKLCH, all of the hues for a given shade will appear to be of uniform intensity.

We had the following requirements:

  • the L and C values generated for each shade must be compatible with all possible hues in the specified gamut. We don't want to generate any colors that screens can't properly render.
  • therefore, we needed to find the maximum chroma value that would work for all hues at a given luminance level.
  • the shades we generate need to be closer to each other at luminance values closer to 0% and 100%. When building UI, we need more shades at the extreme ends to create depth and layering.
  • The lumimance values need to be symmetrical, so that we can create similar UIs in light mode and dark mode.

Installation

Install the package globally to use it as a CLI:

npm install -g @daybridge/color-system

Or install it as a dependency in your project to use it programmatically:

npm install --save @daybridge/color-system

Usage

Command-Line Interface

You can use the tool from the command line as follows:

daybridge-colors --shades 10 --gamut p3 --squashFactorDark 1.5 --squashFactorLight 1.3 --lightnessRange 20,100

The options are as follows:

  • --shades: The number of shades to generate.
  • --gamut: The color gamut. Options are 'srgb' and 'p3'. Default is 'p3'.
  • --squashFactorDark: The squash factor used to adjust the lightness values for the darker shades. Higher squash factors lead to more "bunching" at each end. Default is 1.
  • --squashFactorLight: The squash factor used to adjust the lightness values for the lighter shades. Higher squash factors lead to more "bunching" at each end. Default is 1.
  • --lightnessRange: The range of lightness values to generate, specified as a comma-separated string with format 'min,max'. Default is '20,100'.

Programmatic Usage

You can also use the generateShades function in your code:

const { generateShades } = require('@daybridge/color-system');

let shades = generateShades(5, 'srgb', 1, 1, [20, 100]);

The generateShades function takes three parameters:

  • N: The number of shades to generate.
  • gamut: The color gamut. Options are 'srgb' and 'p3'. Default is 'p3'.
  • squashFactorDark: The squash factor used to adjust the lightness values for the darker shades. Default is 1.
  • squashFactorLight: The squash factor used to adjust the lightness values for the lighter shades. Default is 1.
  • lightnessRange: The range of lightness values to generate, specified as an array of two numbers: [min, max]. Default is [20, 100].

It returns an array of shades with each shade represented as a pair [lightness, chroma].

Contributing

Contributions are welcome. Please submit a pull request or create an issue for any bugs or feature requests.