import type { ReactNode } from 'react'; import { Link } from 'react-router'; import { styles } from './styles'; import { gridColsClass } from './utils'; export interface TileProps { /** URL to navigate to when the tile is clicked. */ href: string; title?: ReactNode; description?: ReactNode; /** Preview content, typically light/dark image variants. */ children: ReactNode; target?: '_self' | '_blank'; } export function Tile({ href, title, description, children, target }: TileProps) { const external = /^https?:\/\//i.test(href); const resolvedTarget = target ?? (external ? '_blank' : undefined); const content = ( <>
{children}
{title || description ? (
{title ?
{title}
: null} {description ?
{description}
: null}
) : null} ); const className = `${styles.tile} no-underline hover:no-underline active:no-underline`; if (external) { return ( {content} ); } return ( {content} ); } export interface TilesProps { children?: ReactNode; cols?: 1 | 2 | 3 | 4; } /** Grid wrapper for when is not used directly. */ export function Tiles({ children, cols = 2 }: TilesProps) { return
{children}
; }