laif-ds
Version:
Design System di Laif con componenti React basati su principi di Atomic Design
32 lines (31 loc) • 1.13 kB
JavaScript
"use client";
import { clsx as l } from "../node_modules/clsx/dist/clsx.js";
import { twMerge as m } from "../node_modules/tailwind-merge/dist/bundle-mjs.js";
function p(...e) {
return m(l(e));
}
const x = (e) => {
if (!e) return "#777777";
let t = 0;
for (let s = 0; s < e.length; s += 1)
t = e.charCodeAt(s) + ((t << 5) - t), t &= t;
let n = t >> 16 & 255, o = t >> 8 & 255, r = t & 255;
const a = 60, i = 200;
n = Math.min(i, Math.max(a, n)), o = Math.min(i, Math.max(a, o)), r = Math.min(i, Math.max(a, r));
const c = (s) => s.toString(16).padStart(2, "0");
return `#${c(n)}${c(o)}${c(r)}`;
}, u = (e, t) => {
let n = e.replace("#", "");
n.length === 3 && (n = n.split("").map((c) => c + c).join(""));
const o = parseInt(n, 16), r = o >> 16 & 255, a = o >> 8 & 255, i = o & 255;
return `rgba(${r}, ${a}, ${i}, ${t})`;
}, b = (e) => {
const t = parseInt(e.replace("#", ""), 16), n = t >> 16 & 255, o = t >> 8 & 255, r = t & 255;
return (0.299 * n + 0.587 * o + 0.114 * r) / 255 > 0.5 ? "#000000" : "#FFFFFF";
};
export {
p as cn,
b as hexContrast,
u as hexToRgba,
x as stringToHexColor
};