mirror of
https://github.com/supabase/supabase.git
synced 2026-10-16 22:59:11 +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). ```
57 lines
1.7 KiB
TypeScript
57 lines
1.7 KiB
TypeScript
import { CheckIcon, CopyIcon } from 'lucide-react'
|
|
import { forwardRef, useState } from 'react'
|
|
import { cn, copyToClipboard } from 'ui'
|
|
|
|
const CommandRender = forwardRef<HTMLDivElement, { commands: any[]; className?: string }>(
|
|
({ commands, className }, ref) => {
|
|
return (
|
|
<div ref={ref} className={cn('space-y-4', className)}>
|
|
{commands.map((item: any, idx: number) => (
|
|
<Command key={`command-${idx}`} item={item} />
|
|
))}
|
|
</div>
|
|
)
|
|
}
|
|
)
|
|
|
|
CommandRender.displayName = 'CommandRender'
|
|
|
|
export default CommandRender
|
|
|
|
const Command = ({ item }: any) => {
|
|
const [isCopied, setIsCopied] = useState(false)
|
|
|
|
return (
|
|
<div className="space-y-1">
|
|
<span className="font-mono text-sm text-foreground-lighter">{`> ${item.comment}`}</span>
|
|
<div className="flex items-center gap-2">
|
|
<div className="flex gap-2 font-mono text-sm font-normal text-foreground">
|
|
<span className="text-foreground-lighter">$</span>
|
|
<span>
|
|
<span>{item.jsx ? item.jsx() : null} </span>
|
|
<button
|
|
type="button"
|
|
tabIndex={0}
|
|
className="text-foreground-lighter hover:text-foreground"
|
|
onClick={() => {
|
|
function onCopy(value: any) {
|
|
setIsCopied(true)
|
|
copyToClipboard(value)
|
|
setTimeout(() => setIsCopied(false), 3000)
|
|
}
|
|
onCopy(item.command)
|
|
}}
|
|
>
|
|
{isCopied ? (
|
|
<CheckIcon size={14} strokeWidth={3} className="text-primary" />
|
|
) : (
|
|
<CopyIcon size={14} />
|
|
)}
|
|
</button>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|