Skip to content

Fix/size #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 15, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
width/height listener
  • Loading branch information
ShMcK committed Jul 15, 2019
commit 7a07a4d9f7177b44a91550f54274e0f317d7d984
26 changes: 20 additions & 6 deletions web-app/src/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,33 @@ interface Props {
const styles = {
page: {
margin: 0,
width: window.innerWidth - 20, // 220
height: window.innerHeight - 20, // 655
backgroundColor: 'white',
},
}

console.log('page styles')
console.log(JSON.stringify(styles.page))

const Routes = ({ state }: Props) => {
const [dimensions, setDimensions] = React.useState({
width: window.innerWidth - 20,
height: window.innerHeight - 20,
})

// solution for windows getting off size
// without adding multiple listeners
React.useEffect(() => {
const dimensionsInterval = setInterval(() => {
setDimensions({
width: window.innerWidth - 20,
height: window.innerHeight - 20,
})
}, 5000)
return () => {
clearInterval(dimensionsInterval)
}
})

// TODO: refactor cond to user <Router><Route> and accept first route as if/else if
return (
<div style={styles.page}>
<div style={{ ...styles.page, ...dimensions }}>
<Cond state={state} path="SelectTutorial.Startup">
<Loading />
</Cond>
Expand Down