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 | 32x 10x 22x 8x 3x | import { FolderPlus, Plus } from 'lucide-react'
import type { Collection } from '../api/client'
import { cn } from '../lib/utils'
interface CollectionListProps {
collections: Collection[]
loading: boolean
addingTo: number | null
onAdd: (collectionId: number) => void
onCreateNew: () => void
}
export default function CollectionList({
collections,
loading,
addingTo,
onAdd,
onCreateNew,
}: CollectionListProps) {
if (loading) {
return (
<div className="px-2 py-4 text-center text-sm text-muted-foreground">
Loading...
</div>
)
}
return (
<>
{collections.length > 0 ? (
<div className="max-h-48 overflow-y-auto">
{collections.map((collection) => (
<button
key={collection.id}
onClick={() => onAdd(collection.id)}
disabled={addingTo === collection.id}
className={cn(
'flex w-full items-center gap-2 rounded-md px-2 py-2 text-left text-sm transition-colors',
'text-foreground hover:bg-muted disabled:opacity-50'
)}
>
<FolderPlus className="h-4 w-4 text-muted-foreground" />
<span className="flex-1 truncate">{collection.name}</span>
{addingTo === collection.id && (
<span className="text-xs text-muted-foreground">Adding...</span>
)}
</button>
))}
</div>
) : (
<div className="px-2 py-2 text-sm text-muted-foreground">
No collections yet
</div>
)}
<div className="mt-1 border-t border-border pt-1">
<button
onClick={onCreateNew}
className="flex w-full items-center gap-2 rounded-md px-2 py-2 text-left text-sm text-primary transition-colors hover:bg-muted"
>
<Plus className="h-4 w-4" />
Create New Collection
</button>
</div>
</>
)
}
|