const React = require('react') const ReactDOM = require('react-dom') const { Prism } = require('react-syntax-highlighter') const { dark } = require('react-syntax-highlighter/dist/cjs/styles/prism') const { Tab, Tabs, TabList, TabPanel } = require('react-tabs') const CodeBlock = (props) => { let jsPanel let jsTab let phpPanel let phpTab let pythonPanel let pythonTab if (props.js) { jsPanel = ( {props.js} ) jsTab = Javascript } if (props.php) { phpPanel = ( {props.php} ) phpTab = PHP } if (props.python) { pythonPanel = ( {props.python} ) pythonTab = Python } return (
{jsTab} {phpTab} {pythonTab} {jsPanel} {phpPanel} {pythonPanel}
) } module.exports = CodeBlock if (typeof window === 'undefined') { } else { const componentContainers = document.querySelectorAll('.react-component-CodeBlock') for (const componentContainer of componentContainers) { const div = componentContainer.children[0] const js = div.getAttribute('js') const php = div.getAttribute('php') const python = div.getAttribute('python') ReactDOM.hydrate(React.createElement(CodeBlock, { js: js, php: php, python: python }), componentContainer) } }