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.

editor.tsx 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 Toolbar from './toolbar'
  6. import CodePanel from './code-panel/code-panel'
  7. import ControlsPanel from './controls-panel/controls-panel'
  8. import ToolsPanel from './tools-panel/tools-panel'
  9. import StylePanel from './style-panel/style-panel'
  10. import { useSelector } from 'state'
  11. import styled from 'styles'
  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. <Toolbar />
  21. <Canvas />
  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('div', {
  35. position: 'fixed',
  36. top: 0,
  37. left: 0,
  38. bottom: 0,
  39. right: 0,
  40. display: 'grid',
  41. gridTemplateRows: '40px 1fr auto 40px',
  42. gridTemplateColumns: 'minmax(50%, 400px) 1fr auto',
  43. gridTemplateAreas: `
  44. "toolbar toolbar toolbar"
  45. "leftPanels main rightPanels"
  46. "tools tools tools"
  47. "statusbar statusbar statusbar"
  48. `,
  49. })
  50. const LeftPanels = styled('main', {
  51. display: 'grid',
  52. gridArea: 'leftPanels',
  53. gridTemplateRows: '1fr auto',
  54. padding: 8,
  55. gap: 8,
  56. })
  57. const RightPanels = styled('main', {
  58. display: 'grid',
  59. gridArea: 'rightPanels',
  60. gridTemplateRows: 'auto',
  61. height: 'fit-content',
  62. justifyContent: 'flex-end',
  63. padding: 8,
  64. gap: 8,
  65. })