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

color-variations

v0.0.8

Published

Create color variations for your theme with no pain

Downloads

20

Readme

color-variations

Travis npm package Coveralls

Create color variations for your theme with no pain.

Based on polished color transformation functions.

Edit qv9xy5xokw

Getting started

es6

import colorVariations from 'color-variations';

const baseColors = {
  black: '#000',
  white: '#fff',
  red: '#ff0000',
  blue: 'rgb(0, 102, 204)',
  green: 'rgba(101, 218, 162, 0.9)',
  foo: {
    green: 'rgba(101, 218, 162, 0.9)',
  },
  bar: ['rgba(101, 218, 162, 0.9)'],
};

const colors = colorVariations(baseColors);

console.log(colors.blackLighten[3]); // '#4d4d4d'
console.log(colors.redTint[3]); // '#ff4c4c'
console.log(colors.greenSaturate[3]); // 'rgba(72,247,163,0.9)'
console.log(colors.foo.greenSaturate[3]); // 'rgba(72,247,163,0.9)'
console.log(colors.bar.c0Saturate[3]); // 'rgba(72,247,163,0.9)'
console.log(colors.bar.0); // 'rgba(101, 218, 162, 0.9)'

node

const colorVariations = require('color-variations');

//... The same as above

umd

<!-- Inject this script in your HTML -->
<script src="https://unpkg.com/color-variations/dist/index.umd.js"></script>

The variable exported is called colorVariations.

Installing

yarn add color-variations

or

npm install color-variations

Options

steps

Defines the number of variations (apart from 0) generated.

For 10 steps the scale will be [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1].

For 5 steps [0, 0.2, 0.4, 0.6, 0.8, 1].

Pass the options as an object for the second argument of colorVariations.

includedFns

The color functions included. By default: ['darken', 'lighten', 'saturate', 'desaturate', 'rgba', 'shade', 'tint'].

This options is useful is you want to include only a few variations functions.

excludedFns

The color functions excluded. By default: []

const baseColors = {
  black: '#000',
  red: '#ff0000',
  // ...
};

const opts = {
  steps: 5,
  includedFns: ['darken', 'lighten', 'rgba'],
};

const colors = colorVariations(baseColors, opts);

Todo

  • [x] Proper documentation
  • [x] Human testing
  • [x] Improve options (include only functions provided, exclude functions provided...)
  • [x] Support for complex structures (objects of arrays of objects of...)
  • [ ] Move away from polished
  • [ ] Deal with collisions (having a color with name equals to a generated variation)
  • [ ] Exclude useless color variations like darken for black (with option)
  • [ ] Options (path) for included/excluded colors for variations
  • [ ] Custom variations