1- import ChevronDown from "@/assets/icons/chevron-down.svg?react" ;
2- import { Key , Value } from "@/components/KeyValue" ;
1+ import { NestedCollapsible } from "@/components/NestedCollapsible" ;
32import { snakeCaseToTitleCase } from "@/lib/strings" ;
43import { StackComponent } from "@/types/components" ;
54import { PipelineRun } from "@/types/pipeline-runs" ;
6- import {
7- CollapsibleContent ,
8- CollapsibleHeader ,
9- CollapsiblePanel ,
10- CollapsibleTrigger
11- } from "@zenml-io/react-component-library" ;
12- import { ReactNode , useState } from "react" ;
5+ import { CollapsibleHeader } from "@zenml-io/react-component-library" ;
136
147type Props = {
158 component : StackComponent ;
169 run : PipelineRun ;
1710} ;
1811
1912export function StackComponentCollapsible ( { component, run } : Props ) {
20- const [ open , setOpen ] = useState ( false ) ;
21-
2213 const keyName = `${ component . body ?. type } .${ component . body ?. flavor } ` ;
2314 const settings =
2415 // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -37,38 +28,18 @@ export function StackComponentCollapsible({ component, run }: Props) {
3728 }
3829
3930 return (
40- < CollapsiblePanel className = "w-full" open = { open } onOpenChange = { setOpen } >
41- < CollapsibleHeader intent = "secondary" className = "flex items-center justify-between " >
42- < div className = "flex w-full items-center gap-[10px]" >
43- < CollapsibleTrigger >
44- < ChevronDown
45- className = { ` ${
46- open ? "" : "-rotate-90"
47- } h-5 w-5 rounded-md fill-neutral-500 transition-transform duration-200 hover:bg-neutral-200`}
48- />
49- </ CollapsibleTrigger >
50- < div className = "grid w-full grid-cols-2 gap-2" >
51- < span > { snakeCaseToTitleCase ( component . body ?. type as string ) } </ span >
52- < div > { component . name } </ div >
53- </ div >
31+ < NestedCollapsible
32+ intent = "secondary"
33+ contentClassName = "pl-[60px]"
34+ className = "w-full"
35+ isInitialOpen = { false }
36+ data = { settings }
37+ title = {
38+ < div className = "grid w-full grid-cols-2 gap-2 text-left" >
39+ < span > { snakeCaseToTitleCase ( component . body ?. type as string ) } </ span >
40+ < div > { component . name } </ div >
5441 </ div >
55- </ CollapsibleHeader >
56- < CollapsibleContent className = "border-t border-theme-border-moderate bg-theme-surface-primary px-5 py-3" >
57- < dl className = "grid grid-cols-1 gap-x-[10px] gap-y-2 pl-[36px] md:grid-cols-2 md:gap-y-4" >
58- { Object . entries ( settings ) . map ( ( [ key , value ] ) => (
59- < KeyValue key = { key } label = { key } value = { JSON . stringify ( value ) } />
60- ) ) }
61- </ dl >
62- </ CollapsibleContent >
63- </ CollapsiblePanel >
64- ) ;
65- }
66-
67- function KeyValue ( { label, value } : { label : string ; value : string | ReactNode } ) {
68- return (
69- < >
70- < Key className = "col-span-1 text-theme-text-secondary" > { label } </ Key >
71- < Value className = "col-span-1 w-full truncate text-neutral-700" > { value } </ Value >
72- </ >
42+ }
43+ />
7344 ) ;
7445}
0 commit comments