Files
supabase/apps/studio/components/interfaces/QueryPerformance/QueryPanel.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

94 lines
3.1 KiB
TypeScript

import { InformationCircleIcon } from '@heroicons/react/16/solid'
import { ArrowDownIcon, ArrowUpIcon } from 'lucide-react'
import { PropsWithChildren } from 'react'
import { cn, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
export const QueryPanelContainer = ({
children,
className,
}: PropsWithChildren<{ className?: string }>) => (
<div className={cn('flex flex-col gap-y-0 py-4', className)}>{children}</div>
)
export const QueryPanelSection = ({
children,
className,
}: PropsWithChildren<{ className?: string }>) => (
<div className={cn('px-6 flex flex-col gap-y-0', className)}>{children}</div>
)
export const QueryPanelScoreSection = ({
className,
name,
description,
before: rawBefore,
after: rawAfter,
hideArrowMarkers = false,
}: {
className?: string
name: string
description: string
before?: number
after?: number
hideArrowMarkers?: boolean
}) => {
const before = rawBefore !== undefined ? Number(rawBefore) : undefined
const after = rawAfter !== undefined ? Number(rawAfter) : undefined
return (
<div className={cn('py-4 px-4 flex', className)}>
<div className="flex gap-x-2 w-48">
<span className="text-sm">{name}</span>
<Tooltip>
<TooltipTrigger asChild className="mt-1">
<InformationCircleIcon className="transition text-foreground-muted w-3 h-3 data-[state=delayed-open]:text-foreground-light" />
</TooltipTrigger>
<TooltipContent side="top" className="w-52 text-center">
{description}
</TooltipContent>
</Tooltip>
</div>
<div className="flex flex-col gap-y-1">
<div className="flex gap-x-2 text-sm">
<span className="text-foreground-light w-20">Currently:</span>
<span
className={cn(
'font-mono',
before !== undefined && after !== undefined && before !== after
? 'text-foreground-light'
: ''
)}
>
{before}
</span>
</div>
{before !== undefined && after !== undefined && before !== after && (
<div className="flex items-center gap-x-2 text-sm">
<span className="text-foreground-light w-20">With index:</span>
<span className="font-mono">{after}</span>
{before !== undefined && !hideArrowMarkers && (
<div className="flex items-center gap-x-1">
{after > before ? (
<ArrowUpIcon size={14} className="text-warning" />
) : (
<ArrowDownIcon size={14} className="text-primary" />
)}
{before !== 0 && !isNaN(before) && isFinite(before) && (
<span
className={cn(
'font-mono tracking-tighter',
after > before ? 'text-warning' : 'text-primary'
)}
>
{(((before - after) / before) * 100).toFixed(2)}%
</span>
)}
</div>
)}
</div>
)}
</div>
</div>
)
}