mirror of
https://github.com/supabase/supabase.git
synced 2026-06-13 01:39:53 +08:00
## Problem We have multiple Popover components ## Solution - [x] migrate Popover usages to Shadcn components - Migrated JSON and text editor in the `TableEditor` (inline row edition) - Migrated the template popover in the logs explorer templates page - [x] remove `_Shadcn_` suffix from Popover components (renaming + prettier) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Unified popover implementation across the app and design system; dropdowns, calendars, menus and tooltips now use a consistent popover API with no visual or interaction changes. * **Chores** * Minor prop typing update for the logs date-picker to align with the consolidated popover content type. <!-- review_stack_entry_start --> [](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/45980) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
73 lines
2.1 KiB
TypeScript
73 lines
2.1 KiB
TypeScript
import { AlertCircle, ChevronsUpDown } from 'lucide-react'
|
|
import Link from 'next/link'
|
|
import { forwardRef, type ReactNode } from 'react'
|
|
import { Button, cn, Popover, PopoverContent, PopoverTrigger } from 'ui'
|
|
|
|
interface AppLayoutDropdownErrorProps {
|
|
message: string
|
|
}
|
|
|
|
export function AppLayoutDropdownError({ message }: AppLayoutDropdownErrorProps) {
|
|
return (
|
|
<div className="flex items-center space-x-2 text-amber-900">
|
|
<AlertCircle size={16} strokeWidth={1.5} />
|
|
<p className="text-sm">{message}</p>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
interface AppLayoutDropdownTriggerButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
className?: string
|
|
}
|
|
|
|
export const AppLayoutDropdownTriggerButton = forwardRef<
|
|
HTMLButtonElement,
|
|
AppLayoutDropdownTriggerButtonProps
|
|
>(({ className, ...props }, ref) => (
|
|
<Button
|
|
ref={ref}
|
|
size="tiny"
|
|
className={cn('px-1.5 py-4 [&_svg]:w-5 [&_svg]:h-5 ml-1', className)}
|
|
iconRight={<ChevronsUpDown strokeWidth={1.5} />}
|
|
{...props}
|
|
type="text"
|
|
/>
|
|
))
|
|
AppLayoutDropdownTriggerButton.displayName = 'AppLayoutDropdownTriggerButton'
|
|
|
|
export interface AppLayoutDropdownWithPopoverProps {
|
|
linkHref: string
|
|
linkContent: ReactNode
|
|
linkClassName?: string
|
|
commandContent: ReactNode
|
|
open: boolean
|
|
onOpenChange: (open: boolean) => void
|
|
triggerButtonClassName?: string
|
|
}
|
|
|
|
export function AppLayoutDropdownWithPopover({
|
|
linkHref,
|
|
linkContent,
|
|
linkClassName = 'flex items-center gap-2 shrink-0 text-sm',
|
|
commandContent,
|
|
open,
|
|
onOpenChange,
|
|
triggerButtonClassName,
|
|
}: AppLayoutDropdownWithPopoverProps) {
|
|
return (
|
|
<Popover open={open} onOpenChange={onOpenChange} modal={false}>
|
|
<div className="flex items-center shrink-0">
|
|
<Link href={linkHref} className={linkClassName}>
|
|
{linkContent}
|
|
</Link>
|
|
<PopoverTrigger asChild>
|
|
<AppLayoutDropdownTriggerButton className={triggerButtonClassName} />
|
|
</PopoverTrigger>
|
|
</div>
|
|
<PopoverContent className="p-0" side="bottom" align="start">
|
|
{commandContent}
|
|
</PopoverContent>
|
|
</Popover>
|
|
)
|
|
}
|