import { For, Show, type JSX } from "solid-js"; import { SourceAttribution } from "~/components/SourceAttribution"; import { AnswerBlock } from "~/components/AnswerBlock"; import { formatWhen } from "~/lib/format"; import styles from "~/routes/[handle].module.css"; interface AnswerLike { id: string; content: string; createdAt: Date | string; sourceType?: string | null; sourceUri?: string | null; sourceData?: string | null; } interface AuthorLike { handle: string; displayName?: string | null; } interface QuestionCardProps { id?: string; content: string; createdAt: Date | string; anonymous: boolean; author?: AuthorLike | null; sourceType?: string | null; sourceUri?: string | null; sourceData?: string | null; answers?: AnswerLike[]; /** When true, show a "Pending answer" hint if no answers are present. */ showPendingHint?: boolean; /** Optional slot for trailing content (e.g. "Click to answer →"). */ trailing?: JSX.Element; } export function QuestionCard(props: QuestionCardProps) { const authorLabel = () => { if (props.anonymous) return "Anonymous"; return props.author?.displayName || props.author?.handle || "Unknown"; }; return (
{props.content}
{authorLabel()} · {formatWhen(props.createdAt)}
{(a) => ( )}
Pending answer
{props.trailing}
); } export default QuestionCard;