Files
supabase/apps/studio/components/ui/AIAssistantPanel/CollapsibleCodeBlock.tsx
T
Joshen Lim 09a1f431bc Mass update for all lucide icon imports to use the component with Icon suffix (#51659)
## Context

This is largely just a mechanical change here:
Opting to use lucide icons with the `Icon` suffix across all icon
imports within `studio`
- so that it’s clearer which components are icons + reduces the
possibility of name collision with our own components
- e.g <User /> vs <UserIcon />

Also added a eslint rule for this:
<img width="1069" height="167" alt="image"
src="https://github.com/user-attachments/assets/7f36f443-5ca2-4bf6-8d22-86e774513bfc"
/>

And updated `AGENTS.md` as such:
```
Icons come from `lucide-react`, always imported with the `Icon` suffix (`import { CheckIcon, Trash2Icon } from 'lucide-react'`) — never the bare names (`Check`) or `Check as CheckIcon` aliases (lint-enforced).
```
2026-10-14 12:56:55 +02:00

51 lines
1.7 KiB
TypeScript

import { CodeIcon, XIcon } from 'lucide-react'
import { Button, cn, HoverCard, HoverCardContent, HoverCardTrigger } from 'ui'
import { CodeBlock, type CodeBlockProps } from 'ui-patterns/CodeBlock'
interface CollapsibleCodeBlockProps extends CodeBlockProps {
onRemove?: () => void
}
export const CollapsibleCodeBlock = ({ onRemove, ...props }: CollapsibleCodeBlockProps) => {
const codeString = (props.value || props.children) as string
const firstLine = codeString?.substring(0, codeString.indexOf('\n')) || codeString
return (
<div className="relative">
<div
className={cn(
'flex items-center gap-1 px-2 py-1.5 bg-surface-100 border border-default w-full overflow-hidden',
'rounded-md',
props.className
)}
>
<HoverCard>
<HoverCardTrigger asChild>
<div className="flex flex-1 items-center gap-2 text-foreground-light px-2 hover:text-foreground cursor-pointer overflow-hidden">
<CodeIcon size={14} strokeWidth={1.5} />
<span className="text-xs font-mono flex-1 truncate pointer">{firstLine}...</span>
</div>
</HoverCardTrigger>
<HoverCardContent className="w-96 max-h-96 overflow-auto p-0">
<CodeBlock
{...props}
value={codeString}
className={cn('text-xs font-mono border-none p-3')}
/>
</HoverCardContent>
</HoverCard>
{onRemove && (
<Button
variant="text"
size="tiny"
className="shrink-0 w-6 h-6"
onClick={onRemove}
icon={<XIcon size={14} />}
/>
)}
</div>
</div>
)
}