All files / src/components/channels CategoryBrowser.tsx

100% Statements 48/48
100% Branches 4/4
66.66% Functions 2/3
100% Lines 48/48

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 68 691x                               1x 2x 2x 2x 2x 2x 2x 2x 2x 2x   2x 2x   2x 2x 2x 2x 2x 2x 2x 2x   2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x   2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x    
import { ChevronRight, FolderOpen, Tv2 } from "lucide-react";
 
interface SuperCategoryInfo {
	name: string;
	groupCount: number;
	channelCount: number;
}
 
interface CategoryBrowserProps {
	superCategories: SuperCategoryInfo[];
	topLevelGroups: { name: string; channelCount: number }[];
	onSelectCategory: (name: string) => void;
	onSelectGroup: (name: string) => void;
	onManage: () => void;
}
 
export const CategoryBrowser = ({
	superCategories,
	topLevelGroups,
	onSelectCategory,
	onSelectGroup,
	onManage,
}: CategoryBrowserProps) => (
	<div className="px-3 pt-2 pb-1">
		<div className="flex items-center justify-between mb-2">
			<span className="text-xs font-semibold text-muted-foreground uppercase tracking-wider">
				Categories
			</span>
			<button onClick={onManage} className="text-xs text-primary hover:underline">
				Manage
			</button>
		</div>
		<div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-2">
			{superCategories.map((cat) => (
				<button
					key={cat.name}
					onClick={() => onSelectCategory(cat.name)}
					className="flex flex-col items-start gap-1.5 p-3 rounded-xl bg-secondary/80 border border-border/50 hover:bg-accent hover:border-primary/30 transition-all text-left group"
				>
					<div className="flex items-center justify-between w-full">
						<FolderOpen className="h-4 w-4 text-primary/70" />
						<ChevronRight className="h-3.5 w-3.5 text-muted-foreground/50 group-hover:text-primary transition-colors" />
					</div>
					<div className="text-sm font-medium leading-tight">{cat.name}</div>
					<div className="text-[10px] text-muted-foreground">
						{cat.groupCount} groups &middot; {cat.channelCount.toLocaleString()} ch
					</div>
				</button>
			))}
			{topLevelGroups.map((group) => (
				<button
					key={group.name}
					onClick={() => onSelectGroup(group.name)}
					className="flex flex-col items-start gap-1.5 p-3 rounded-xl bg-secondary/80 border border-border/50 hover:bg-accent hover:border-primary/30 transition-all text-left group"
				>
					<div className="flex items-center justify-between w-full">
						<Tv2 className="h-4 w-4 text-muted-foreground/70" />
						<ChevronRight className="h-3.5 w-3.5 text-muted-foreground/50 group-hover:text-primary transition-colors" />
					</div>
					<div className="text-sm font-medium leading-tight">{group.name}</div>
					<div className="text-[10px] text-muted-foreground">
						{group.channelCount.toLocaleString()} channels
					</div>
				</button>
			))}
		</div>
	</div>
);