2024-10-21 13:57:17 -06:00
|
|
|
import { ChevronDown, ChevronUp, X } from "lucide-react"
|
2024-10-14 22:34:26 -04:00
|
|
|
|
|
|
|
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-14 22:34:26 -04:00
|
|
|
}
|
|
|
|
|
2024-10-21 13:57:17 -06:00
|
|
|
export default function ContextDisplay({
|
|
|
|
context,
|
|
|
|
isContextExpanded,
|
|
|
|
setIsContextExpanded,
|
|
|
|
setContext,
|
|
|
|
}: ContextDisplayProps) {
|
|
|
|
if (!context) return null
|
2024-10-14 22:34:26 -04:00
|
|
|
|
|
|
|
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"
|
2024-10-14 22:34:26 -04:00
|
|
|
onClick={() => setIsContextExpanded(!isContextExpanded)}
|
|
|
|
>
|
2024-10-21 13:57:17 -06:00
|
|
|
<span className="text-sm text-gray-300">Context</span>
|
2024-10-14 22:34:26 -04:00
|
|
|
</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-14 22:34:26 -04:00
|
|
|
) : (
|
2024-10-21 13:57:17 -06:00
|
|
|
<ChevronDown
|
|
|
|
size={16}
|
|
|
|
className="cursor-pointer"
|
|
|
|
onClick={() => setIsContextExpanded(true)}
|
|
|
|
/>
|
2024-10-14 22:34:26 -04:00
|
|
|
)}
|
2024-10-21 13:57:17 -06:00
|
|
|
<X
|
|
|
|
size={16}
|
|
|
|
className="ml-2 cursor-pointer text-gray-400 hover:text-gray-200"
|
2024-10-14 22:34:26 -04:00
|
|
|
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}`)
|
|
|
|
}
|
2024-10-14 22:34:26 -04:00
|
|
|
className="w-full mt-2 p-2 bg-#1e1e1e text-white rounded"
|
|
|
|
rows={5}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</div>
|
2024-10-21 13:57:17 -06:00
|
|
|
)
|
2024-10-14 22:34:26 -04:00
|
|
|
}
|