@@ -25,18 +25,85 @@ export default function SDKSelector({ disabledPlatforms }: SDKSelectorProps) {
2525 label : "Mobile" ,
2626 id : "mobile" ,
2727 } ,
28+ {
29+ label : "React" ,
30+ id : "web-react" ,
31+ } ,
32+ {
33+ label : "Web Components" ,
34+ id : "web-components" ,
35+ } ,
36+ {
37+ label : "Angular" ,
38+ id : "web-angular" ,
39+ } ,
40+ {
41+ label : "Android" ,
42+ id : "mobile-android" ,
43+ } ,
44+ {
45+ label : "iOS" ,
46+ id : "mobile-ios" ,
47+ } ,
48+ {
49+ label : "Flutter" ,
50+ id : "mobile-flutter" ,
51+ } ,
52+ {
53+ label : "React Native" ,
54+ id : "mobile-react-native" ,
55+ } ,
2856 ] ;
2957
58+ const mainPlatforms = platforms . filter (
59+ ( p ) => p . id === "web" || p . id === "mobile" ,
60+ ) ;
61+
62+ const frameworkToPlatform : Record < string , Platform > = {
63+ react : "web-react" ,
64+ "web-components" : "web-components" ,
65+ angular : "web-angular" ,
66+ android : "mobile-android" ,
67+ ios : "mobile-ios" ,
68+ flutter : "mobile-flutter" ,
69+ "react-native" : "mobile-react-native" ,
70+ } ;
71+
3072 const frameworks = useMemo (
3173 ( ) => ( platform === "web" ? webFrameworks : mobileFrameworks ) ,
3274 [ platform ] ,
3375 ) ;
3476
3577 const isPlatformDisabled = ( p : Platform ) =>
3678 Boolean ( disabledPlatforms ?. includes ( p ) ) ;
37- const activePlatformDisabled = isPlatformDisabled ( platform ) ;
3879
39- const disabledPlatformsString = disabledPlatforms ?. join ( ", " ) ;
80+ const isFrameworkDisabled = ( fw : { id : string ; label : string } ) => {
81+ const subPlatform = frameworkToPlatform [ fw . id ] ;
82+ return subPlatform ? isPlatformDisabled ( subPlatform ) : false ;
83+ } ;
84+
85+ const isWebPlatformDisabled = ( ) => {
86+ if ( isPlatformDisabled ( "web" ) ) return true ;
87+
88+ const allWebDisabled = webFrameworks . every ( ( fw ) => isFrameworkDisabled ( fw ) ) ;
89+ return allWebDisabled ;
90+ } ;
91+
92+ const isMobilePlatformDisabled = ( ) => {
93+ if ( isPlatformDisabled ( "mobile" ) ) return true ;
94+
95+ const allMobileDisabled = mobileFrameworks . every ( ( fw ) =>
96+ isFrameworkDisabled ( fw ) ,
97+ ) ;
98+ return allMobileDisabled ;
99+ } ;
100+
101+ const activePlatformDisabled =
102+ platform === "web" ? isWebPlatformDisabled ( ) : isMobilePlatformDisabled ( ) ;
103+
104+ const disabledPlatformsString = disabledPlatforms
105+ ?. map ( ( p ) => platforms . find ( ( platform ) => platform . id === p ) ?. label || p )
106+ . join ( ", " ) ;
40107
41108 return (
42109 < >
@@ -48,8 +115,13 @@ export default function SDKSelector({ disabledPlatforms }: SDKSelectorProps) {
48115 ) }
49116 < div className = "my-5 flex flex-col gap-0 rounded-md bg-blue-100 p-2 dark:bg-neutral-800" >
50117 < div className = "flex w-full flex-row items-start justify-start gap-2" >
51- { platforms . map ( ( p ) => {
52- const disabled = isPlatformDisabled ( p . id ) ;
118+ { mainPlatforms . map ( ( p ) => {
119+ const disabled =
120+ p . id === "web"
121+ ? isWebPlatformDisabled ( )
122+ : p . id === "mobile"
123+ ? isMobilePlatformDisabled ( )
124+ : isPlatformDisabled ( p . id ) ;
53125
54126 return (
55127 < button
@@ -86,15 +158,18 @@ export default function SDKSelector({ disabledPlatforms }: SDKSelectorProps) {
86158 { ! activePlatformDisabled && (
87159 < div className = "m-0 flex w-full flex-row items-center gap-2 rounded-r-md rounded-b-md bg-neutral-50 p-2 text-gray-500 dark:bg-neutral-700 dark:text-gray-400" >
88160 { frameworks . map ( ( fw ) => {
161+ const disabled = isFrameworkDisabled ( fw ) ;
89162 const handleClick = ( ) => {
163+ if ( disabled ) return ;
90164 setSelection ( platform , fw ) ;
91165 } ;
92166
93167 return (
94168 < button
95169 key = { fw . id }
96170 type = "button"
97- className = { `m-0 flex ${ framework ?. id === fw . id ? "text-blue-500 italic" : "" } text-md cursor-pointer items-center rounded-md bg-neutral-50 px-3 py-1 font-medium dark:bg-neutral-700` }
171+ disabled = { disabled }
172+ className = { `m-0 flex ${ framework ?. id === fw . id ? "text-blue-500 italic" : "" } ${ disabled ? "cursor-not-allowed opacity-50" : "cursor-pointer" } text-md items-center rounded-md bg-neutral-50 px-3 py-1 font-medium dark:bg-neutral-700` }
98173 onClick = { handleClick }
99174 >
100175 { fw . label }
0 commit comments