11// Tabs
22import { Tabs } from "@kobalte/core/tabs"
3- import { useClipboard } from "bagon-hooks"
43import { clsx } from "clsx"
54import {
65 type ComponentProps ,
@@ -13,6 +12,7 @@ import {
1312 onMount ,
1413 Show ,
1514 splitProps ,
15+ type Component ,
1616} from "solid-js"
1717import { MDXContent } from "@/components/mdx-content"
1818import { cn } from "@/utils/cn"
@@ -48,7 +48,7 @@ export type DemoProps = {
4848 children : JSX . Element
4949 class ?: string
5050 defaultValue ?: TabValue
51- code ?: string
51+ code ?: Component
5252 minHeight ?: string
5353 title ?: JSX . Element
5454}
@@ -69,8 +69,6 @@ function Demo(props: FlowProps<Props>) {
6969 const [ knowsToClick , setKnowsToClick ] = createSignal ( false )
7070 const [ active , setActive ] = createSignal ( _props . defaultValue )
7171
72- const { copy, copied } = useClipboard ( )
73-
7472 function handleClick ( ) {
7573 if ( ! _props . onClick ) return
7674
@@ -170,54 +168,9 @@ function Demo(props: FlowProps<Props>) {
170168 </ div >
171169 </ Tabs . Content >
172170 </ Show >
173- < Show when = { active ( ) === "code" && _props . code } >
174- < Tabs . Content value = "code" class = " relative overflow-hidden p-3 text-sm">
171+ < Show when = { _props . code } >
172+ < Tabs . Content value = "code" class = { clsx ( "min-h-25 relative overflow-hidden text-sm", active ( ) !== "code" && "hidden" ) } forceMount >
175173 < MDXContent code = { _props . code ! } />
176- < button
177- onClick = { ( ) => {
178- const code = _props . code || ""
179- const trimmedCode = code
180- . replace ( / ^ \s * ` ` ` t s x \s * \n ? / , "" ) // Remove ```tsx from beginning
181- . replace ( / \n ? \s * ` ` ` \s * $ / , "" ) // Remove ``` from end
182- copy ( trimmedCode )
183- } }
184- class = "absolute right-2 bottom-2 animate-fadeIn rounded-md bg-white/10 p-1 transition-colors hover:bg-white/20"
185- >
186- < Show
187- when = { ! copied ( ) }
188- fallback = {
189- < svg
190- class = "h-4 w-4 animate-scale-in text-white"
191- fill = "none"
192- stroke = "currentColor"
193- viewBox = "0 0 24 24"
194- xmlns = "http://www.w3.org/2000/svg"
195- >
196- < path
197- stroke-linecap = "round"
198- stroke-linejoin = "round"
199- stroke-width = "2"
200- d = "M5 13l4 4L19 7"
201- />
202- </ svg >
203- }
204- >
205- < svg
206- class = "h-4 w-4 animate-scale-in text-white"
207- fill = "none"
208- stroke = "currentColor"
209- viewBox = "0 0 24 24"
210- xmlns = "http://www.w3.org/2000/svg"
211- >
212- < path
213- stroke-linecap = "round"
214- stroke-linejoin = "round"
215- stroke-width = "2"
216- d = "M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"
217- > </ path >
218- </ svg >
219- </ Show >
220- </ button >
221174 </ Tabs . Content >
222175 </ Show >
223176 </ Collapsible >
@@ -415,7 +368,7 @@ export function Collapsible(props: CollapsibleProps) {
415368 return (
416369 < div
417370 style = { { height : heightStyle ( ) } }
418- class = { cn ( "overflow-hidden transition-[width,height] duration-400 " , local . containerClass ) }
371+ class = { cn ( "overflow-hidden transition-[width,height] duration-350 ease-in-out " , local . containerClass ) }
419372 aria-hidden = { ! local . open }
420373 { ...others }
421374 >
0 commit comments