import React, { useState } from 'react' import SvgWrapper from './svg-wrapper' import Error from './error.js' import Events from './events.js' import Json from 'shared/components/json.js' import Yaml from 'shared/components/yaml.js' import { capitalize } from 'shared/utils.js' import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch" const tabClasses = active => ` tab tab-bordered font-bold text-4xl pb-12 capitalize ${active && 'text-base-content tab-active'} ` const Wrap = props =>
{props.children}
const LabDraft = props => { const { app, draft, pattern, gist, updateGist, unsetGist } = props if (!draft) return null const [tab, setTab] = useState(props.pattern.config.name) if (gist?.renderer === 'svg') { // Render as SVG let svg try { svg = draft.render() } catch(error) { console.log('Failed to render pattern', error) return } return
} // Render as React let patternProps = {} try { patternProps = draft.draft().getRenderProps() } catch(error) { console.log('Failed to get render props for pattern', error) return } return (
{[props.pattern.config.name, 'events', 'yaml', 'json'].map(name => )}
{tab === 'events' && } {tab === 'json' && {JSON.stringify(props.gist, null, 2)}} {tab === 'yaml' && } {tab === props.pattern.config.name && }
) } export default LabDraft