Download apps/web/src/components/admin-selection-bar.tsx from ineeds/now: direct link, hf CLI and curl.
- Browser
- Download file 1.48 kB
-
https://huggingface.co/spaces/ineeds/now/resolve/main/apps/web/src/components/admin-selection-bar.tsx
- Command line
-
hf download hf://spaces/ineeds/now/apps/web/src/components/admin-selection-bar.tsx
-
curl -L -o admin-selection-bar.tsx https://huggingface.co/spaces/ineeds/now/resolve/main/apps/web/src/components/admin-selection-bar.tsx
1.48 kB
| import { useEffect, useRef } from "react"; | |
| import { Button } from "@/components/ui/button"; | |
| import { Trash2 } from "lucide-react"; | |
| export function SelectionBar({ | |
| count, | |
| allSelected, | |
| someSelected, | |
| onToggleAll, | |
| onDelete, | |
| deleting, | |
| label, | |
| }: { | |
| count: number; | |
| allSelected: boolean; | |
| someSelected: boolean; | |
| onToggleAll: () => void; | |
| onDelete: () => void; | |
| deleting: boolean; | |
| label: string; | |
| }) { | |
| const ref = useRef<HTMLInputElement>(null); | |
| useEffect(() => { | |
| if (ref.current) ref.current.indeterminate = !allSelected && someSelected; | |
| }, [allSelected, someSelected]); | |
| return ( | |
| <div className="flex flex-wrap items-center justify-between gap-3 rounded-xl border bg-card px-4 py-2.5"> | |
| <label className="flex cursor-pointer items-center gap-2 text-sm font-medium select-none"> | |
| <input | |
| ref={ref} | |
| type="checkbox" | |
| checked={allSelected} | |
| onChange={onToggleAll} | |
| className="h-4 w-4 rounded accent-primary" | |
| /> | |
| Select all | |
| </label> | |
| {count > 0 && ( | |
| <div className="flex items-center gap-3"> | |
| <span className="text-xs text-muted-foreground"> | |
| {count} selected | |
| </span> | |
| <Button variant="destructive" size="sm" onClick={onDelete} disabled={deleting}> | |
| <Trash2 className="h-4 w-4" /> | |
| {deleting ? "Deleting..." : `Delete selected (${count})`} | |
| </Button> | |
| </div> | |
| )} | |
| </div> | |
| ); | |
| } | |