From 14a8110b5d66c7baa5ecf8ea3e46fdda544c9275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Sun, 31 Mar 2019 22:37:04 +0200 Subject: [PATCH] imp: add split editor mode to playground --- playground.css | 18 ++++++++++++++++++ src/app.js | 32 ++++++++++++++++++++++++-------- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/playground.css b/playground.css index 4dca11ed..66365464 100644 --- a/playground.css +++ b/playground.css @@ -28,6 +28,10 @@ body { background-color: #2f3129; } +.left-bar.split { + grid-template-rows: 50px auto 23px auto; +} + .menubar { background-color: #1c2128; color: white; @@ -52,6 +56,20 @@ body { border-bottom: 2px solid gray; } +.layout-selector { + font-size: 33px; + padding: 0px 3px; + margin-right: 17px; + cursor: pointer; + margin: 8px; + color: #cccccc; + transform: rotate(90deg); +} + +.layout-selector.active { + font-weight: bold; + color: white; +} /* TABBED EDITOR ****************************************/ .tabBar { diff --git a/src/app.js b/src/app.js index aed03879..62a46276 100644 --- a/src/app.js +++ b/src/app.js @@ -17,9 +17,9 @@ const DEFAULT_XML = ` const EDITOR_TEMPLATE = `
- JS - XML - CSS + JS + XML + CSS
`; @@ -29,7 +29,12 @@ class TabbedEditor extends Component { super(...arguments); this.inlineTemplate = EDITOR_TEMPLATE; this.state = { - currentTab: "js" + currentTab: this.props.display.split("|")[0] + }; + this.tabs = { + js: this.props.display.includes("js"), + xml: this.props.display.includes("xml"), + css: this.props.display.includes("css") }; } @@ -38,7 +43,7 @@ class TabbedEditor extends Component { // remove this for xml/css (?) this.editor.session.setOption("useWorker", false); - this.editor.setValue(this.props.js, -1); + this.editor.setValue(this.props[this.state.currentTab], -1); this.editor.setFontSize("14px"); this.editor.setTheme("ace/theme/monokai"); this.editor.session.setMode("ace/mode/javascript"); @@ -82,7 +87,7 @@ class TabbedEditor extends Component { const TEMPLATE = `
-
+
- + + + + + +
+ +
@@ -117,12 +130,12 @@ class App extends Component { this.widgets = { TabbedEditor }; this.state = { - currentTab: "js", js: SAMPLES[0].code, css: SAMPLES[0].css || "", xml: SAMPLES[0].xml || DEFAULT_XML, error: false, displayWelcome: true, + splitLayout: false, leftPaneWidth: Math.ceil(window.innerWidth / 2) }; } @@ -209,6 +222,9 @@ class App extends Component { updateCode(ev) { this.state[ev.type] = ev.value; } + toggleLayout() { + this.updateState({ splitLayout: !this.state.splitLayout }); + } } //------------------------------------------------------------------------------