import { useState } from 'react' import type { Suggestion, SuggestionType } from '../../api/client' import { AskPetal } from './AskPetal' // Per-type accent color + human label, mirroring the design tokens. const TYPE_META: Record = { grammar: { color: 'var(--color-mint)', label: 'Grammar' }, phrasing: { color: 'var(--color-peach)', label: 'Phrasing' }, idiom: { color: 'var(--color-lavender)', label: 'Idiom' }, clarity: { color: 'var(--color-sky)', label: 'Clarity' }, voice: { color: 'var(--color-honey)', label: 'Voice' }, } interface Props { suggestion: Suggestion style: React.CSSProperties onAccept: (s: Suggestion) => void onDismiss: (s: Suggestion) => void onPointerEnter: () => void onPointerLeave: () => void // Pins the card open while the Ask Petal panel is expanded, so the chat isn't // dismissed by the hover-close timer when the pointer drifts away. onExpandChange: (expanded: boolean) => void } // SuggestionCard is the hover panel for a single suggestion: a colored type tag, // the original → replacement diff, the friendly explanation, and accept/dismiss // actions. Voice flags carry no replacement, so the diff row is hidden and only // Dismiss is offered (awareness-only). export function SuggestionCard({ suggestion, style, onAccept, onDismiss, onPointerEnter, onPointerLeave, onExpandChange, }: Props) { const meta = TYPE_META[suggestion.type] const hasReplacement = suggestion.replacement.trim() !== '' const [asking, setAsking] = useState(false) function toggleAsking() { setAsking((prev) => { const next = !prev onExpandChange(next) return next }) } return (
{meta.label} {hasReplacement && (
{suggestion.original} {suggestion.replacement}
)}

{suggestion.explanation}

{asking && }
{hasReplacement && ( )}
) }