Layout changes

This commit is contained in:
2019-10-04 15:28:49 -05:00
parent 71aff1405c
commit 38825f970a
3 changed files with 33 additions and 29 deletions

View File

@@ -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",

View File

@@ -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,

View File

@@ -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 <GridComponent
row={row}
col={col}
rowSpan={rowSpan}
colSpan={colSpan}
key={'gc_' + i}>{child}</GridComponent>;
return (
<GridComponent row={row}
col={col}
rowSpan={rowSpan}
colSpan={colSpan}
key={'gc_' + i}>
{child}
</GridComponent>
);
} 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 (
<div
ref='GridOwner'
@@ -125,5 +129,5 @@ export default class extends Component {
</div>
</div>
)
};
}
};