Files
Gildas Garcia 35571d242e chore: migrate <Collapsible> to shadcn <Collapsible> (#45819)
## Problem

We have multiple `Collapsible` components.

## Solution

Reduce their number by using only the one from shadcn.
I haven't noticed any visual nor functional changes.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Refactor**
* Migrated expandable/collapsible UI to a unified shadcn-based
implementation for more consistent expand/collapse behavior across the
app.

* **Style**
* Updated listbox check icon sizing and removed obsolete collapsible
open/close animations.

* **Chores**
* Removed deprecated collapsible variants and consolidated UI component
surface for simpler maintenance.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-05-13 09:39:48 +02:00

54 lines
1.4 KiB
TypeScript

import type { PropsWithChildren, ReactNode } from 'react'
import {
cn,
Collapsible_Shadcn_ as Collapsible,
CollapsibleContent_Shadcn_ as CollapsibleContent,
CollapsibleTrigger_Shadcn_ as 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'