import { Paperclip, Star } from 'lucide-react' import { ClientListDate } from '#shared/components/ClientTime' import { labelBadgeClass } from '#shared/lib/color-tone' import { cn } from '#shared/lib/utils' import { readableSnippet, STAR_FILLED_CLASS, STAR_HOVER_CLASS, threadLabels, threadSender, threadTimestamp, } from '../lib/mail-ui-model.js' import type { MailThread } from '../state/mail-queries.js' /** Shared class for a thread-list row; active/unread/hover come from `.thread-row` CSS. */ export const THREAD_ROW_CLASS = 'thread-row group isolate flex w-full cursor-pointer flex-col gap-1 border-b border-border px-4 py-3 pl-5 text-left outline-none focus-visible:bg-accent' /** A route-specific link can stretch across the row while remaining a sibling of row actions. */ export const THREAD_ROW_LINK_CLASS = 'thread-row-link absolute inset-0 z-0 focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-inset focus-visible:ring-ring forced-colors:focus-visible:outline-2 forced-colors:focus-visible:outline-offset-[-2px] forced-colors:focus-visible:outline-solid' export function threadRowLinkLabel(thread: MailThread, folderId: string) { return `Open ${thread.subject || '(no subject)'} from ${threadSender(thread, folderId)}` } /** * The visible content and secondary star action for a thread-list row. Callers place a * stretched route link before this content so the link and button remain semantic siblings. */ export function ThreadRowContent({ thread, folderId, onToggleStar, starPending = false, }: { thread: MailThread folderId: string onToggleStar: () => void starPending?: boolean }) { const labels = threadLabels(thread) return ( <>
{threadSender(thread, folderId)} {(thread.message_ids?.length ?? 0) > 1 ? ( ({thread.message_ids?.length}) ) : null} {thread.has_attachments ? : null}

{thread.subject || '(no subject)'}

{readableSnippet(thread.snippet)}

{labels.map((label) => ( {label.name} ))}
) }