2021-05-29 10:12:28 +00:00
|
|
|
import useKeyboardEvents from 'hooks/useKeyboardEvents'
|
|
|
|
import useLoadOnMount from 'hooks/useLoadOnMount'
|
|
|
|
import Canvas from './canvas/canvas'
|
|
|
|
import StatusBar from './status-bar'
|
|
|
|
import CodePanel from './code-panel/code-panel'
|
|
|
|
import ControlsPanel from './controls-panel/controls-panel'
|
|
|
|
import ToolsPanel from './tools-panel/tools-panel'
|
|
|
|
import StylePanel from './style-panel/style-panel'
|
|
|
|
import { useSelector } from 'state'
|
|
|
|
import styled from 'styles'
|
2021-05-09 13:04:42 +00:00
|
|
|
|
|
|
|
export default function Editor() {
|
2021-05-12 11:27:33 +00:00
|
|
|
useKeyboardEvents()
|
2021-05-16 07:09:46 +00:00
|
|
|
useLoadOnMount()
|
2021-05-12 11:27:33 +00:00
|
|
|
|
2021-05-26 21:47:46 +00:00
|
|
|
const hasControls = useSelector(
|
|
|
|
(s) => Object.keys(s.data.codeControls).length > 0
|
|
|
|
)
|
|
|
|
|
2021-05-09 13:04:42 +00:00
|
|
|
return (
|
2021-05-17 10:01:11 +00:00
|
|
|
<Layout>
|
2021-05-29 10:12:28 +00:00
|
|
|
<Canvas />
|
2021-05-17 10:01:11 +00:00
|
|
|
<LeftPanels>
|
|
|
|
<CodePanel />
|
2021-05-26 21:47:46 +00:00
|
|
|
{hasControls && <ControlsPanel />}
|
2021-05-17 10:01:11 +00:00
|
|
|
</LeftPanels>
|
2021-05-26 10:34:10 +00:00
|
|
|
<RightPanels>
|
|
|
|
<StylePanel />
|
|
|
|
</RightPanels>
|
2021-05-29 10:12:28 +00:00
|
|
|
<ToolsPanel />
|
|
|
|
<StatusBar />
|
2021-05-17 10:01:11 +00:00
|
|
|
</Layout>
|
2021-05-09 13:04:42 +00:00
|
|
|
)
|
|
|
|
}
|
2021-05-17 10:01:11 +00:00
|
|
|
|
2021-06-01 21:49:32 +00:00
|
|
|
const Layout = styled('main', {
|
2021-05-29 10:12:28 +00:00
|
|
|
position: 'fixed',
|
2021-05-17 10:01:11 +00:00
|
|
|
top: 0,
|
|
|
|
left: 0,
|
|
|
|
bottom: 0,
|
|
|
|
right: 0,
|
2021-05-30 13:39:53 +00:00
|
|
|
height: '100%',
|
|
|
|
width: '100%',
|
2021-05-29 10:12:28 +00:00
|
|
|
display: 'grid',
|
2021-05-30 13:39:53 +00:00
|
|
|
gridTemplateRows: '1fr auto 144px',
|
|
|
|
gridTemplateColumns: 'minmax(0, 720px) 1fr auto',
|
2021-05-17 10:01:11 +00:00
|
|
|
gridTemplateAreas: `
|
2021-05-26 10:34:10 +00:00
|
|
|
"leftPanels main rightPanels"
|
2021-05-29 10:12:28 +00:00
|
|
|
"tools tools tools"
|
2021-05-26 10:34:10 +00:00
|
|
|
"statusbar statusbar statusbar"
|
2021-05-17 10:01:11 +00:00
|
|
|
`,
|
|
|
|
})
|
|
|
|
|
2021-06-01 21:49:32 +00:00
|
|
|
const LeftPanels = styled('div', {
|
2021-05-29 10:12:28 +00:00
|
|
|
display: 'grid',
|
|
|
|
gridArea: 'leftPanels',
|
|
|
|
gridTemplateRows: '1fr auto',
|
2021-05-17 10:01:11 +00:00
|
|
|
padding: 8,
|
|
|
|
gap: 8,
|
2021-06-01 21:49:32 +00:00
|
|
|
zIndex: 250,
|
|
|
|
pointerEvents: 'none',
|
2021-05-17 10:01:11 +00:00
|
|
|
})
|
2021-05-26 10:34:10 +00:00
|
|
|
|
2021-06-01 21:49:32 +00:00
|
|
|
const RightPanels = styled('div', {
|
2021-05-29 10:12:28 +00:00
|
|
|
gridArea: 'rightPanels',
|
2021-05-26 10:34:10 +00:00
|
|
|
padding: 8,
|
2021-06-01 21:49:32 +00:00
|
|
|
display: 'grid',
|
|
|
|
gridTemplateRows: 'auto',
|
|
|
|
height: 'fit-content',
|
|
|
|
justifyContent: 'flex-end',
|
|
|
|
gap: 8,
|
|
|
|
zIndex: 300,
|
|
|
|
pointerEvents: 'none',
|
2021-05-26 10:34:10 +00:00
|
|
|
})
|