react-life-design
Version:
Life Design UI components
47 lines • 2.21 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
var Colors_1 = require("../Colors");
exports.styledByMediaQuery = function (style, breakpoint) {
if (breakpoint === void 0) { breakpoint = '768px'; }
return "\n @media screen and (min-width: " + breakpoint + ") {\n " + style + ";\n }\n";
};
exports.hexToRgb = function (hex) { return function (opacity) {
if (!hex) {
return;
}
if (hex.substring(0, 1) === '#') {
hex = hex.substring(1);
}
var rgb = parseInt(hex.substring(0, 2), 16) + ", " + parseInt(hex.substring(2, 4), 16) + ", " + parseInt(hex.substring(4), 16);
if (typeof opacity === 'string' || typeof opacity === 'number') {
return "rgba(" + rgb + ", " + opacity + ")";
}
return "rgb(" + rgb + ")";
}; };
var addLight = function (color, amount) {
if (color === void 0) { color = Colors_1.default.cerulean; }
var cc = parseInt(color, 16) + amount;
var c = (cc > 255) ? 255 : (cc);
c = (c.toString(16).length > 1) ? c.toString(16) : "0" + c.toString(16);
return c;
};
exports.lighten = function (color, amount) {
if (color === void 0) { color = Colors_1.default.cerulean; }
color = (color.indexOf('#') >= 0) ? color.substring(1, color.length) : color;
amount = parseInt((255 * amount) / 100, 10);
return color = "#" + addLight(color.substring(0, 2), amount) + addLight(color.substring(2, 4), amount) + addLight(color.substring(4, 6), amount);
};
var subtractLight = function (color, amount) {
if (color === void 0) { color = Colors_1.default.cerulean; }
var cc = parseInt(color, 16) - amount;
var c = (cc < 0) ? 0 : (cc);
c = (c.toString(16).length > 1) ? c.toString(16) : "0" + c.toString(16);
return c;
};
exports.darken = function (color, amount) {
if (color === void 0) { color = Colors_1.default.cerulean; }
color = (color.indexOf('#') >= 0) ? color.substring(1, color.length) : color;
amount = parseInt((255 * amount) / 100, 10);
return color = "#" + subtractLight(color.substring(0, 2), amount) + subtractLight(color.substring(2, 4), amount) + subtractLight(color.substring(4, 6), amount);
};
//# sourceMappingURL=styles.js.map
;