diff --git a/website/src/components/Playground/index.js b/website/src/components/Playground/index.js index f0ff16e3..35b0b47d 100644 --- a/website/src/components/Playground/index.js +++ b/website/src/components/Playground/index.js @@ -18,7 +18,7 @@ import {List, setIn} from 'immutable'; import PositionRecord from './PositionRecord'; import LayoutRecord from './LayoutRecord'; import Sidebar from './Sidebar'; -import {Row, Col} from 'antd'; +import {Row, Col, Button} from 'antd'; import type {LayoutRecordT} from './LayoutRecord'; import type {Yoga$Direction} from 'yoga-layout'; import './index.css'; @@ -154,7 +154,7 @@ export default class Playground extends Component { modifyAtPath( path: Array, value: any, - selectedNodePath?: ?Array = this.state.selectedNodePath, + selectedNodePath?: ?Array = this.state.selectedNodePath ) { // $FlowFixMe const layoutDefinition = setIn(this.state.layoutDefinition, path, value); @@ -164,12 +164,15 @@ export default class Playground extends Component { }); if (this.props.persist) { - window.location.hash = btoa( - JSON.stringify(this.removeUnchangedProperties(layoutDefinition)), - ); + window.location.hash = this.getHash(layoutDefinition); } } + getHash = ( + layoutDefinition: LayoutRecordT = this.state.layoutDefinition + ): string => + btoa(JSON.stringify(this.removeUnchangedProperties(layoutDefinition))); + removeUnchangedProperties = (node: LayoutRecordT): Object => { const untouchedLayout = LayoutRecord({}); const untouchedPosition = PositionRecord({}); @@ -203,7 +206,7 @@ export default class Playground extends Component { this.state.selectedNodePath || [] ).reduce( (node: LayoutRecordT, cv) => node.children.get(cv), - this.state.layoutDefinition, + this.state.layoutDefinition ); return selectedNode ? selectedNode.children.size : 0; }; @@ -223,7 +226,8 @@ export default class Playground extends Component { style={{height, maxHeight: height}} ref={ref => { this._containerRef = ref; - }}> + }} + > { /> - + {this.props.persist ? ( + + ) : ( + + )} @@ -284,7 +297,7 @@ export default class Playground extends Component {
{this.props.renderSidebar( layoutDefinition.getIn(getPath(selectedNodePath)), - this.onChangeLayout, + this.onChangeLayout )}
{playground}