New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

shade-generator

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shade-generator

Generate tints and shades easily.

latest
Source
npmnpm
Version
1.2.7
Version published
Weekly downloads
5K
82.56%
Maintainers
1
Weekly downloads
 
Created
Source

shade-generator

This will output a Record<Shade, string>.

const colorMap = ShadeGenerator.hue("#ff0000").shadesMap("hex");

You can use it like so.

const StyledComponent = styled.div`
  background-color: ${color['300']};
  margin: 8px;
  padding: 16px;
  border-radius: 8px;
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
`;

This also works.

const color = ShadeGenerator.hue("#ff0000").shade("10").hex();

Pass a config to fine tune the output

const config: Record<Shade, number> = {
  "10": 0.9,
  "20": 0.8,
  "30": 0.7,
  "40": 0.6,
  "50": 0.5,
  "60": 0.4,
  "70": 0.3,
  "80": 0.2,
  "90": 0.1,
  "100": 0,
  "200": 0.9,
  "300": 0.8,
  "400": 0.7,
  "500": 0.6,
  "600": 0.5,
  "700": 0.4,
  "800": 0.3,
  "900": 0.2,
  "1000": 0.1,
};

// You can, for example, change shade 50 to be "50": 0.55

const color = ShadeGenerator.hue("#ff0000").config(config).shade("10").hex();

const colorMap = ShadeGenerator.hue("#ff0000").config(config).shadesMap("hex");

Checkout other formats

...shadesMap("rgba");
...shadesMap("hsl");
...shadesMap("hex");

...rgba();
...hsl();
...hex();

See it in action here.

Enjoy ♥️

Keywords

color

FAQs

Package last updated on 27 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts