import type { ReactNode } from 'react'; import { Link } from 'react-router'; import { Check as CheckIcon, ChevronRight, CircleAlert, InfoIcon, Lightbulb, TriangleAlert, } from '@/components/icons'; import { CardContent, Card as CardPrimitive } from '@/components/ui/card'; import { styles } from './styles'; import { gridColsClass, resolveIcon } from './utils'; export interface CardProps { title?: ReactNode; href?: string; icon?: ReactNode | string; color?: string; img?: string; cta?: string; horizontal?: boolean; arrow?: boolean; type?: CardType; children?: ReactNode; } export type CardType = 'note' | 'info' | 'warning' | 'tip' | 'check' | 'danger'; const CARD_TYPE_ICONS: Record = { note: , info: , warning: , tip: , check: , danger: , }; const CARD_TYPE_HOVER: Record = { note: 'hover:border-border', info: 'hover:border-blue-300 dark:hover:border-blue-400/40', warning: 'hover:border-amber-300 dark:hover:border-amber-400/40', tip: 'hover:border-green-300 dark:hover:border-green-400/40', check: 'hover:border-emerald-300 dark:hover:border-emerald-400/40', danger: 'hover:border-destructive/40', }; function DocsCardContent({ title, icon, color, img, cta, arrow, type, children, }: Omit) { const resolvedIcon = resolveIcon(icon, 24) || (type ? CARD_TYPE_ICONS[type] : null); return ( {img ? : null}
{resolvedIcon ? ( {resolvedIcon} ) : null} {title ? (
{title}
) : null}
{children ? (
{children}
) : null}
{cta || arrow ? (
{cta ? {cta} : null} {arrow ? ( ) : null}
) : null}
); } export function Card({ title, href, icon, color, img, cta, horizontal, arrow, type, children, }: CardProps) { const external = typeof href === 'string' && /^https?:\/\//i.test(href); const showArrow = arrow ?? external; const className = `${styles.card} ${type ? `${styles.cardTyped} ${styles[type]} ${CARD_TYPE_HOVER[type]}` : styles.cardPlain} ${horizontal ? styles.cardHorizontal : ''} ${img ? styles.cardImageLayout : ''}`; const content = ( {children} ); if (!href) { return content; } const linkClassName = 'block h-full no-underline hover:no-underline active:no-underline'; if (external) { return ( {content} ); } return ( {content} ); } export interface CardGroupProps { children?: ReactNode; cols?: 1 | 2 | 3 | 4; } export function CardGroup({ children, cols = 2 }: CardGroupProps) { return
{children}
; }