From 2172ed95bf5dbb3a27faa69ae8fdef7b65b89d72 Mon Sep 17 00:00:00 2001 From: Lucas Duailibe Date: Tue, 17 Apr 2018 16:09:37 -0300 Subject: [PATCH] refactor & fixes --- website/playground/BottomBar.js | 14 +++++++++++ website/playground/Playground.js | 12 +++------ website/playground/PrettierFormat.js | 37 ++++++++++------------------ website/playground/helpers.js | 2 +- website/playground/index.js | 6 ++++- 5 files changed, 37 insertions(+), 34 deletions(-) create mode 100644 website/playground/BottomBar.js diff --git a/website/playground/BottomBar.js b/website/playground/BottomBar.js new file mode 100644 index 00000000..52219bbf --- /dev/null +++ b/website/playground/BottomBar.js @@ -0,0 +1,14 @@ +import React from "react"; +import ReactDOM from "react-dom"; + +const root = document.getElementById("bottom-bar"); + +export default function({ left, right }) { + return ReactDOM.createPortal( + +
{left}
+
{right}
+
, + root + ); +} diff --git a/website/playground/Playground.js b/website/playground/Playground.js index a7e5c5ee..195351a4 100644 --- a/website/playground/Playground.js +++ b/website/playground/Playground.js @@ -14,8 +14,6 @@ import SidebarOptions from "./sidebar/SidebarOptions"; import Option from "./sidebar/options"; import { Checkbox } from "./sidebar/inputs"; -import WorkerApi from "./WorkerApi"; - const CATEGORIES_ORDER = ["Global", "JavaScript", "Markdown", "Special"]; const ENABLED_OPTIONS = [ @@ -58,9 +56,7 @@ class Playground extends React.Component { } componentDidMount() { - this._worker = new WorkerApi("/worker.js"); - - this._worker + this.props.worker .postMessage({ type: "meta" }) .then(({ supportInfo, version }) => { const availableOptions = parsePrettierOptions(supportInfo); @@ -119,7 +115,7 @@ class Playground extends React.Component { {editorState => ( {editorState.showAst ? ( - + ) : null} {editorState.showDoc ? ( - + ) : null} this.setState(result)); } diff --git a/website/playground/helpers.js b/website/playground/helpers.js index 520f0dff..f36930bb 100644 --- a/website/playground/helpers.js +++ b/website/playground/helpers.js @@ -33,7 +33,7 @@ export function shallowEqual(objA, objB) { if (keysA.length !== keysB.length) return false; - for (let i = 0; i <= keysA.length; i++) { + for (let i = 0; i < keysA.length; i++) { if ( !hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]]) diff --git a/website/playground/index.js b/website/playground/index.js index a9e720cb..0ad806a6 100644 --- a/website/playground/index.js +++ b/website/playground/index.js @@ -4,5 +4,9 @@ import React from "react"; import ReactDOM from "react-dom"; import Playground from "./Playground"; +import WorkerApi from "./WorkerApi"; -ReactDOM.render(, document.getElementById("root")); +ReactDOM.render( + , + document.getElementById("root") +);