1- import { useState } from "react" ;
1+ import { useCallback , useEffect , useState } from "react" ;
22import { twMerge } from "tailwind-merge" ;
3+ import { FaWindows , FaApple , FaLinux } from "react-icons/fa" ;
34
45const EngineCompatibility = ( ) => {
56 const [ Compatibility , setCompatibility ] = useState ( {
@@ -17,14 +18,17 @@ const EngineCompatibility = () => {
1718 {
1819 name : "Windows" ,
1920 value : "win" ,
21+ logo : FaWindows ,
2022 } ,
2123 {
2224 name : "Mac" ,
2325 value : "mac" ,
26+ logo : FaApple ,
2427 } ,
2528 {
2629 name : "Linux" ,
2730 value : "linux" ,
31+ logo : FaLinux ,
2832 } ,
2933 ] ,
3034 } ,
@@ -62,7 +66,7 @@ const EngineCompatibility = () => {
6266 {
6367 name : "Apple Metal" ,
6468 value : "apple" ,
65- disabled : Compatibility . os !== "mac" ,
69+ disabled : Compatibility . os !== "mac" || Compatibility . cpu === "amd" ,
6670 } ,
6771 {
6872 name : "Snapdragon NPU" ,
@@ -127,6 +131,8 @@ const EngineCompatibility = () => {
127131 } ,
128132 ] ;
129133
134+ // console.log(Compatibility);
135+
130136 const handleClick = ( level : string , value : string , disabled : boolean ) => {
131137 if ( disabled ) return ;
132138 setCompatibility ( ( prev ) => {
@@ -147,7 +153,6 @@ const EngineCompatibility = () => {
147153 return updatedCompatibility ;
148154 } ) ;
149155 } ;
150-
151156 const isPreviousLevelSelected = ( index : number ) => {
152157 if ( index === 0 ) return true ; // The first level (OS) is always enabled
153158 if ( index === 3 ) return ! ! Compatibility . cpu ; // Enable Engine if CPU is selected
@@ -165,32 +170,50 @@ const EngineCompatibility = () => {
165170 return "cortex run llama3:onnx / llama3:tensorrt-llm / llama3:gguf" ;
166171 } ;
167172
173+ useEffect ( ( ) => {
174+ return ( ) => {
175+ console . log ( Compatibility ) ;
176+ // if (Compatibility.os === "mac") {
177+ // console.log(Compatibility);
178+ // setCompatibility({
179+ // ...Compatibility,
180+ // accelerator: "apple",
181+ // engine: "llama",
182+ // format: "gguf",
183+ // });
184+ // }
185+ } ;
186+ } , [ Compatibility ] ) ;
187+
168188 return (
169189 < div >
170190 { levels . map ( ( level , i ) => (
171191 < div key = { i } className = "flex justify-between items-center gap-4" >
172192 < h5 className = "mb-0" > { level . name } </ h5 >
173193 < div className = "flex w-3/4 gap-4" >
174- { level . child . map ( ( c ) => (
175- < div
176- key = { c . value }
177- className = { twMerge (
178- `border border-neutral-200 border-solid text-black p-4 my-2 rounded-lg cursor-pointer` ,
179- Compatibility [ level . name . toLowerCase ( ) ] === c . value
180- ? "bg-neutral-900 text-white"
181- : isPreviousLevelSelected ( i )
182- ? ""
183- : "opacity-50 bg-neutral-100 cursor-not-allowed" ,
184- c ?. disabled && "bg-neutral-100 cursor-not-allowed"
185- ) }
186- onClick = { ( ) =>
187- isPreviousLevelSelected ( i ) &&
188- handleClick ( level . name . toLowerCase ( ) , c . value , c . disabled )
189- }
190- >
191- { c . name }
192- </ div >
193- ) ) }
194+ { level . child . map ( ( c ) => {
195+ return (
196+ < div
197+ key = { c . value }
198+ className = { twMerge (
199+ `border border-neutral-200 border-solid text-black p-4 my-2 rounded-lg cursor-pointer flex items-center` ,
200+ Compatibility [ level . name . toLowerCase ( ) ] === c . value
201+ ? "bg-neutral-900 text-white"
202+ : isPreviousLevelSelected ( i )
203+ ? ""
204+ : "opacity-50 bg-neutral-100 cursor-not-allowed" ,
205+ c ?. disabled && "bg-neutral-100 cursor-not-allowed"
206+ ) }
207+ onClick = { ( ) =>
208+ isPreviousLevelSelected ( i ) &&
209+ handleClick ( level . name . toLowerCase ( ) , c . value , c . disabled )
210+ }
211+ >
212+ { c . logo && < c . logo className = "h-4 mr-2" /> }
213+ { c . name }
214+ </ div >
215+ ) ;
216+ } ) }
194217 </ div >
195218 </ div >
196219 ) ) }
0 commit comments