33import { MosaicProvider } from '@clerk/ui/mosaic/MosaicProvider' ;
44import { RotateCcwIcon , SlidersHorizontalIcon } from 'lucide-react' ;
55import type React from 'react' ;
6+ import { useState } from 'react' ;
67
78import { Collapsible , CollapsibleContent , CollapsibleTrigger } from '@/components/ui/collapsible' ;
89import { generateKnobs , initKnobValues } from '@/lib/generateKnobs' ;
@@ -25,6 +26,7 @@ interface StoryPreviewProps {
2526export function StoryPreview ( { name, storyModule } : StoryPreviewProps ) {
2627 const StoryComp = storyModule [ name ] as React . ComponentType < Record < string , unknown > > ;
2728 const playground = usePlayground ( ) ;
29+ const [ variablesOpen , setVariablesOpen ] = useState ( false ) ;
2830
2931 if ( ! StoryComp ) {
3032 return (
@@ -37,7 +39,11 @@ export function StoryPreview({ name, storyModule }: StoryPreviewProps) {
3739 const variables = playground ?. variables ?? { } ;
3840
3941 return (
40- < Collapsible className = 'not-prose border-border bg-background my-4 overflow-hidden rounded-lg border' >
42+ < Collapsible
43+ open = { variablesOpen }
44+ onOpenChange = { setVariablesOpen }
45+ className = 'not-prose border-border bg-background my-4 overflow-hidden rounded-lg border'
46+ >
4147 < div className = 'flex items-center justify-end border-b px-2 py-1.5' >
4248 < button
4349 type = 'button'
@@ -56,11 +62,21 @@ export function StoryPreview({ name, storyModule }: StoryPreviewProps) {
5662 </ MosaicProvider >
5763 </ div >
5864
59- < div className = 'flex items-center justify-start border-t px-2 py-1.5' >
60- < CollapsibleTrigger className = 'text-muted-foreground hover:text-foreground flex items-center gap-1 rounded px-2 py-1 text-xs' >
65+ < div className = 'flex items-center justify-start gap-1 border-t px-2 py-1.5' >
66+ < CollapsibleTrigger className = 'text-muted-foreground hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground flex items-center gap-1 rounded px-2 py-1 text-xs' >
6167 < SlidersHorizontalIcon className = 'size-3' />
6268 Variables
6369 </ CollapsibleTrigger >
70+ { variablesOpen && playground ? (
71+ < button
72+ type = 'button'
73+ onClick = { ( ) => playground . setVariables ( { } ) }
74+ className = 'text-muted-foreground hover:text-foreground flex items-center gap-1 rounded px-2 py-1 text-xs'
75+ >
76+ < RotateCcwIcon className = 'size-3' />
77+ Reset
78+ </ button >
79+ ) : null }
6480 </ div >
6581
6682 { playground ? (
0 commit comments