import Link from 'next/link' import React, { PropsWithChildren } from 'react' import { IconChevronRight, IconLoader } from 'ui' interface CardButtonProps { title: string | React.ReactNode description?: string footer?: React.ReactNode url?: string linkHref?: string imgUrl?: string imgAlt?: string onClick?: () => void icon?: React.ReactNode loading?: boolean className?: string } const CardButton = ({ title, description, children, footer, url = '', linkHref = '', imgUrl, imgAlt, onClick, icon, className, loading = false, }: PropsWithChildren) => { const LinkContainer = ({ children }: { children: React.ReactNode }) => ( {children} ) const UrlContainer = ({ children }: { children: React.ReactNode }) => {children} const NonLinkContainer = ({ children }: { children: React.ReactNode }) =>
{children}
const ButtonContainer = ({ children }: { children: React.ReactNode }) => ( ) const isLink = url || linkHref || onClick let containerClasses = [ className, 'group relative text-left', 'bg-surface-100', 'border border-surface', 'rounded-md p-5 flex flex-row h-32', 'transition ease-in-out duration-150', ] if (isLink) { containerClasses = [ ...containerClasses, 'cursor-pointer', 'hover:bg-surface-200', 'hover:border-control', ] } const ImageContainer = ({ children }: { children: React.ReactNode }) => { return
{children}
} const contents = (
{imgUrl && ( {`${imgAlt}`} )} {icon && {icon}}
{typeof title === 'string' ?
{title}
: title} {(children || description) && (

{description}

{children && children}
)} {footer &&
{footer}
}
{isLink && (
{loading ? : }
)}
) if (onClick) { return {contents} } else if (linkHref) { return {contents} } else if (url) { return {contents} } else { return {contents} } } export default CardButton