61 lines
1.7 KiB
TypeScript
Raw Normal View History

2024-10-21 13:57:17 -06:00
import { ChevronDown, ChevronUp, X } from "lucide-react"
interface ContextDisplayProps {
2024-10-21 13:57:17 -06:00
context: string | null
isContextExpanded: boolean
setIsContextExpanded: (isExpanded: boolean) => void
setContext: (context: string | null) => void
}
2024-10-21 13:57:17 -06:00
export default function ContextDisplay({
context,
isContextExpanded,
setIsContextExpanded,
setContext,
}: ContextDisplayProps) {
if (!context) return null
return (
<div className="mb-2 bg-input p-2 rounded-lg">
<div className="flex justify-between items-center">
2024-10-21 13:57:17 -06:00
<div
className="flex-grow cursor-pointer"
onClick={() => setIsContextExpanded(!isContextExpanded)}
>
2024-10-21 13:57:17 -06:00
<span className="text-sm text-gray-300">Context</span>
</div>
<div className="flex items-center">
{isContextExpanded ? (
2024-10-21 13:57:17 -06:00
<ChevronUp
size={16}
className="cursor-pointer"
onClick={() => setIsContextExpanded(false)}
/>
) : (
2024-10-21 13:57:17 -06:00
<ChevronDown
size={16}
className="cursor-pointer"
onClick={() => setIsContextExpanded(true)}
/>
)}
2024-10-21 13:57:17 -06:00
<X
size={16}
className="ml-2 cursor-pointer text-gray-400 hover:text-gray-200"
onClick={() => setContext(null)}
/>
</div>
</div>
{isContextExpanded && (
<textarea
2024-10-21 13:57:17 -06:00
value={context.replace(/^Regarding this code:\n/, "")}
onChange={(e) =>
setContext(`Regarding this code:\n${e.target.value}`)
}
className="w-full mt-2 p-2 bg-#1e1e1e text-white rounded"
rows={5}
/>
)}
</div>
2024-10-21 13:57:17 -06:00
)
}