diff --git a/playground.css b/playground.css index e45b89e2..8b61e09b 100644 --- a/playground.css +++ b/playground.css @@ -23,8 +23,8 @@ body { /* LEFT BAR ****************************************/ .left-bar { - display: grid; - grid-template-rows: 50px auto; + display: flex; + flex-direction: column; background-color: #2f3129; } @@ -37,6 +37,7 @@ body { color: white; font-size: 18px; display: flex; + flex: 0 0 50px; flex-direction: row-reverse; align-items: center; } @@ -72,11 +73,25 @@ body { } /* TABBED EDITOR ****************************************/ +.tabbed-editor { + flex: 2 2 auto; + position: relative; +} + +.separator.horizontal + .tabbed-editor { + flex: 1 1 auto; +} + .tabBar { color: white; height: 22px; margin-top: -22px; padding-left: 5px; + user-select: none; +} + +.tabBar.resizeable { + cursor: row-resize; } .tab { @@ -87,16 +102,13 @@ body { line-height: 20px; width: 34px; text-align: center; + border-bottom: 2px solid transparent; } .tab.active { border-bottom: 2px solid gray; } -.tab:hover { - font-weight: bold; -} - .code-editor { margin-top: 8px; height: calc(100% - 10px); @@ -109,6 +121,10 @@ body { cursor: col-resize; } +.separator.horizontal { + height: 20px; +} + /* RIGHT PANE ****************************************/ .right-pane { background-color: lightgray; diff --git a/src/app.js b/src/app.js index 17005618..c736d524 100644 --- a/src/app.js +++ b/src/app.js @@ -15,8 +15,8 @@ const DEFAULT_XML = ` // Tabbed editor //------------------------------------------------------------------------------ const EDITOR_TEMPLATE = ` -
-
+
+
JS XML CSS @@ -79,6 +79,32 @@ class TabbedEditor extends Component { this.editor.session.setMode(mode); this.updateState({ currentTab: tab }); } + + onMouseDown(ev) { + if (ev.target.tagName === "DIV") { + let y = ev.clientY; + const resizer = ev => { + const delta = ev.clientY - y; + y = ev.clientY; + this.trigger("updatePanelHeight", { delta }); + }; + document.body.addEventListener("mousemove", resizer); + document.body.addEventListener("mouseup", () => { + document.body.removeEventListener("mousemove", resizer); + }); + } + // document.body.addEventListener("mousemove", resizer); + // for (let iframe of document.getElementsByTagName("iframe")) { + // iframe.classList.add("disabled"); + // } + + // document.body.addEventListener("mouseup", () => { + // document.body.removeEventListener("mousemove", resizer); + // for (let iframe of document.getElementsByTagName("iframe")) { + // iframe.classList.remove("disabled"); + // } + // }); + } } //------------------------------------------------------------------------------ @@ -101,12 +127,12 @@ const TEMPLATE = ` - -
- + +
+
-
+
🦉 Odoo Web Lab 🦉
@@ -136,7 +162,8 @@ class App extends Component { error: false, displayWelcome: true, splitLayout: true, - leftPaneWidth: Math.ceil(window.innerWidth / 2) + leftPaneWidth: Math.ceil(window.innerWidth / 2), + topPanelHeight: null }; } @@ -202,7 +229,11 @@ class App extends Component { return `width:${window.innerWidth - 6 - this.state.leftPaneWidth}px`; } - onMouseDown(ev) { + get topEditorStyle() { + return `flex: 0 0 ${this.state.topPanelHeight}px`; + } + + onMouseDown() { const resizer = ev => { this.updateState({ leftPaneWidth: ev.clientX }); }; @@ -225,6 +256,16 @@ class App extends Component { toggleLayout() { this.updateState({ splitLayout: !this.state.splitLayout }); } + updatePanelHeight(ev) { + if (!ev.delta) { + return; + } + let height = this.state.topPanelHeight; + if (!height) { + height = document.getElementsByClassName("tabbed-editor")[0].clientHeight; + } + this.updateState({ topPanelHeight: height + ev.delta }); + } } //------------------------------------------------------------------------------