You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import useKeyboardEvents from 'hooks/useKeyboardEvents'
  2. import useLoadOnMount from 'hooks/useLoadOnMount'
  3. import Canvas from './canvas/canvas'
  4. import StatusBar from './status-bar'
  5. import CodePanel from './code-panel/code-panel'
  6. import ControlsPanel from './controls-panel/controls-panel'
  7. import ToolsPanel from './tools-panel/tools-panel'
  8. import StylePanel from './style-panel/style-panel'
  9. import { useSelector } from 'state'
  10. import styled from 'styles'
  11. import PagePanel from './page-panel/page-panel'
  12. export default function Editor() {
  13. useKeyboardEvents()
  14. useLoadOnMount()
  15. const hasControls = useSelector(
  16. (s) => Object.keys(s.data.codeControls).length > 0
  17. )
  18. return (
  19. <Layout>
  20. <Canvas />
  21. <PagePanel />
  22. <LeftPanels>
  23. <CodePanel />
  24. {hasControls && <ControlsPanel />}
  25. </LeftPanels>
  26. <RightPanels>
  27. <StylePanel />
  28. </RightPanels>
  29. <ToolsPanel />
  30. <StatusBar />
  31. </Layout>
  32. )
  33. }
  34. const Layout = styled('main', {
  35. position: 'fixed',
  36. top: 0,
  37. left: 0,
  38. bottom: 0,
  39. right: 0,
  40. height: '100%',
  41. width: '100%',
  42. display: 'grid',
  43. gridTemplateRows: '1fr auto 144px',
  44. gridTemplateColumns: 'minmax(0, 720px) 1fr auto',
  45. gridTemplateAreas: `
  46. "leftPanels main rightPanels"
  47. "tools tools tools"
  48. "statusbar statusbar statusbar"
  49. `,
  50. })
  51. const LeftPanels = styled('div', {
  52. display: 'grid',
  53. gridArea: 'leftPanels',
  54. gridTemplateRows: '1fr auto',
  55. padding: 8,
  56. gap: 8,
  57. zIndex: 250,
  58. pointerEvents: 'none',
  59. })
  60. const RightPanels = styled('div', {
  61. gridArea: 'rightPanels',
  62. padding: 8,
  63. display: 'grid',
  64. gridTemplateRows: 'auto',
  65. height: 'fit-content',
  66. justifyContent: 'flex-end',
  67. gap: 8,
  68. zIndex: 300,
  69. pointerEvents: 'none',
  70. })