mirror of
https://github.com/supabase/supabase.git
synced 2026-06-17 13:14:06 +08:00
## Problem Now that we migrated old components to their new shadcn alternatives, we don't need the `_Shadcn_` suffix anymore. ## Solution Remove it <img width="659" height="609" alt="image" src="https://github.com/user-attachments/assets/2d7271a9-066a-4dcc-92fe-729b106d2c2f" />
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
import type { PropsWithChildren, ReactNode } from 'react'
|
|
import { cn, Collapsible, CollapsibleContent, CollapsibleTrigger } from 'ui'
|
|
|
|
type ToolProps = PropsWithChildren<{
|
|
className?: string
|
|
label: ReactNode
|
|
icon?: ReactNode
|
|
}>
|
|
|
|
export function Tool({ className, label, icon, children }: ToolProps) {
|
|
const isCollapsible = !!children
|
|
|
|
return (
|
|
<div
|
|
className={cn(
|
|
'tool-item text-foreground-lighter flex items-center gap-2 py-2',
|
|
'[&:not(.tool-item+.tool-item)]:mt-4 [&:not(:has(+.tool-item))]:mb-4',
|
|
'[&:has(+.tool-item)]:border-b [&:has(+.tool-item)]:border-b-muted',
|
|
'first:mt-0! last:mb-0',
|
|
className
|
|
)}
|
|
>
|
|
<Collapsible>
|
|
<CollapsibleTrigger
|
|
className={cn('flex items-center gap-2 w-full text-left')}
|
|
disabled={!children}
|
|
>
|
|
{icon}
|
|
{typeof label === 'string' ? (
|
|
<span className="text-foreground-lighter">{label}</span>
|
|
) : (
|
|
label
|
|
)}
|
|
</CollapsibleTrigger>
|
|
|
|
{isCollapsible && (
|
|
<CollapsibleContent
|
|
className={cn('pl-6 py-2 text-xs leading-normal', 'max-h-64 overflow-y-auto')}
|
|
>
|
|
{children}
|
|
</CollapsibleContent>
|
|
)}
|
|
</Collapsible>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
Tool.displayName = 'Tool'
|