import { colors } from '../components/ui'; import defaultColors from 'tailwindcss/colors'; export const getColor = (colorValue: any) => { if (colorValue.startsWith('#') || colorValue.startsWith('rgb')) { return colorValue; } const paths = colorValue.split('-'); if (paths.length > 2) { let result = colors; for (const path of paths) { // @ts-ignore result = result[path]; if (!result) break; } if (result) return result; } const [category, shade] = colorValue.split('-'); // @ts-ignore if (colors[category] && colors[category][shade]) { // @ts-ignore return colors[category][shade]; } // @ts-ignore if (defaultColors[category]?.[shade]) { // @ts-ignore return defaultColors[category][shade]; } // @ts-ignore if (colors[colorValue]) { // @ts-ignore return colors[colorValue]; } return colorValue; }