(componentName, codeObject, propData, lang, style)
| 61 | } |
| 62 | |
| 63 | function buildPrompt(componentName, codeObject, propData, lang, style) { |
| 64 | const { source, label, css } = getActiveCode(codeObject, lang, style); |
| 65 | const usage = codeObject.usage || ''; |
| 66 | const deps = codeObject.dependencies || ''; |
| 67 | |
| 68 | let prompt = `## Integrate the <${componentName} /> component from React Bits |
| 69 | |
| 70 | You are helping integrate an open-source React component into an existing application. |
| 71 | |
| 72 | ### Component: ${componentName} |
| 73 | ### Variant: ${label} |
| 74 | ${deps ? `### Dependencies: ${deps}` : ''} |
| 75 | |
| 76 | --- |
| 77 | |
| 78 | ### Usage Example |
| 79 | \`\`\`jsx |
| 80 | ${usage} |
| 81 | \`\`\` |
| 82 | `; |
| 83 | |
| 84 | if (propData && propData.length > 0) { |
| 85 | prompt += ` |
| 86 | ### Props |
| 87 | | Prop | Type | Default | Description | |
| 88 | |------|------|---------|-------------| |
| 89 | ${propData.map(p => `| ${p.name} | ${p.type} | ${p.default || '—'} | ${p.description} |`).join('\n')} |
| 90 | `; |
| 91 | } |
| 92 | |
| 93 | prompt += ` |
| 94 | ### Full Component Source |
| 95 | \`\`\`${lang === 'TS' ? 'tsx' : 'jsx'} |
| 96 | ${source} |
| 97 | \`\`\` |
| 98 | `; |
| 99 | |
| 100 | if (css) { |
| 101 | prompt += ` |
| 102 | ### Component CSS |
| 103 | \`\`\`css |
| 104 | ${css} |
| 105 | \`\`\` |
| 106 | `; |
| 107 | } |
| 108 | |
| 109 | prompt += ` |
| 110 | ### Integration Instructions |
| 111 | 1. Install any listed dependencies. |
| 112 | 2. Copy the component source into the appropriate directory in the project. |
| 113 | ${css ? '3. Import the CSS file alongside the component.\n' : ''}${css ? '4' : '3'}. Import and render the component using the usage example above as a starting point. |
| 114 | ${css ? '5' : '4'}. Adjust props as needed for the specific use case — refer to the props table for all available options. |
| 115 | `; |
| 116 | |
| 117 | return prompt; |
| 118 | } |
| 119 | |
| 120 | const TabsLayout = ({ children, className }) => { |
no test coverage detected