UNPKG

1.12 kBJavaScriptView Raw
1"use strict";
2
3exports.__esModule = true;
4exports["default"] = void 0;
5var _curry = _interopRequireDefault(require("../internalHelpers/_curry"));
6var _mix = _interopRequireDefault(require("./mix"));
7function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
8/**
9 * Shades a color by mixing it with black. `shade` can produce
10 * hue shifts, where as `darken` manipulates the luminance channel and therefore
11 * doesn't produce hue shifts.
12 *
13 * @example
14 * // Styles as object usage
15 * const styles = {
16 * background: shade(0.25, '#00f')
17 * }
18 *
19 * // styled-components usage
20 * const div = styled.div`
21 * background: ${shade(0.25, '#00f')};
22 * `
23 *
24 * // CSS in JS Output
25 *
26 * element {
27 * background: "#00003f";
28 * }
29 */
30function shade(percentage, color) {
31 if (color === 'transparent') return color;
32 return (0, _mix["default"])(parseFloat(percentage), 'rgb(0, 0, 0)', color);
33}
34
35// prettier-ignore
36var curriedShade = (0, _curry["default"] /* ::<number | string, string, string> */)(shade);
37var _default = exports["default"] = curriedShade;
38module.exports = exports.default;
\No newline at end of file