2018-02-12 09:28:31 -08:00
|
|
|
/**
|
2018-09-11 15:27:47 -07:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2018-02-12 09:28:31 -08:00
|
|
|
*
|
2018-02-16 18:24:55 -08:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2018-02-12 09:28:31 -08:00
|
|
|
*
|
|
|
|
* @flow
|
|
|
|
* @format
|
|
|
|
*/
|
|
|
|
|
2018-02-14 07:53:07 -08:00
|
|
|
import React, {Component} from 'react';
|
2018-02-12 09:28:31 -08:00
|
|
|
import Page from '../components/Page';
|
|
|
|
import Playground from '../components/Playground';
|
|
|
|
import DocsSidebar from '../components/DocsSidebar';
|
2018-02-12 10:25:02 -08:00
|
|
|
import EditValue from '../components/Playground/EditValue';
|
|
|
|
import Link from 'gatsby-link';
|
|
|
|
import {Button, Icon, Row, Col} from 'antd';
|
2018-02-13 03:50:40 -08:00
|
|
|
import './index.css';
|
2018-02-16 09:03:21 -08:00
|
|
|
import atob from 'atob';
|
2018-02-12 09:28:31 -08:00
|
|
|
|
2018-02-14 07:53:07 -08:00
|
|
|
type Props = {
|
|
|
|
pathContext: {
|
|
|
|
html: string,
|
2018-02-14 07:53:08 -08:00
|
|
|
frontmatter: {
|
|
|
|
initialPlayground?: string,
|
|
|
|
},
|
2018-02-14 07:53:07 -08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
const REGEX = /<controls prop="([A-Za-z]+)"\s?\/>/gi;
|
|
|
|
|
|
|
|
export default class withPlayground extends Component<Props> {
|
|
|
|
render() {
|
2018-02-14 07:53:08 -08:00
|
|
|
let layoutDefinition;
|
|
|
|
if (this.props.pathContext.frontmatter.initialPlayground) {
|
|
|
|
layoutDefinition = JSON.parse(
|
|
|
|
atob(this.props.pathContext.frontmatter.initialPlayground),
|
|
|
|
);
|
|
|
|
}
|
2018-02-14 07:53:07 -08:00
|
|
|
return (
|
2018-02-19 02:08:18 -08:00
|
|
|
<Page
|
|
|
|
className="doc-block playground"
|
|
|
|
title={this.props.pathContext.frontmatter.title}>
|
2018-02-14 07:53:07 -08:00
|
|
|
<Playground
|
2018-02-14 07:53:08 -08:00
|
|
|
layoutDefinition={layoutDefinition}
|
2018-02-14 07:53:07 -08:00
|
|
|
selectedNodePath={[]}
|
|
|
|
showGuides={false}
|
|
|
|
renderSidebar={(layout, onChange) => (
|
|
|
|
<DocsSidebar
|
|
|
|
layout={layout}
|
|
|
|
onChange={onChange}
|
|
|
|
markdown={this.props.pathContext.html}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</Page>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|