source: trip-planner-front/node_modules/stylus/lib/functions/lightness.js@ eed0bf8

Last change on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 794 bytes
Line 
1var nodes = require('../nodes')
2 , hsla = require('./hsla')
3 , component = require('./component');
4
5/**
6 * Return the lightness component of the given `color`,
7 * or set the lightness component to the optional second `value` argument.
8 *
9 * Examples:
10 *
11 * lightness(#00c)
12 * // => 100%
13 *
14 * lightness(#00c, 80%)
15 * // => #99f
16 *
17 * @param {RGBA|HSLA} color
18 * @param {Unit} [value]
19 * @return {Unit|RGBA}
20 * @api public
21 */
22
23function lightness(color, value){
24 if (value) {
25 var hslaColor = color.hsla;
26 return hsla(
27 new nodes.Unit(hslaColor.h),
28 new nodes.Unit(hslaColor.s),
29 value,
30 new nodes.Unit(hslaColor.a)
31 )
32 }
33 return component(color, new nodes.String('lightness'));
34};
35lightness.params = ['color', 'value'];
36module.exports = lightness;
Note: See TracBrowser for help on using the repository browser.