@catho/quantum
Version:
Catho react components
18 lines (17 loc) • 670 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var hexToRgba = function hexToRgba(hex) {
var opacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
var _h = hex.replace('#', '');
var _shortened = _h.length === 3;
var _step = _shortened ? 1 : 2;
var _bIndex = _shortened ? 2 : 4;
var _parse = function _parse(from) {
return parseInt(_h.slice(from, from + _step).repeat(_shortened ? 2 : 1), 16);
};
return "rgba(".concat(_parse(0), ",").concat(_parse(_step), ",").concat(_parse(_bIndex), ",").concat(opacity, ")");
};
var _default = exports["default"] = hexToRgba;