export const hexToRgba = (h: string, opacity: number = 1, percent = 1) => { let r = 0, g = 0, b = 0; // 3 digits if (h.length === 4) { r = parseInt('0x' + h[1] + h[1]) * percent; g = parseInt('0x' + h[2] + h[2]) * percent; b = parseInt('0x' + h[3] + h[3]) * percent; // 6 digits } else if (h.length === 7) { r = parseInt('0x' + h[1] + h[2]) * percent; g = parseInt('0x' + h[3] + h[4]) * percent; b = parseInt('0x' + h[5] + h[6]) * percent; } return `rgba(${r},${g},${b},${opacity})`; };