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 * Tints a color by mixing it with white. `tint` can produce
10 * hue shifts, where as `lighten` 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: tint(0.25, '#00f')
17 * }
18 *
19 * // styled-components usage
20 * const div = styled.div`
21 * background: ${tint(0.25, '#00f')};
22 * `
23 *
24 * // CSS in JS Output
25 *
26 * element {
27 * background: "#bfbfff";
28 * }
29 */
30function tint(percentage, color) {
31 if (color === 'transparent') return color;
32 return (0, _mix["default"])(parseFloat(percentage), 'rgb(255, 255, 255)', color);
33}
34
35// prettier-ignore
36var curriedTint = (0, _curry["default"] /* ::<number | string, string, string> */)(tint);
37var _default = exports["default"] = curriedTint;
38module.exports = exports.default;
\No newline at end of file