import { useState } from 'react' import type { DocSummary, Tag, TagColor } from '../../api/client' import { TagChip } from './TagChip' import { TagPicker } from './TagPicker' interface Props { doc: DocSummary active: boolean roster: Tag[] onSelect: () => void onDelete: () => void onDuplicate: () => void onToggleTag: (docId: string, tag: Tag) => void onCreateTag: (docId: string, name: string, color: TagColor) => void } // One row in the sidebar: title + word count, its tag chips, a tag affordance and // a delete affordance on hover, and a rose wash when it's the open document. export function DocListItem({ doc, active, roster, onSelect, onDelete, onDuplicate, onToggleTag, onCreateTag, }: Props) { const [picking, setPicking] = useState(false) const assignedIds = new Set(doc.tags.map((t) => t.id)) return (
{doc.title || 'Untitled'}
{doc.word_count} {doc.word_count === 1 ? 'word' : 'words'}
{/* Tag + delete affordances: always reachable on touch (no hover), fade in on hover for the pointer experience. */} {picking && ( onToggleTag(doc.id, t)} onCreate={(name, color) => onCreateTag(doc.id, name, color)} onClose={() => setPicking(false)} /> )}
{doc.tags.length > 0 && (
{doc.tags.map((t) => ( onToggleTag(doc.id, t)} /> ))}
)}
) }