// hex -> rgba function computeRgb(hex: string): string[] { if (!hex || !hex.startsWith('#')) return; const hexValue = hex.substring(1); let rgb = []; if (hexValue.length === 3) { rgb = hexValue.split('').map(item => parseInt(`0x${item + item}`, 16)); } if (hexValue.length === 6) { rgb = [0, 2, 4].map(item => parseInt(`0x${hexValue.slice(item, item + 2)}`, 16)); } return rgb; } function hexToRgba(hex: string, opacity: number) { const rgb = computeRgb(hex); if (!rgb) return; return `rgb(${rgb.join(',')}, ${opacity})`; } function hexToRgb(hex: string) { const rgb = computeRgb(hex); if (!rgb) return; return `rgb(${rgb.join(',')})`; } const BaseToken = { COLOR: { GRAY_3: '#E7E7E7', GRAY_5: '#C5C5C5', FONTGRAY_3: '#E7E7E7', GRAY_OPACITY_5: 'rgba(0, 0, 0, 0.05)', FONTGRAY_1: 'rgba(0, 0, 0, 0.9)', FONTGRAY_2: 'rgba(0, 0, 0, 0.6)', }, }; export { hexToRgba, hexToRgb, BaseToken };