Skip to content

Latest commit

 

History

History
32 lines (24 loc) · 650 Bytes

04.using-npm-modules.md

File metadata and controls

32 lines (24 loc) · 650 Bytes

Using npm modules

For more complex color/style transformation logic, it's always god to use it from a separate npm module (or) create one.

Reference:

Example:

For darkening scales in CSS you can use chroma-js module

import chroma from 'chroma-js'

const alpha = (color) => (a) => chroma(color).alpha(a).css();

const darken = alpha('#000');

const shade = [
  darken(0),
  darken(1 / 8),
  darken(1 / 4)
  // More...
];

const blueAlpha = [
  alpha(blue)(0),
  alpha(blue)(1 / 4),
  alpha(blue)(1 / 2),
  alpha(blue)(3 / 4),
  alpha(blue)(1)
];