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

postcss-color-adjustment

v0.1.6

Published

PostCSS color manipulations, functions, and analysis

Downloads

135

Readme

PostCSS Color Adjustment plugin

This PostCss plugin provides several utility actions used to manipulate, adjust, and analyse colors in you css files. Most actions call for a single color and an adjustment factor, but some call for two colors, while others forgo any adjustment factor property. The plugin was inspired by the color functions of Sass and the syntax from the awesome postcss-color-functions plugin.

Installation

npm install postcss-color-adjustment

Acceptable Color Formats

Functions that manipulate colors formats:

  • Hex, 3-digit shorthand Hex, 8-digit (RGBA) Hex
  • RGB, RGBA
  • HSL, HSLA
  • HSV, HSVA
  • Named colors

Basic Syntax

/*
 * rule: color(<base color>, <keyword>(<adjustment-factor>))
 **/

 background-color: color(#f00, darken(20));

Average Syntax

/*
 * rule: color(<base color>, average(<secondary color>))
 **/

 color: color(#2ef, average(#f24));

Mix Syntax

/*
 * rule: color(<base color>, mix(<secondary color>, <adjustment-factor>))
 **/

 border: 1px solid color(#f00 mix(#00f,40));

Chained Syntax (operations are performed from left to right)

/*
 * rule: color(<base color>, <keyword>(<adjustment-factor>) <keyword>(<adjustment-factor>) <keyword>(<adjustment-factor>) <.etc..> )
 **/

 box-shadow: 0 0 10px color(#bada55 saturate(20) darken(20));

note: do not separated chained color actions with a comma

Available actions

| Action & Alias| Parameters | Result | |--------|:----------------------:|-------------------------| | darken, shade, d | color, adjustment factor(0-100) | darkens color | | lighten, tint, l | color, adjustment factor(0-100) | lightens color | | brighten, b | color, adjustment factor(0-100) | brightens color | | desaturate d | color, adjustment factor(0-100) | desaturate color | | saturate, s | color, adjustment factor(0-100) | saturates color | | grayscale, greyscale, g | color | desaturate color 100% | | shift, hue, rotate, h | color, adjustment factor(-360 - 360) | shifts hue | | mix, blend, m | color1, color2, adjustment factor(0-100) | mixes 2 colors by adjustment factor | | average | color1, color2 | averages 2 colors | | complement | color | returns complimentary color | | randomColor | color | returns a random color | | transparentize, alpha, opacity, a | color, adjustment factor(0-1) | sets alpha level of color | | contrast | color, color2 | returns the color contrast, from 0-21 as defined by Web Content Accessibility Guidelines (Version 2.0). | | luminance | color | Returns the perceived luminance of a color, from 0-1 as defined by Web Content Accessibility Guidelines (Version 2.0). | | readable | color | Returns either "var(--colorLight)" or "var(--colorDark)" depending on which has the better contrast. These are returned as custom properties to give flexibility to the rendered color |

css

color: color(#f00 darken(20));           /* #990000  */
color: color(#f00 lighten(20));          /* #ff6666  */
color: color(#f00 brighten(20));         /* #ff3333  */
color: color(#f00 desaturate(20));       /* #e61919  */
color: color(#f00 saturate(20));         /* #ff0000  */
color: color(#f00 grayscale());            /* #808080  */
color: color(#f00 shift(120));           /* #00ff00  */
color: color(#f00 mix(#00f,40);          /* rgb(153, 0, 102)  */
color: color(#f00 average(#0f0));        /* rgb(128, 128, 0)  */
color: color(#f00 complement());         /* #00ffff  */
color: color(randomColor());             /* #886b76  */
color: color(#f00 transparentize(.2));   /* rgba(255, 0, 0, 0.2)  */
color: color(#f00 alpha(.8));            /* rgba(255, 0, 0, 0.8)  */
color: color(#f00 contrast(#000));       /* 5.252  */
color: color(#f00 luminance());          /* 0.2126 */
color: color(#ff0 readable());           /* var(--colorDark) */