import page from '@automattic/calypso-router'; import { SelectDropdown } from '@automattic/components'; import clsx from 'clsx'; import { keys } from 'lodash'; import { Component } from 'react'; import { LiveProvider, LiveEditor, LiveError, LivePreview } from 'react-live'; import DocumentHead from 'calypso/components/data/document-head'; import Main from 'calypso/components/main'; import * as componentExamples from 'calypso/devdocs/design/component-examples'; import * as playgroundScope from 'calypso/devdocs/design/playground-scope'; import { getExampleCodeFromComponent } from './playground-utils'; import './playground.scss'; import './syntax.scss'; export default class DesignAssets extends Component { static displayName = 'DesignAssets'; state = { code: ` Welcome to the Playground Hello Published Drafts Scheduled Trashed Only Me Everyone {} } /> `, }; backToComponents = () => { page( '/devdocs/design/' ); }; addComponent = ( exampleCode ) => () => { this.setState( { code: '' + this.state.code.replace( /(^)/, '' ).replace( /(<\/Main>$)/, '' ) + '\n\t' + exampleCode + '\n', } ); }; handleChange = ( code ) => { this.setState( { code: code, } ); }; listOfExamples() { return ( { keys( componentExamples ).map( ( name ) => { // eslint-disable-next-line import/namespace const ExampleComponentName = componentExamples[ name ]; const exampleComponent = ; const exampleCode = getExampleCodeFromComponent( exampleComponent ); return ( exampleCode && ( { name } ) ); } ) } ); } render() { const className = clsx( 'devdocs', 'devdocs__components', { 'is-single': true, 'is-list': ! this.props.component, } ); return ( { this.listOfExamples() } ); } }