8000 refactor out workspace dimensions · jordanliu/coderoad-vscode@0107b0d · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0107b0d

Browse files
committed
refactor out workspace dimensions
1 parent a0f7bce commit 0107b0d

File tree

2 files changed

+34
-28
lines changed

2 files changed

+34
-28
lines changed

web-app/src/Routes.tsx

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import * as React from 'react'
22
// import { editorDispatch } from './services/vscode'
33
import * as CR from 'typings'
4+
import Workspace from './components/Workspace'
5+
46
import Router from './components/Router'
57
import LoadingPage from './containers/LoadingPage'
68
import ContinuePage from './containers/Continue'
@@ -12,37 +14,11 @@ import CompletedPage from './containers/Tutorial/CompletedPage'
1214

1315
const { Route } = Router
1416

15-
const styles = {
16-
page: {
17-
margin: 0,
18-
backgroundColor: 'white',
19-
},
20-
}
21-
2217
const tempSend = (action: any) => console.log('sent')
2318

2419
const Routes = () => {
25-
// const [dimensions, setDimensions] = React.useState({
26-
// width: window.innerWidth - 20,
27-
// height: window.innerHeight - 20,
28-
// })
29-
30-
// // solution for windows getting off size
31-
// // without adding multiple listeners
32-
// React.useEffect(() => {
33-
// const dimensionsInterval = setInterval(() => {
34-
// setDimensions({
35-
// width: window.innerWidth - 20,
36-
// height: window.innerHeight - 20,
37-
// })
38-
// }, 5000)
39-
// return () => {
40-
// clearInterval(dimensionsInterval)
41-
// }
42-
// }, [])
43-
4420
return (
45-
<div style={{ ...styles.page }}>
21+
<Workspace>
4622
<Router>
4723
<Route path="Start.Startup">
4824
<LoadingPage text="Launching..." />
@@ -72,7 +48,7 @@ const Routes = () => {
7248
<CompletedPage send={tempSend} context={{} as CR.MachineContext} />
7349
</Route>
7450
</Router>
75-
</div>
51+
</Workspace>
7652
)
7753
}
7854

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import * as React from 'react'
2+
3+
interface Props {
4+
children: React.ReactElement
5+
}
6+
7+
const resize = () => ({
8+
width: window.innerWidth - 20,
9+
height: window.innerHeight - 20,
10+
})
11+
12+
const Workspace = ({ children }: Props) => {
13+
const [dimensions, setDimensions] = React.useState(resize())
14+
15+
// solution for windows getting off size
16+
React.useEffect(() => {
17+
setDimensions(resize())
18+
}, [window.innerHeight, window.innerHeight])
19+
20+
const styles = {
21+
page: {
22+
margin: 0,
23+
backgroundColor: 'white',
24+
},
25+
}
26+
27+
return <div style={{ ...styles.page, ...dimensions }}>{children}</div>
28+
}
29+
30+
export default Workspace

0 commit comments

Comments
 (0)
0