reactbits-mcp-tools
Version:
Model Context Protocol server for ReactBits component library with comprehensive TypeScript build system and real data integration
46 lines • 2.63 kB
JSON
{
"metadata": {
"name": "Utils",
"category": "ui-component",
"variant": "js-css",
"priority": 1,
"extractedAt": "2025-08-01T16:33:29.415Z"
},
"source": {
"filePath": "src/utils/utils.js",
"sourceCode": "export const getLanguage = (key) => {\n const languages = {\n code: 'jsx',\n usage: 'jsx',\n tailwind: 'jsx',\n presets: 'jsx',\n utility: 'jsx',\n installation: 'bash',\n css: 'css',\n };\n\n return languages[key];\n};\n\nconst formatNumber = (num) => {\n if (num < 1000) return num.toString();\n\n const rounded = Math.ceil(num / 100) * 100;\n return new Intl.NumberFormat('en', { notation: 'compact', maximumFractionDigits: 1 }).format(rounded);\n};\n\nexport const getStarsCount = async () => {\n try {\n const response = await fetch('https://api.github.com/repos/DavidHDev/react-bits');\n const data = await response.json();\n return String(formatNumber(data.stargazers_count)).toUpperCase();\n } catch (error) {\n console.error('Error fetching stargazers count:', error);\n return null;\n }\n};\n\nexport const decodeLabel = (label) => label\n .split('-')\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n .join(' ');\n\nexport const forceChakraDarkTheme = () => {\n localStorage.setItem('chakra-ui-color-mode', 'dark');\n console.info('Successfully set dark color mode.');\n};\n\nexport const randomHex = () => `#${Math.floor(Math.random() * 0xffffff).toString(16).padStart(6, '0')}`;\n\nexport const generateCliCommands = (path, variants = ['default', 'tailwind', 'ts/default', 'ts/tailwind']) => {\n const [category, component] = path.split('/');\n\n return Object.fromEntries(\n variants.map(variant => {\n const formattedKey = `cli${variant\n .split('/')\n .map(word => word.charAt(0).toUpperCase() + word.slice(1))\n .join('')}`;\n\n return [formattedKey, `npx jsrepo add https://reactbits.dev/${variant}/${category}/${component}`];\n })\n );\n};",
"fileSize": 1706
},
"analysis": {
"dependencies": [],
"exports": [
"getLanguage",
"getStarsCount",
"decodeLabel",
"forceChakraDarkTheme",
"randomHex",
"generateCliCommands"
],
"imports": [],
"hooks": [],
"features": [],
"complexity": {
"level": "simple",
"score": 7,
"metrics": {
"lines": 58,
"dependencies": 0,
"hooks": 0,
"conditionals": 1
}
},
"stylingApproach": [
"tailwind"
],
"hasAnimation": false
},
"types": {
"definitions": [],
"propsInterface": []
}
}