@@ -3,16 +3,23 @@ import { Handle, Position } from "@xyflow/react";
33import { Icons } from "components/core" ;
44import { Button , Card } from "components/ui" ;
55
6- const BaseNode = ( {
7- data,
8- children,
9- } : {
10- data : any ;
11- children : React . ReactNode ;
12- } ) => < Card className = "w-[200px] border-2 shadow-lg" > { children } </ Card > ;
6+ interface NodeData {
7+ label : string ;
8+ description ?: string ;
9+ icon : keyof typeof Icons ;
10+ icon_color ?: string ;
11+ image ?: string ;
12+ expandable ?: boolean ;
13+ version ?: string ;
14+ url ?: string ;
15+ cta ?: {
16+ primary : { label : string ; url : string } ;
17+ secondary ?: { label : string ; url : string } ;
18+ } ;
19+ }
1320
14- const GardenNode = ( { data } : { data : any } ) => (
15- < BaseNode data = { data } >
21+ const GardenNode = ( { data } : { data : NodeData } ) => (
22+ < Card className = "w-[200px] border-2 shadow-lg" >
1623 < div className = "flex flex-col items-center justify-center gap-2 rounded-md bg-primary p-4 text-center text-primary-foreground" >
1724 < Icons . Sprout className = "h-8 w-8" />
1825 < h2 className = "font-semibold text-2xl" > { data . label } </ h2 >
@@ -21,14 +28,14 @@ const GardenNode = ({ data }: { data: any }) => (
2128 </ div >
2229 < Handle type = "target" position = { Position . Top } />
2330 < Handle type = "source" position = { Position . Bottom } />
24- </ BaseNode >
31+ </ Card >
2532) ;
2633
27- const CategoryNode = ( { data } : { data : any } ) => {
34+ const CategoryNode = ( { data } : { data : NodeData } ) => {
2835 const Icon = Icons [ data . icon ] ;
2936
3037 return (
31- < BaseNode data = { data } >
38+ < Card className = "w-[200px] border-2 shadow-lg" >
3239 < Handle type = "target" position = { Position . Top } />
3340 < Handle type = "source" position = { Position . Bottom } />
3441 < div className = "p-4" >
@@ -45,12 +52,12 @@ const CategoryNode = ({ data }: { data: any }) => {
4552 </ p >
4653 ) }
4754 </ div >
48- </ BaseNode >
55+ </ Card >
4956 ) ;
5057} ;
5158
52- const ItemNode = ( { data } : { data : any } ) => (
53- < BaseNode data = { data } >
59+ const ItemNode = ( { data } : { data : NodeData } ) => (
60+ < Card className = "w-[200px] border-2 shadow-lg" >
5461 < div className = "space-y-3" >
5562 < div className = "aspect-video w-full overflow-hidden rounded-t-lg" >
5663 < img
@@ -72,16 +79,17 @@ const ItemNode = ({ data }: { data: any }) => (
7279 variant = "default"
7380 size = "sm"
7481 className = "w-full"
75- onClick = { ( ) => window . open ( data . cta . primary . url , "_blank" ) }
82+ onClick = { ( ) => window . open ( data . cta ? .primary . url , "_blank" ) }
7683 >
7784 < Icons . ExternalLink className = "mr-1 h-4 w-4" />
78- { data . cta . primary . label }
85+ { data . cta ? .primary . label }
7986 </ Button >
80- { data . cta . secondary && (
87+
88+ { data . cta ?. secondary && (
8189 < Button
8290 variant = "outline"
8391 size = "sm"
84- onClick = { ( ) => window . open ( data . cta . secondary . url , "_blank" ) }
92+ onClick = { ( ) => window . open ( data . cta ? .secondary ? .url , "_blank" ) }
8593 >
8694 < Icons . Git className = "h-4 w-4" />
8795 </ Button >
@@ -90,11 +98,11 @@ const ItemNode = ({ data }: { data: any }) => (
9098 </ div >
9199 < Handle type = "target" position = { Position . Top } />
92100 < Handle type = "source" position = { Position . Bottom } />
93- </ BaseNode >
101+ </ Card >
94102) ;
95103
96- const GardenRefNode = ( { data } : { data : any } ) => (
97- < BaseNode data = { data } >
104+ const GardenRefNode = ( { data } : { data : NodeData } ) => (
105+ < Card className = "w-[200px] border-2 shadow-lg" >
98106 < Handle type = "target" position = { Position . Top } />
99107 < Handle type = "target" position = { Position . Left } />
100108 < div className = "relative flex cursor-pointer flex-col items-center rounded-md border-2 border-primary/50 border-dashed p-4 text-center transition-colors hover:bg-primary-foreground/10" >
@@ -127,11 +135,11 @@ const GardenRefNode = ({ data }: { data: any }) => (
127135 </ Button >
128136 </ div >
129137 </ div >
130- </ BaseNode >
138+ </ Card >
131139) ;
132140
133- const SupergardenNode = ( { data } : { data : any } ) => (
134- < BaseNode data = { data } >
141+ const SupergardenNode = ( { data } : { data : NodeData } ) => (
142+ < Card className = "w-[200px] border-2 shadow-lg" >
135143 < Handle type = "source" position = { Position . Bottom } />
136144 < div
137145 className = "relative flex cursor-pointer flex-col items-center border-2 border-white/70 border-dashed p-4 text-center transition-transform hover:scale-105"
@@ -164,11 +172,11 @@ const SupergardenNode = ({ data }: { data: any }) => (
164172 </ Button >
165173 </ div >
166174 </ div >
167- </ BaseNode >
175+ </ Card >
168176) ;
169177
170- const SubgardenNode = ( { data } : { data : any } ) => (
171- < BaseNode data = { data } >
178+ const SubgardenNode = ( { data } : { data : NodeData } ) => (
179+ < Card className = "w-[200px] border-2 shadow-lg" >
172180 < Handle type = "target" position = { Position . Bottom } />
173181 < div
174182 className = "relative flex cursor-pointer flex-col items-center p-4 text-center transition-transform hover:scale-105"
@@ -207,7 +215,7 @@ const SubgardenNode = ({ data }: { data: any }) => (
207215 </ Button >
208216 </ div >
209217 </ div >
210- </ BaseNode >
218+ </ Card >
211219) ;
212220
213221export const nodeTypes = {
@@ -217,7 +225,7 @@ export const nodeTypes = {
217225 garden_ref : GardenRefNode ,
218226 supergarden : SupergardenNode ,
219227 subgarden : SubgardenNode ,
220- default : ( { data } : { data : any } ) => (
228+ default : ( { data } : { data : NodeData } ) => (
221229 < >
222230 < Handle type = "source" position = { Position . Top } />
223231 < Handle type = "source" position = { Position . Bottom } />
0 commit comments