Files
Saxon Fletcher d8f8d9a1f3 Update add-ons design (#43159)
**Old**

<img width="1376" height="1115" alt="image"
src="https://github.com/user-attachments/assets/75703b14-f066-491e-8d5a-b68a716fa081"
/>


**New**

<img width="1374" height="678" alt="image"
src="https://github.com/user-attachments/assets/538830be-a8bf-40c8-97dc-2c6085d500c7"
/>

This updates the add-ons design to remove the Compute Size section which
has now been moved and simplify the add-on list design.
2026-03-18 13:59:21 +10:00

81 lines
2.2 KiB
TypeScript

import { ChevronRight, MoreVertical } from 'lucide-react'
import { forwardRef, HTMLAttributes, ReactNode } from 'react'
import {
Button,
CardContent,
cn,
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from 'ui'
export interface ResourceAction {
label: string
onClick: () => void
}
export interface ResourceItemProps extends HTMLAttributes<HTMLDivElement> {
media?: ReactNode
meta?: ReactNode
onClick?: () => void
children?: ReactNode
actions?: ResourceAction[]
}
export const ResourceItem = forwardRef<HTMLDivElement, ResourceItemProps>(
({ media, meta, onClick, children, className, actions, ...props }, ref) => {
return (
<CardContent
ref={ref}
className={cn(
'flex items-center justify-between text-sm gap-4',
'!border-b-0',
onClick && 'cursor-pointer transition-colors duration-150 hover:bg-surface-200',
className
)}
onClick={onClick}
{...props}
>
{media && (
<div className="text-foreground-light flex items-center justify-center">{media}</div>
)}
<div className="flex-1">{children}</div>
{meta && <div>{meta}</div>}
{actions && actions.length > 0 ? (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
type="text"
className="px-1"
icon={<MoreVertical size={16} />}
onClick={(e) => {
e.stopPropagation()
}}
/>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
{actions.map((action) => (
<DropdownMenuItem
key={action.label}
onClick={(e) => {
e.stopPropagation()
action.onClick()
}}
>
{action.label}
</DropdownMenuItem>
))}
</DropdownMenuContent>
</DropdownMenu>
) : (
onClick && <ChevronRight strokeWidth={1.5} size={16} />
)}
</CardContent>
)
}
)
ResourceItem.displayName = 'ResourceItem'