/*! Strand UI | MIT License | dillingerstaffing.com */ import type { JSX } from "preact"; import { forwardRef } from "preact/compat"; import { cx } from "../../internal/index.js"; export interface ResultCardProps extends Omit, "title"> { /** The result's name. */ title: string; company?: string; location?: string; salary?: string; /** Small chips; `remote` and `source` are the two tints. */ badges?: { label: string; variant?: "remote" | "source" }[]; /** The highlighted result, announced with `aria-current`. */ active?: boolean; /** Makes the card a button. */ onSelect?: () => void; className?: string; } /** * One result in an instrument's results panel; a button when selectable, an article when not. * * @example * panTo(id)} /> */ export const ResultCard = forwardRef( ({ title, company, location, salary, badges, active = false, onSelect, className = "", ...rest }, ref) => { const body = ( <>
{title}
{company &&
{company}
} {(location || salary || badges?.length) && (
{location && {location}} {salary && {salary}} {badges?.map((b) => ( {b.label} ))}
)} ); const shared = { className: cx("strand-result-card", active && "strand-result-card--active", className), "aria-current": active ? ("true" as const) : undefined, }; return onSelect ? ( ) : (
["ref"]} {...shared} {...rest}> {body}
); }, ); ResultCard.displayName = "ResultCard";