Sha256: 92739dac122feaaf031c914e0ceb1ebd76b8c9785bc8e7b712e934438fa7ac7c

Contents?: true

Size: 744 Bytes

Versions: 39

Compression:

Stored size: 744 Bytes

Contents

var nodes = require('../nodes')
  , hsla = require('./hsla')
  , component = require('./component');

/**
 * Return the lightness component of the given `color`,
 * or set the lightness component to the optional second `value` argument.
 *
 * Examples:
 *
 *    lightness(#00c)
 *    // => 100%
 *
 *    lightness(#00c, 80%)
 *    // => #99f
 *
 * @param {RGBA|HSLA} color
 * @param {Unit} [value]
 * @return {Unit|RGBA}
 * @api public
 */

module.exports = function lightness(color, value){
  if (value) {
    var hslaColor = color.hsla;
    return hsla(
      new nodes.Unit(hslaColor.h),
      new nodes.Unit(hslaColor.s),
      value,
      new nodes.Unit(hslaColor.a)
    )
  }
  return component(color, new nodes.String('lightness'));
};

Version data entries

39 entries across 20 versions & 2 rubygems

Version Path
ela-4.1.6 node_modules/stylus/lib/functions/lightness.js
ela-4.1.6 node_modules/nib/node_modules/stylus/lib/functions/lightness.js
ela-4.1.5 node_modules/stylus/lib/functions/lightness.js
ela-4.1.5 node_modules/nib/node_modules/stylus/lib/functions/lightness.js
ela-4.1.4 node_modules/nib/node_modules/stylus/lib/functions/lightness.js
ela-4.1.4 node_modules/stylus/lib/functions/lightness.js
ela-4.1.3 node_modules/stylus/lib/functions/lightness.js
ela-4.1.3 node_modules/nib/node_modules/stylus/lib/functions/lightness.js
ela-4.1.2 node_modules/stylus/lib/functions/lightness.js
ela-4.1.2 node_modules/nib/node_modules/stylus/lib/functions/lightness.js
ela-4.1.1 node_modules/stylus/lib/functions/lightness.js
ela-4.1.1 node_modules/nib/node_modules/stylus/lib/functions/lightness.js
ela-4.1.0 node_modules/stylus/lib/functions/lightness.js
ela-4.1.0 node_modules/nib/node_modules/stylus/lib/functions/lightness.js
ela-4.0.0 node_modules/stylus/lib/functions/lightness.js
ela-4.0.0 node_modules/nib/node_modules/stylus/lib/functions/lightness.js
ela-3.4.3 node_modules/stylus/lib/functions/lightness.js
ela-3.4.3 node_modules/nib/node_modules/stylus/lib/functions/lightness.js
ela-3.4.2 node_modules/nib/node_modules/stylus/lib/functions/lightness.js
ela-3.4.2 node_modules/stylus/lib/functions/lightness.js