import React, { useMemo } from 'react' import { TAILWIND_COLORS } from '../utils/colors' interface TailwindColorsProps { onColorSelect: (color: string) => void selectedColor?: string } export function TailwindColors({ onColorSelect, selectedColor }: TailwindColorsProps) { // Order colors in specified sequence const orderedColors = useMemo(() => [ 'red', 'orange', 'amber', 'yellow', 'lime', 'green', 'emerald', 'teal', 'cyan', 'sky', 'blue', 'indigo', 'violet', 'purple', 'fuchsia', 'pink', 'rose', 'slate', 'gray', 'zinc', 'neutral', 'stone', ] as const, []) const shades = useMemo(() => ['50', '100', '200', '300', '400', '500', '600', '700', '800', '900', '950'] as const, []) // Function to determine text color based on background luminance const getTextColor = (hex: string) => { const rgb = hex.match(/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i) if (!rgb) return 'text-black' const [_, r, g, b] = rgb.map(x => parseInt(x, 16)) const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255 return luminance > 0.5 ? 'text-black' : 'text-white' } return (
Tailwind Color Reference
{/* Color rows */} {orderedColors.map(colorName => (
{colorName}
{shades.map(shade => { const values = TAILWIND_COLORS[colorName][shade] const hexColor = typeof values === 'string' ? values : values.hex const textColorClass = getTextColor(hexColor) return ( ) })}
))}
) }