@aplus-frontend/ui
Version:
10 lines (9 loc) • 373 B
JavaScript
function g(n, t = 1) {
if (n = n?.replace(/^#/, ""), n.length === 3 && (n = n.split("").map((r) => r + r).join("")), n.length !== 6)
throw new Error("Invalid hex color code");
const s = parseInt(n.substring(0, 2), 16), o = parseInt(n.substring(2, 4), 16), i = parseInt(n.substring(4, 6), 16);
return `rgba(${s}, ${o}, ${i}, ${t})`;
}
export {
g as hexToRgba
};