All files / src/components/player ChannelOverlay.tsx

0% Statements 0/52
0% Branches 0/1
0% Functions 0/1
0% Lines 0/52

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67                                                                                                                                     
import { useChannels } from "@/hooks/useChannels";
import { ScrollArea } from "@/components/ui/scroll-area";
import { X } from "lucide-react";
import { Button } from "@/components/ui/button";
import type { Channel } from "@/lib/types";
 
interface ChannelOverlayProps {
	onClose: () => void;
	onSelectChannel: (channel: Channel) => void;
}
 
export const ChannelOverlay = ({ onClose, onSelectChannel }: ChannelOverlayProps) => {
	const { channels } = useChannels();
 
	const handleSelect = (ch: Channel) => {
		onSelectChannel(ch);
		onClose();
	};
 
	return (
		<div className="absolute right-0 top-0 bottom-0 w-80 bg-black/90 backdrop-blur-sm border-l border-white/10 flex flex-col">
			<div className="flex items-center justify-between p-3 border-b border-white/10">
				<h3 className="text-sm font-semibold text-white">Channels</h3>
				<Button
					variant="ghost"
					size="icon"
					onClick={onClose}
					className="h-7 w-7 text-white hover:bg-white/20"
				>
					<X className="h-4 w-4" />
				</Button>
			</div>
			<ScrollArea className="flex-1">
				<div className="p-2">
					{channels.map((ch) => (
						<button
							key={ch.id}
							onClick={() => handleSelect(ch)}
							className="flex items-center gap-2 w-full p-2 rounded-md text-left text-white hover:bg-white/10 transition-colors focus:outline-none focus:ring-1 focus:ring-primary"
							tabIndex={0}
						>
							<div className="h-8 w-8 rounded bg-white/10 flex items-center justify-center overflow-hidden shrink-0">
								{ch.logoUrl ? (
									<img
										src={ch.logoUrl}
										alt=""
										className="h-full w-full object-contain"
										loading="lazy"
									/>
								) : (
									<span className="text-[10px] text-white/50">TV</span>
								)}
							</div>
							<div className="min-w-0 flex-1">
								<p className="text-xs font-medium truncate">{ch.name}</p>
								<p className="text-[10px] text-white/50 truncate">
									{ch.groupTitle}
								</p>
							</div>
						</button>
					))}
				</div>
			</ScrollArea>
		</div>
	);
};