index.tsx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. import { useRouter } from "next/router";
  2. import React from "react";
  3. import { Button } from "src/components/Button";
  4. import { Sidebar } from "src/components/Sidebar";
  5. import styled from "styled-components";
  6. import { JsonEditor } from "src/containers/JsonEditor";
  7. import { LiveEditor } from "src/containers/LiveEditor";
  8. import SplitPane from "react-split-pane";
  9. import Head from "next/head";
  10. const StyledPageWrapper = styled.div`
  11. display: flex;
  12. `;
  13. const StyledIncompatible = styled.div`
  14. display: none;
  15. @media only screen and (max-width: 568px) {
  16. position: fixed;
  17. top: 0;
  18. left: 0;
  19. display: flex;
  20. flex-direction: column;
  21. background: ${({ theme }) => theme.BLACK_LIGHT};
  22. content: "This app is not compatible with your device!";
  23. color: ${({ theme }) => theme.SILVER};
  24. width: 100%;
  25. height: 100vh;
  26. justify-content: center;
  27. align-items: center;
  28. button {
  29. margin-top: 60px;
  30. }
  31. &::before {
  32. content: "Uh, oh!";
  33. font-weight: 700;
  34. font-size: 60px;
  35. opacity: 0.6;
  36. }
  37. }
  38. `;
  39. const StyledEditorWrapper = styled.div`
  40. width: 100%;
  41. @media only screen and (max-width: 568px) {
  42. display: none;
  43. }
  44. `;
  45. const StyledTools = styled.div`
  46. display: flex;
  47. align-items: center;
  48. height: 36px;
  49. border-bottom: 1px solid ${({ theme }) => theme.BLACK};
  50. padding: 4px 16px;
  51. background: ${({ theme }) => theme.BLACK_SECONDARY};
  52. color: ${({ theme }) => theme.SILVER};
  53. `;
  54. const StyledEditor = styled(SplitPane)`
  55. position: relative !important;
  56. display: flex;
  57. background: ${({ theme }) => theme.BLACK_LIGHT};
  58. height: calc(100vh - 46px) !important;
  59. .Resizer {
  60. background: #000;
  61. opacity: 0.2;
  62. z-index: 1;
  63. box-sizing: border-box;
  64. background-clip: padding-box;
  65. }
  66. .Resizer:hover {
  67. transition: all 2s ease;
  68. }
  69. .Resizer.horizontal {
  70. height: 11px;
  71. margin: -5px 0;
  72. border-top: 5px solid rgba(255, 255, 255, 0);
  73. border-bottom: 5px solid rgba(255, 255, 255, 0);
  74. cursor: row-resize;
  75. width: 100%;
  76. }
  77. .Resizer.horizontal:hover {
  78. border-top: 5px solid rgba(0, 0, 0, 0.5);
  79. border-bottom: 5px solid rgba(0, 0, 0, 0.5);
  80. }
  81. .Resizer.vertical {
  82. width: 11px;
  83. margin: 0 -5px;
  84. border-left: 5px solid rgba(255, 255, 255, 0);
  85. border-right: 5px solid rgba(255, 255, 255, 0);
  86. cursor: col-resize;
  87. }
  88. .Resizer.vertical:hover {
  89. border-left: 5px solid rgba(0, 0, 0, 0.5);
  90. border-right: 5px solid rgba(0, 0, 0, 0.5);
  91. }
  92. .Resizer.disabled {
  93. cursor: not-allowed;
  94. }
  95. .Resizer.disabled:hover {
  96. border-color: transparent;
  97. }
  98. `;
  99. const Editor: React.FC = () => {
  100. const route = useRouter();
  101. return (
  102. <StyledPageWrapper>
  103. <Head>
  104. <title>Editor | JSON Visio</title>
  105. </Head>
  106. <Sidebar />
  107. <StyledEditorWrapper>
  108. <StyledTools>Editor</StyledTools>
  109. <StyledEditor
  110. maxSize={800}
  111. minSize={300}
  112. defaultSize={450}
  113. split="vertical"
  114. >
  115. <JsonEditor />
  116. <LiveEditor />
  117. </StyledEditor>
  118. </StyledEditorWrapper>
  119. <StyledIncompatible>
  120. This app is not compatible with your device!
  121. <Button className="incompatible" onClick={() => route.push("/")}>
  122. Go Back
  123. </Button>
  124. </StyledIncompatible>
  125. </StyledPageWrapper>
  126. );
  127. };
  128. export default Editor;