mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00: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). ```
61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
import { XIcon } from 'lucide-react'
|
|
import React from 'react'
|
|
import { Button, HoverCard, HoverCardContent, HoverCardTrigger } from 'ui'
|
|
import { CodeBlock } from 'ui-patterns/CodeBlock'
|
|
|
|
import { getSnippetContent, getSnippetLabel } from './AIAssistant.utils'
|
|
import { type SqlSnippet } from '@/state/ai-assistant-state'
|
|
|
|
interface SnippetRowProps {
|
|
snippets: SqlSnippet[]
|
|
onRemoveSnippet?: (index: number) => void
|
|
className?: string
|
|
}
|
|
|
|
export const SnippetRow: React.FC<SnippetRowProps> = ({
|
|
snippets,
|
|
onRemoveSnippet,
|
|
className = '',
|
|
}) => {
|
|
if (!snippets || snippets.length === 0) return null
|
|
|
|
return (
|
|
<div className={`w-full overflow-x-auto flex ${className}`}>
|
|
{snippets.map((snippet, idx) => (
|
|
<HoverCard key={idx}>
|
|
<HoverCardTrigger asChild>
|
|
<div
|
|
tabIndex={0}
|
|
className="border bg inline-flex gap-1 items-center shrink-0 py-1 pl-2 rounded-full pr-1 text-xs cursor-pointer"
|
|
>
|
|
{getSnippetLabel(snippet, idx)}
|
|
{onRemoveSnippet && (
|
|
<Button
|
|
size="tiny"
|
|
variant="text"
|
|
className="h-4! w-4! rounded-full p-0"
|
|
onClick={(e) => {
|
|
e.stopPropagation()
|
|
onRemoveSnippet(idx)
|
|
}}
|
|
aria-label={`Remove snippet ${idx + 1}`}
|
|
icon={<XIcon strokeWidth={1.5} className="h-3! w-3!" />}
|
|
/>
|
|
)}
|
|
</div>
|
|
</HoverCardTrigger>
|
|
<HoverCardContent className="w-96 max-h-64 overflow-auto p-0">
|
|
<CodeBlock
|
|
hideLineNumbers
|
|
className="text-xs font-mono whitespace-pre-wrap wrap-break-word p-2 border-0"
|
|
language="sql"
|
|
>
|
|
{getSnippetContent(snippet)}
|
|
</CodeBlock>
|
|
</HoverCardContent>
|
|
</HoverCard>
|
|
))}
|
|
</div>
|
|
)
|
|
}
|