UNPKG

@magicbell/magicbell-react

Version:

React components for building a notification inbox for your app

30 lines 1.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.toRGBA = toRGBA; exports.darken = darken; const tslib_1 = require("tslib"); const tinycolor2_1 = tslib_1.__importDefault(require("tinycolor2")); /** * Function that takes a valid CSS color and adds some opacity to it. * * @param baseColor Color in HSL, HSV, HEX or RGB * @param alpha Alpha for this color */ function toRGBA(baseColor, alpha) { // tinycolor doesn't support css variables, so assume the variable is correct as is if (baseColor.startsWith('var(')) return baseColor; const color = (0, tinycolor2_1.default)(baseColor); color.setAlpha(alpha); return color.toRgbString(); } /** * Function that takes a valid CSS color and mixes it with black. * * @param baseColor Color in HSL, HSV, HEX or RGB * @param amount Amount of black to mix with the base color. */ function darken(baseColor, amount) { return tinycolor2_1.default.mix(baseColor, 'black', amount || 50).toRgbString(); } //# sourceMappingURL=color.js.map