mirror of
https://github.com/supabase/supabase.git
synced 2026-10-17 07:09:07 +03:00
## 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). ```
51 lines
1.7 KiB
TypeScript
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>
|
|
)
|
|
}
|