import { Button, Gridicon } from '@automattic/components'; import clsx from 'clsx'; import PropTypes from 'prop-types'; import { Component } from 'react'; import { LiveProvider, LiveEditor, LiveError, LivePreview } from 'react-live'; import ClipboardButton from 'calypso/components/forms/clipboard-button'; import DocsExampleWrapper from 'calypso/devdocs/docs-example/wrapper'; class ComponentPlayground extends Component { static propTypes = { code: PropTypes.string, }; state = { showCode: false, }; handleClick() { alert( 'Copied to clipboard!' ); } showCode = () => { this.setState( { showCode: ! this.state.showCode, } ); }; render() { const toggleCode = this.props.code.length > 200; const codeClassName = clsx( { 'design__component-playground-code': true, 'show-code': toggleCode ? this.state.showCode : true, } ); const scope = require( 'calypso/devdocs/design/playground-scope' ); return ( { this.props.component && (
) } { this.props.component && toggleCode && (
) }
); } } ComponentPlayground.displayName = 'ComponentPlayground'; export default ComponentPlayground;