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

adaptive-colors

v0.0.5

Published

adaptive color palettes

Downloads

8

Readme

adaptive colors

adaptive color palettes

built upon Adobe's Leonardo

motivation

"why do this when Adobe's already got Leonardo?"

tl;dr

  • as of writing this, the latest working version of @adobe/leonardo-contrast-colors is 1.0.0-alpha.13 (it's currently on 1.0.0-alpha.17)
  • it doesn't support oklab/oklch
  • why not send in a pr then? well, sorry Leonardo maintainers, but that code was an absolute horror to read through

adobe's official package for adaptive color palettes is broken, missing support for oklab/oklch, and the code is miserable to work with.

i want to create adaptive color palettes that target oklch. i do not want to work within the constraints of their code, and wait all that time for a pr to be accepted (and for the package to get unborked).

rewriting the whole thing lets me create an api that i prefer, and allows for clearer expression of data flow and transformation.

installation

this package requires Node >=20.0.0. for the most up to date information, see package.json :: engines.node.

npm i adaptive-colors

usage

this section's code examples are adapted from Adobe Leonardo's readme

import { Color, Theme } from "adaptive-colors";

const grey = new Color({
    name: 'grey',
    key_colors: ['#cacaca'],
    ratios: [2, 3, 4.5, 8]
});

const blue = new Color({
    name: 'blue',
    key_colors: ['#5CDBFF', '#0000FF'],
    ratios: [3, 4.5]
});

const red = new Color({
    name: 'red',
    key_colors: ['#FF9A81', '#FF0000'],
    ratios: [3, 4.5]
});

const theme = new Theme({
    colors: [gray, blue, red],
    background_color: gray,
});

/*
colors  - theme colors as json
pairs   - theme colors as flat key:value map
values  - theme colors as list
*/
const { colors, pairs, values } = theme.palette()

interpolation color spaces

colors can be interpolated along a variety of possible color spaces

| color space | description | | ----------- | ------------------------------------------ | | 'rgb' | rgb color space | | 'hsl' | hsl representation in rgb color space | | 'hsv' | hsv representation in rgb color space | | 'hsluv' | hsluv color space | | 'lab' | cielab color space | | 'lch' | polar representation in cielab color space | | 'oklab' | oklab color space | | 'oklch' | polar representation in oklab color space | | 'cam02' | ciecam02-ucs color appearance model | | 'cam02p' | ciecam02 color appearance model | | 'cam16' | ciecam16-ucs color appearance model | | 'cam16p' | ciecam16 color appearance model | | 'hct' | hct color space |

output formats

this section is adapted from but taken nearly verbatim from Adobe Leonardo's readme

available output formats conform to the W3C CSS Color Module Level 4 spec for the supported options, as listed below:

| output option | sample value | | ------------------- | ------------------------ | | 'hex' | #RRGGBB | | 'rgb' (default) | rgb(255, 255, 255) | | 'hsl' | hsl(360deg, 0%, 100%) | | 'lab' | lab(100%, 0, 0) | | 'lch' | lch(100%, 0, 360deg) | | 'oklab' | oklab(100%, 0, 0) | | 'oklch' | oklch(100%, 0, 360deg) |