|
| 1 | +import React from 'react'; |
| 2 | +import Tabs from '@theme/Tabs'; |
| 3 | +import TabItem from '@theme/TabItem'; |
| 4 | +import { SDK_LANGUAGES, LANGUAGE_TAB_GROUP } from '@site/src/constants/sdkLanguages'; |
| 5 | + |
| 6 | +// Named components for language-specific slots |
| 7 | +export const Go = ({ children }) => children; |
| 8 | +Go.displayName = 'go'; |
| 9 | + |
| 10 | +export const Java = ({ children }) => children; |
| 11 | +Java.displayName = 'java'; |
| 12 | + |
| 13 | +export const Python = ({ children }) => children; |
| 14 | +Python.displayName = 'py'; |
| 15 | + |
| 16 | +export const TypeScript = ({ children }) => children; |
| 17 | +TypeScript.displayName = 'ts'; |
| 18 | + |
| 19 | +export const PHP = ({ children }) => children; |
| 20 | +PHP.displayName = 'php'; |
| 21 | + |
| 22 | +export const DotNet = ({ children }) => children; |
| 23 | +DotNet.displayName = 'dotnet'; |
| 24 | + |
| 25 | +export const Ruby = ({ children }) => children; |
| 26 | +Ruby.displayName = 'rb'; |
| 27 | + |
| 28 | +// Main wrapper |
| 29 | +const SdkTabs = ({ children }) => { |
| 30 | + const contentMap = {}; |
| 31 | + |
| 32 | + React.Children.forEach(children, (child) => { |
| 33 | + if (child?.type?.displayName) { |
| 34 | + const langKey = child.type.displayName.toLowerCase(); |
| 35 | + contentMap[langKey] = child; |
| 36 | + } |
| 37 | + }); |
| 38 | + |
| 39 | + return ( |
| 40 | + <Tabs groupId={LANGUAGE_TAB_GROUP}> |
| 41 | + {SDK_LANGUAGES.map(({ key, icon: Icon, label }) => ( |
| 42 | + <TabItem key={key} value={key} label={<Icon title={label} />}> |
| 43 | + {contentMap[key] || ( |
| 44 | + <div style={{ backgroundColor: '#ffffcc', padding: '1rem', borderRadius: '6px' }}> |
| 45 | + <strong>{label}</strong> example coming soon. |
| 46 | + </div> |
| 47 | + )} |
| 48 | + </TabItem> |
| 49 | + ))} |
| 50 | + </Tabs> |
| 51 | + ); |
| 52 | +}; |
| 53 | + |
| 54 | +SdkTabs.Go = ({ children }) => children; |
| 55 | +SdkTabs.Go.displayName = 'go'; |
| 56 | + |
| 57 | +SdkTabs.Java = ({ children }) => children; |
| 58 | +SdkTabs.Java.displayName = 'java'; |
| 59 | + |
| 60 | +SdkTabs.Python = ({ children }) => children; |
| 61 | +SdkTabs.Python.displayName = 'py'; |
| 62 | + |
| 63 | +SdkTabs.TypeScript = ({ children }) => children; |
| 64 | +SdkTabs.TypeScript.displayName = 'ts'; |
| 65 | + |
| 66 | +SdkTabs.PHP = ({ children }) => children; |
| 67 | +SdkTabs.PHP.displayName = 'php'; |
| 68 | + |
| 69 | +SdkTabs.DotNet = ({ children }) => children; |
| 70 | +SdkTabs.DotNet.displayName = 'dotnet'; |
| 71 | + |
| 72 | +SdkTabs.Ruby = ({ children }) => children; |
| 73 | +SdkTabs.Ruby.displayName = 'rb'; |
| 74 | + |
| 75 | +export default SdkTabs; |
0 commit comments