import { cn } from '@/lib/utils';
/** A little skateboard-deck glyph for the rating. */
function Deck({ className }: { className?: string }) {
return (
);
}
interface DeckRatingProps {
/** Current rating, 0 = none, 1–10 = decks. */
value: number;
/** Omit for a read-only display. */
onChange?: (value: number) => void;
/** `sm` for inline rows, `md` for dialogs. */
size?: 'sm' | 'md';
/** When true, only render the filled decks (for display). */
compact?: boolean;
className?: string;
}
/**
* A 1–10 skateboard-deck rating. 1 deck = bad, 10 decks = best-in-class.
* Interactive by default; read-only when no `onChange` is given.
*/
export function DeckRating({ value, onChange, size = 'md', compact = false, className }: DeckRatingProps) {
const readOnly = !onChange;
const count = readOnly && compact ? Math.max(value, 0) : 10;
const deckCls = size === 'sm' ? 'h-3 w-6' : 'h-3.5 w-7';
return (
{Array.from({ length: count }).map((_, i) => {
const n = i + 1;
const filled = n <= value;
if (readOnly) {
return ;
}
return (
);
})}
{(value > 0 || !readOnly) && (
{value > 0 ? `${value}/10` : ''}
)}
);
}