File size: 1,234 Bytes
e3d26ad
1185ec1
e3d26ad
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { cn } from "@/lib/utils"
import { CollectionInfo } from "@/types/general"

import { CollectionCard } from "../collection-card"

export function CollectionList({
  collections = [],
  layout = "grid",
  className = "",
  onSelect,
}: {
  collections: CollectionInfo[]

  /**
   * Layout mode
   * 
   * This isn't necessarily based on screen size, it can also be:
   * - based on the device type (eg. a smart TV)
   * - a design choice for a particular page
   */
  layout?: "grid" | "horizontal" | "vertical"

  className?: string

  onSelect?: (collection: CollectionInfo) => void
}) {
  
  return (
    <div
      className={cn(
        layout === "grid"
          ? `grid grid-cols-1 gap-4 sm:grid-cols-2 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4`
        : layout === "vertical"
          ? `grid grid-cols-1 gap-2`
          : `flex flex-col md:flex-row space-y-4 md:space-y-0 md:space-x-4`,
        className,
      )}
    >
    {collections.map((collection, i) => (
      <CollectionCard
        key={collection.id}
        collection={collection}
        className="w-full"
        layout={layout === "vertical" ? "compact" : "normal"}
        onSelect={onSelect}
        index={i}
      />
    ))}
    </div>
  )
}