'use client'; import { useState, useMemo } from 'react'; import { ColorSwatch } from '@/components/color/ColorSwatch'; import { Input } from '@/components/ui/input'; import { Select } from '@/components/ui/select'; import { useNamedColors } from '@/lib/api/queries'; import { Loader2 } from 'lucide-react'; export default function NamedColorsPage() { const [search, setSearch] = useState(''); const [sortBy, setSortBy] = useState<'name' | 'hue'>('name'); const { data, isLoading, isError } = useNamedColors(); const filteredColors = useMemo(() => { if (!data) return []; let colors = data.colors.filter( (color) => color.name.toLowerCase().includes(search.toLowerCase()) || color.hex.toLowerCase().includes(search.toLowerCase()) ); if (sortBy === 'name') { colors.sort((a, b) => a.name.localeCompare(b.name)); } // For hue sorting, we'd need to convert to HSL which requires the API // For now, just keep alphabetical as default return colors; }, [data, search, sortBy]); return (

Named Colors

Explore 148 CSS/X11 named colors

{/* Search and Filters */}
setSearch(e.target.value)} />
{/* Colors Grid */}
{isLoading && (
)} {isError && (
Failed to load named colors
)} {filteredColors.length > 0 && ( <>
Showing {filteredColors.length} colors
{filteredColors.map((color) => (
{color.name}
{color.hex}
))}
)} {filteredColors.length === 0 && !isLoading && !isError && (
No colors match your search
)}
); }