Code Monkey home page Code Monkey logo

sass-color-shade-generator's Introduction

sass-color-shade-generator

A function to generate shades of a color in Sass.

Installation

Install the package using npm/yarn/whatever:

npm install sass-color-shade-generator

Usage

Import the function into any Sass file:

@import "../node_modules/sass-color-shade-generator/generateShades";

Note: You may need to adjust the relative path accordingly depending on where your partial is located relative to your project root.

And use it like so:

generate-shades($color: hsl(0, 0%, 100%), $n: 10, $type: "darker");

This returns a list of 10 colors, each 10% darker than the provided color:

hsl(0deg 0% 90%)
hsl(0deg 0% 80%)
hsl(0deg 0% 70%)
hsl(0deg 0% 60%)
hsl(0deg 0% 50%)
hsl(0deg 0% 40%)
hsl(0deg 0% 30%)
hsl(0deg 0% 20%)
hsl(0deg 0% 10%)
hsl(0deg 0% 0%)

Note: Duplicates will NOT be removed. So if you want to generate n darker shades of black, you're going to get 10 copies of black. Similarly, for colors that are already quite dark, you may get some colors repeated at the tail end. Same goes for lighter shades.

API

generate-shades

Argument Type Description Required
color Color The color from which to generate shades. Any valid color format is accepted. Yes
n Number The number of shades to generate. Must be a positive integer. No (default: 1)
type "darker" or "lighter" Whether to generate darker or lighter shades of the color. No (default: "darker")

Returns: a List of colors.

sass-color-shade-generator's People

Contributors

aleksandrhovhannisyan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.