Panes.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { Allotment, LayoutPriority } from "allotment";
  2. import React from "react";
  3. import { JsonEditor } from "src/containers/Editor/JsonEditor";
  4. import dynamic from "next/dynamic";
  5. import useConfig from "src/hooks/store/useConfig";
  6. import styled from "styled-components";
  7. import "allotment/dist/style.css";
  8. export const StyledEditor = styled(Allotment)`
  9. position: relative !important;
  10. display: flex;
  11. background: ${({ theme }) => theme.BACKGROUND_SECONDARY};
  12. `;
  13. const LiveEditor = dynamic(() => import("src/containers/Editor/LiveEditor"), {
  14. ssr: false,
  15. });
  16. const Panes: React.FC = () => {
  17. const hideEditor = useConfig((state) => state.hideEditor);
  18. const isMobile = window.innerWidth <= 568;
  19. return (
  20. <StyledEditor proportionalLayout={false} vertical={isMobile}>
  21. <Allotment.Pane
  22. preferredSize={isMobile ? "100%" : 400}
  23. minSize={hideEditor ? 0 : 300}
  24. maxSize={isMobile ? Infinity : 500}
  25. visible={!hideEditor}
  26. >
  27. <JsonEditor />
  28. </Allotment.Pane>
  29. <Allotment.Pane minSize={0} maxSize={isMobile && !hideEditor ? 0 : Infinity}>
  30. <LiveEditor />
  31. </Allotment.Pane>
  32. </StyledEditor>
  33. );
  34. };
  35. export default Panes;