MCPcopy Create free account
hub / github.com/DavidHDev/react-bits / buildPrompt

Function buildPrompt

src/components/common/TabsLayout.jsx:63–118  ·  view source on GitHub ↗
(componentName, codeObject, propData, lang, style)

Source from the content-addressed store, hash-verified

61}
62
63function 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
70You 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
1111. Install any listed dependencies.
1122. 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
120const TabsLayout = ({ children, className }) => {

Callers 1

TabsLayoutFunction · 0.85

Calls 1

getActiveCodeFunction · 0.85

Tested by

no test coverage detected