From 38825f970a9edf81ac4ca10cf44b9a8afd82b224 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Fri, 4 Oct 2019 15:28:49 -0500 Subject: [PATCH] Layout changes --- package.json | 4 +-- public/electron.js | 2 +- src/components/UI/Grid/Grid.js | 56 ++++++++++++++++++---------------- 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/package.json b/package.json index dd67fa2..6524113 100644 --- a/package.json +++ b/package.json @@ -39,8 +39,8 @@ "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject", - "electron-dev": "cross-env ELECTRON_START_URL=http://localhost:3000 electron .", - "electron-dev-unix": "cross-env ELECTRON_START_URL=http://localhost:3000 electron .", + "electron-dev": "cross-env ELECTRON_START_URL=http://localhost:3001 electron .", + "electron-dev-unix": "cross-env ELECTRON_START_URL=http://localhost:3001 electron .", "pack": "npm run build && electron-builder --dir --x64", "dist": "npm run build && electron-builder --x64", "dist-all": "npm run build && electron-builder --x64 --win --linux --mac", diff --git a/public/electron.js b/public/electron.js index 7c27f5d..ecbd338 100644 --- a/public/electron.js +++ b/public/electron.js @@ -77,7 +77,7 @@ const createWindow = () => { } // Create the browser window. - const height = (process.env.ELECTRON_START_URL || (os.platform() === 'darwin') ? 284 : 274) + ((os.platform() === 'win32') ? 30 : -20); + const height = (process.env.ELECTRON_START_URL || (os.platform() === 'darwin') ? 294 : 274) + ((os.platform() === 'win32') ? 30 : -20); mainWindow = new BrowserWindow({ width: 428 + ((os.platform() === 'win32') ? 40 : (os.platform() === 'darwin') ? 150 : 160), height: height, diff --git a/src/components/UI/Grid/Grid.js b/src/components/UI/Grid/Grid.js index 9782c45..2096e9a 100644 --- a/src/components/UI/Grid/Grid.js +++ b/src/components/UI/Grid/Grid.js @@ -3,8 +3,7 @@ import './Grid.css'; import GridComponent from './GridComponent/GridComponent'; export default class extends Component { - checkSizeInterval; - + resizeTimeout; state = { calculated: false, dimensions: { @@ -20,6 +19,16 @@ export default class extends Component { }; }; + componentDidMount() { + window.addEventListener('resize', this.handleResize); + this.updateSizeAsync(); + } + + componentWillUnmount() { + window.removeEventListener('resize', this.handleResize); + clearInterval(this.resizeTimeout); + }; + getSize = () => { const elem = this.refs.GridOwner; return { @@ -28,6 +37,11 @@ export default class extends Component { }; }; + handleResize = () => { + clearTimeout(this.resizeTimeout); + this.resizeTimeout = setTimeout(this.updateSizeAsync, 10); + }; + updateSize = () => { const state = { ...this.state @@ -43,25 +57,11 @@ export default class extends Component { }; updateSizeAsync = () => { - return new Promise((done) => { + return new Promise(() => { this.updateSize(); - done(); }); }; - componentDidMount() { - window.addEventListener("resize", this.updateSizeAsync); - this.checkSizeInterval = setInterval(()=> { - this.updateSize() - }, 2000); - this.updateSizeAsync(); - } - - componentWillUnmount() { - window.removeEventListener("resize", this.updateSizeAsync); - clearInterval(this.checkSizeInterval); - }; - render() { let children = null; const dimensions = this.state.dimensions; @@ -91,17 +91,19 @@ export default class extends Component { rowSpan = rowSpan ? (rowSpan === 'remain' ? (dimensions.rows - row) : rowSpan) : null; colSpan = colSpan ? (colSpan === 'remain' ? dimensions.columns - col : colSpan) : null; - return {child}; + return ( + + {child} + + ); } else { return null; } - }) - .filter(i => i !== null); + }); } let style = { @@ -112,10 +114,12 @@ export default class extends Component { gridAutoRows: '4px', } }; + if (this.props.noScroll) { style['style'].overflowX = 'visible'; style['style'].overflowY = 'visible'; } + return (
) - }; + } }; \ No newline at end of file