|
| 1 | +'use client' |
| 2 | + |
| 3 | +import * as React from 'react' |
| 4 | + |
| 5 | +import { IconChevronLgRight } from '@intentui/icons' |
| 6 | +import { CubeIcon, FolderIcon } from '@phosphor-icons/react' |
| 7 | + |
| 8 | +import { BadgeOrange } from '../../../src/react/icons/badge-orange' |
| 9 | +import { DotsCard } from '../../../src/react/icons/dots-card' |
| 10 | +import { cn } from '../../../src/react/utils/cn' |
| 11 | + |
| 12 | +function CollectionCard({ className, ...props }: React.ComponentProps<'div'>) { |
| 13 | + return ( |
| 14 | + <div |
| 15 | + data-slot="collection-card" |
| 16 | + className={cn( |
| 17 | + 'bg-white rounded-2xl shadow-sm p-2 w-full border border-bluegray-300 relative flex flex-col', |
| 18 | + className |
| 19 | + )} |
| 20 | + {...props} |
| 21 | + /> |
| 22 | + ) |
| 23 | +} |
| 24 | + |
| 25 | +function CollectionCardIcon({ |
| 26 | + icon: Icon = CubeIcon, |
| 27 | + badgeClassName, |
| 28 | + iconClassName, |
| 29 | +}: { |
| 30 | + icon?: React.ComponentType<React.ComponentProps<typeof CubeIcon>> |
| 31 | + badgeClassName?: string |
| 32 | + iconClassName?: string |
| 33 | +}) { |
| 34 | + return ( |
| 35 | + <> |
| 36 | + <BadgeOrange |
| 37 | + data-slot="collection-card-badge" |
| 38 | + className={cn('size-24 absolute top-0 left-6 -translate-y-1/2 z-[1]', badgeClassName)} |
| 39 | + /> |
| 40 | + <Icon |
| 41 | + data-slot="collection-card-icon" |
| 42 | + className={cn( |
| 43 | + 'text-text-brand size-10 absolute top-0 left-8 -translate-y-1/2 z-[2] translate-x-1/2', |
| 44 | + iconClassName |
| 45 | + )} |
| 46 | + /> |
| 47 | + </> |
| 48 | + ) |
| 49 | +} |
| 50 | + |
| 51 | +function CollectionCardHeader({ className, ...props }: React.ComponentProps<'div'>) { |
| 52 | + return ( |
| 53 | + <div |
| 54 | + data-slot="collection-card-header" |
| 55 | + className={cn( |
| 56 | + 'flex justify-between items-center px-8 pb-4 pt-14 border-b border-bluegray-300 relative overflow-hidden', |
| 57 | + className |
| 58 | + )} |
| 59 | + {...props} |
| 60 | + > |
| 61 | + <div className="absolute top-0 left-0"> |
| 62 | + <DotsCard /> |
| 63 | + </div> |
| 64 | + {props.children} |
| 65 | + </div> |
| 66 | + ) |
| 67 | +} |
| 68 | + |
| 69 | +function CollectionCardTitle({ className, ...props }: React.ComponentProps<'p'>) { |
| 70 | + return ( |
| 71 | + <div |
| 72 | + data-slot="collection-card-title" |
| 73 | + className={cn('text-bluegray-800', className)} |
| 74 | + {...props} |
| 75 | + /> |
| 76 | + ) |
| 77 | +} |
| 78 | + |
| 79 | +function CollectionCardItemCount({ |
| 80 | + className, |
| 81 | + itemNumber, |
| 82 | + ...props |
| 83 | +}: React.ComponentProps<'div'> & { |
| 84 | + itemNumber: number |
| 85 | +}) { |
| 86 | + return ( |
| 87 | + <div |
| 88 | + data-slot="collection-card-item-count" |
| 89 | + className={cn('flex items-center gap-2', className)} |
| 90 | + {...props} |
| 91 | + > |
| 92 | + <FolderIcon className="text-text-secondary" /> |
| 93 | + <span className="text-sm text-text-secondary">{itemNumber} items</span> |
| 94 | + </div> |
| 95 | + ) |
| 96 | +} |
| 97 | + |
| 98 | +function CollectionCardDescription({ className, ...props }: React.ComponentProps<'div'>) { |
| 99 | + return ( |
| 100 | + <div |
| 101 | + data-slot="collection-card-description" |
| 102 | + className={cn('px-8 pb-8 pt-6 flex-grow text-text-secondary', className)} |
| 103 | + {...props} |
| 104 | + > |
| 105 | + {props.children} |
| 106 | + </div> |
| 107 | + ) |
| 108 | +} |
| 109 | + |
| 110 | +function CollectionCardButton({ |
| 111 | + className, |
| 112 | + children, |
| 113 | + title = 'View', |
| 114 | + ...props |
| 115 | +}: React.ComponentProps<'button'> & { |
| 116 | + title?: string |
| 117 | +}) { |
| 118 | + return ( |
| 119 | + <button |
| 120 | + data-slot="collection-card-button" |
| 121 | + className={cn( |
| 122 | + 'w-full py-6 px-8 bg-gradient-to-b from-pumpkin-50 to-pumpkin-100 rounded-lg text-text-secondary font-medium flex items-center justify-end hover:from-pumpkin-100 hover:to-pumpkin-300 transition cursor-pointer gap-3', |
| 123 | + className |
| 124 | + )} |
| 125 | + {...props} |
| 126 | + > |
| 127 | + <span>{children ?? title}</span> |
| 128 | + <IconChevronLgRight fontSize={24} className="size-10 text-text-secondary" /> |
| 129 | + </button> |
| 130 | + ) |
| 131 | +} |
| 132 | + |
| 133 | +export { |
| 134 | + CollectionCard, |
| 135 | + CollectionCardButton, |
| 136 | + CollectionCardDescription, |
| 137 | + CollectionCardHeader, |
| 138 | + CollectionCardIcon, |
| 139 | + CollectionCardItemCount, |
| 140 | + CollectionCardTitle, |
| 141 | +} |
0 commit comments