Files
cosscom__coss/apps/ui/components/code-collapsible-wrapper.tsx
Pasquale Vitiello 9302c06311 refactor: align biome settings with calcom (#718)
* update biome config + resolve issues

* improve the ui:sync command to run organizeImports on packages

* reformat

* build registry

* exclude base-ui stuff

* fix useExportsLast

* further improvements

* silence errors

* exclude examples app

* update biome + reformat

* format all the other files

* include examples app

* improve copyable-field

* remove unwanted comment

* remove a few unneeded biome comments

* avoid nested ternary

* refactored some shared components

* upgrade base ui to 1.2.0

* fix
2026-03-11 23:09:19 +00:00

50 lines
1.6 KiB
TypeScript

"use client";
import * as React from "react";
import { Button } from "@/registry/default/ui/button";
import {
Collapsible,
CollapsiblePanel,
CollapsibleTrigger,
} from "@/registry/default/ui/collapsible";
import { Separator } from "@/registry/default/ui/separator";
import { cn } from "@/lib/utils";
export function CodeCollapsibleWrapper({
className,
children,
...props
}: React.ComponentProps<typeof Collapsible>) {
const [isOpened, setIsOpened] = React.useState(false);
return (
<Collapsible
className={cn("group/collapsible relative md:-mx-1", className)}
onOpenChange={setIsOpened}
open={isOpened}
{...props}
>
<div className="absolute top-1.5 right-10 z-10 flex items-center">
<CollapsibleTrigger
render={
<Button className="text-muted-foreground" variant="ghost">
{isOpened ? "Collapse" : "Expand"}
</Button>
}
/>
<Separator className="mx-1.5 h-5" orientation="vertical" />
</div>
<CollapsiblePanel
className="[&>figure]:md:!mx-0 relative mt-6 h-full overflow-hidden data-closed:max-h-64 [&>figure]:mt-0"
hidden={false}
keepMounted
>
{children}
</CollapsiblePanel>
<CollapsibleTrigger className="absolute inset-x-0 -bottom-2 flex h-20 cursor-pointer items-center justify-center rounded-b-lg bg-gradient-to-b from-transparent via-50% via-background to-background font-medium text-muted-foreground text-sm transition-colors hover:text-foreground group-data-open/collapsible:hidden">
{isOpened ? "Collapse" : "Expand"}
</CollapsibleTrigger>
</Collapsible>
);
}