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

sass-colorscheme

v0.4.0

Published

Color scheme generator for plug-and-play use with Sass and SCSS stylesheets

Downloads

16

Readme

Sass color scheme generator

Color scheme generator for Sass. Based on http://colorschemedesigner.com/csd-3.5 and color-scheme, but unique in it's output and focus on ease of use.

Installation

Install package with NPM and add it to your development dependencies:

npm install --save-dev sass-colorscheme

Usage

Import the scss file from any other Sass file, and assign a variable to the function's output:

@import "node_modules/sass-colorscheme/colorscheme";
$seed-color: #ffd040;
$colorscheme: colorscheme($seed: $seed-color, $global: true, $scheme: 'mono');

h1 {
    color: $primary; // #ffd040
    background: $primary-lightest; // #ffefc0
    border: 1px solid $primary-darkest; // #c09000
}

Or, if variables are not global

@import "node_modules/sass-colorscheme/colorscheme";
$seed-color: #ffd040;
$colorscheme: colorscheme($seed: $seed-color, $global: false, $scheme: 'mono');

h1 {
    color: map-get($colorscheme, 'primary'); // #ffd040
    background: map-get($colorscheme, 'primary-lightest'); // #ffefc0
    border: 1px solid map-get($colorscheme, 'primary-darkest'); // #c09000
}

Note that the keys used with map-get are identical to the global variable names, except for the leading $.

Syntax

colorscheme($seed[, $global][, $scheme][, $distance][, $variation][, $complement])

Returns a map of colors (see Output)

$seed

Type: color

Color on which to base the color scheme. Can be any hex or named color value. To use RGB or HSL values, use the built-in rgb() or hsl() functions.

$global

Type: boolean Default: true (Optional)

Assign color scheme output to global variables. True results in variables that are set in the global namespace and can be accessed by any sass file that imports this script. False results in no additional global variables. To access the colors, you must use map-get($colorscheme, '$key').

$scheme

Type: string Default: mono (Optional)

The color scheme to generate. Accepted values are

  • mono A monochromatic color scheme
  • triad A color scheme with three main colors. The two secondary colors are adjacent to the complement of the $seed color
  • complementary A color scheme based on the seed and it's complement
  • tetrad A color scheme with four main colors. Two colors are the seed and the complement, plus one value adjacent to the seed and one value adjacent to the complement.
  • analogic A color scheme with three main colors. The two secondary colors are adjacent to the $seed color. Can optionally include the complement (see $complement, below).

$distance

Type: number Default: 0.3 Range: 0 - 1, inclusive (Optional)

The distance separating the secondary values from the seed and complement.
Notes:

  • Only valid for triad, tetrad, and analogic.
  • A larger number increases the amount of separation between colors, where 1 is maximum separation.
  • Used with tetrad, a distance of 1 will result in 4 evenly spaces hues around the color circle. That is, each hue will be offset from the other by 90 degrees. A distance of 0 will result in the same output as the complementary scheme.
  • For triad and analogic, A distance of 1 will result in the same scheme: the seed, plus two colors that are evenly spaced between the seed and it's complement.
  • For triad, a distance of 0 will result in the same scheme as complementary.
  • For analogic, a distance of 0 will result in the same scheme as mono.

$variation

Type: string Default: none (Optional)

Variations on the generated color scheme. Accepted values are

  • pastel: desaturates by 40% and lightens by 10%
  • dark: darkens colors by 15%
  • light: lightens colors by 15%
  • hard: saturates by 100%
  • pale: desaturates by 60%
  • none

$complement

Type: boolean Default: false (Optional)

Include the complement on the analogic color scheme. Has no effect when used with other schemes.

Output

The script generates a minimum of 5 colors (when $scheme == 'mono'), and a maximum of 20 colors (when $scheme == 'tetrad' or $scheme == 'analogic' and $complement == true). The base color variable names are

  • $primary
  • $secondary-a
  • $secondary-b
  • $complementary

The color variants are

  • {base}--lighter
  • {base}--lightest
  • {base}--darker
  • {base}--darkest

The output varies depending on the selected $scheme:

  • mono returns $primary and all variants
  • complementary returns $primary and $complementary and all variants
  • triad returns $primary, $secondary-a, and $secondary-b and all variants
  • tetrad returns all four base colors and all variants
  • analogic with $complement == false returns $primary, $secondary-a, and $secondary-b and all variants
  • analogic with $complement == true returns all four base colors and all variants

Generating example color schemes

The package has an example directory which is designed to make it easy to generate and preview various color schemes.

Creating previews

Both the example script and the start script will generate a preview using the default settings.

npm start
# or
npm run example

To pass a custom seed color to the example script, simply pass a command line argument to npm (note that the color must be quoted):

npm start -- '#ff0000'
# or
npm run example -- '#ff0000'

Alternatively, you can modify the default seed color in example/defaults.scss and simply run npm start with no arguments.