"use client"; /** * — two action buttons mounted above the movie list search bar. * * 🎲 Roll the Dice! — random winner from the unwatched pool * 🎭 Genre Roll! — opens the for a filtered roll * * Both buttons are disabled (and carry a visible tooltip) when the list is * still loading OR the unwatched pool is empty. The tooltip strings are * hardcoded — no user/movie data is ever interpolated into `title=`, which * keeps the attribute XSS-safe. * * Minimum tap target: 44×44 px (WCAG 2.1 AA). */ interface RollBarProps { isLoading: boolean; poolEmpty: boolean; onRoll: () => void; onGenreRoll: () => void; } function disabledReason(isLoading: boolean, poolEmpty: boolean): string | null { if (isLoading) return "Loading list\u2026"; if (poolEmpty) return "Nothing to roll"; return null; } export function RollBar({ isLoading, poolEmpty, onRoll, onGenreRoll }: RollBarProps) { const reason = disabledReason(isLoading, poolEmpty); const disabled = reason !== null; const randomTooltip = reason ?? "Roll the dice for a random pick"; const genreTooltip = reason ?? "Pick genres and moods, then roll"; const baseClasses = "inline-flex min-h-[44px] min-w-[44px] items-center justify-center gap-2 rounded-lg px-4 py-2 text-sm font-semibold transition-colors"; const enabledClasses = "bg-red-600 text-white hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-400"; const disabledClasses = "bg-gray-700 text-gray-400 cursor-not-allowed"; return (
); }