Skip to content

✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.

feat: update editor layout

AykutSarac701267a5f1f6
diff --git a/package.json b/package.json
index 2dcf2537..de31ebed 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,7 @@
"dev": "next dev",
"build": "next build && next export",
"start": "next start",
- "lint": "tsc && next lint",
+ "lint": "tsc && next lint && prettier --check ./src",
"lint:fix": "prettier --write ./src & eslint --fix src",
"deploy": "gh-pages -d out -t true"
},
diff --git a/src/components/Graph/index.tsx b/src/components/Graph/index.tsx
index fe9b22ef..2910b255 100644
--- a/src/components/Graph/index.tsx
+++ b/src/components/Graph/index.tsx
@@ -1,26 +1,39 @@
import React from "react";
+import dynamic from "next/dynamic";
import styled from "styled-components";
import { ReactZoomPanPinchRef, TransformComponent, TransformWrapper } from "react-zoom-pan-pinch";
-import { Canvas, Edge, EdgeProps, ElkRoot, NodeProps } from "reaflow";
+import { CanvasRef, Edge, EdgeProps, ElkRoot, NodeProps } from "reaflow";
import { CustomNode } from "src/components/CustomNode";
+import useToggleHide from "src/hooks/useToggleHide";
import useGraph from "src/store/useGraph";
+import useModal from "src/store/useModal";
import useUser from "src/store/useUser";
-import { Loading } from "../Loading";
+import { Loading } from "../../layout/Loading";
import { ErrorView } from "./ErrorView";
+import { PremiumView } from "./PremiumView";
+
+const Canvas = dynamic(() => import("reaflow").then(r => r.Canvas));
interface GraphProps {
isWidget?: boolean;
- openNodeModal: () => void;
}
const StyledEditorWrapper = styled.div<{ widget: boolean }>`
position: absolute;
width: 100%;
- height: ${({ widget }) => (widget ? "calc(100vh - 36px)" : "calc(100vh - 65px)")};
- background: ${({ theme }) => theme.BACKGROUND_SECONDARY};
- background-image: ${({ theme }) =>
- `radial-gradient(#505050 1px, ${theme.BACKGROUND_SECONDARY} 1px)`};
- background-size: 25px 25px;
+ height: calc(100vh - 63px);
+
+ --bg-color: ${({ theme }) => theme.GRID_BG_COLOR};
+ --line-color-1: ${({ theme }) => theme.GRID_COLOR_PRIMARY};
+ --line-color-2: ${({ theme }) => theme.GRID_COLOR_SECONDARY};
+
+ background-color: var(--bg-color);
+ background-image: linear-gradient(var(--line-color-1) 1.5px, transparent 1.5px),
+ linear-gradient(90deg, var(--line-color-1) 1.5px, transparent 1.5px),
+ linear-gradient(var(--line-color-2) 1px, transparent 1px),
+ linear-gradient(90deg, var(--line-color-2) 1px, transparent 1px);
+ background-position: -1.5px -1.5px, -1.5px -1.5px, -1px -1px, -1px -1px;
+ background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
:active {
cursor: move;
@@ -35,61 +48,35 @@ const StyledEditorWrapper = styled.div<{ widget: boolean }>`
fill: ${({ theme }) => theme.BACKGROUND_NODE};
}
- @media only screen and (max-width: 1440px) {
- background-image: ${({ theme }) =>
- `radial-gradient(#505050 0.5px, ${theme.BACKGROUND_SECONDARY} 0.5px)`};
- background-size: 15px 15px;
- }
-
- @media only screen and (max-width: 320px) {
- height: 100vh;
+ @media only screen and (max-width: 768px) {
+ height: calc(100vh - 36px);
}
`;
-export const Graph = ({ isWidget = false, openNodeModal }: GraphProps) => {
+export const Graph = ({ isWidget = false }: GraphProps) => {
+ const { validateHiddenNodes } = useToggleHide();
const isPremium = useUser(state => state.isPremium);
const setLoading = useGraph(state => state.setLoading);
const setZoomPanPinch = useGraph(state => state.setZoomPanPinch);
const centerView = useGraph(state => state.centerView);
const setSelectedNode = useGraph(state => state.setSelectedNode);
+ const setVisible = useModal(state => state.setVisible);
+ const canvasRef = React.useRef<CanvasRef>(null);
const loading = useGraph(state => state.loading);
const direction = useGraph(state => state.direction);
const nodes = useGraph(state => state.nodes);
const edges = useGraph(state => state.edges);
- const collapsedNodes = useGraph(state => state.collapsedNodes);
- const collapsedEdges = useGraph(state => state.collapsedEdges);
-
- React.useEffect(() => {
- const nodeList = collapsedNodes.map(id => `[id$="node-${id}"]`);
- const edgeList = collapsedEdges.map(id => `[class$="edge-${id}"]`);
-
- const hiddenItems = document.querySelectorAll(".hide");
- hiddenItems.forEach(item => item.classList.remove("hide"));
-
- if (nodeList.length) {
- const selectedNodes = document.querySelectorAll(nodeList.join(","));
- selectedNodes.forEach(node => node.classList.add("hide"));
- }
-
- if (edgeList.length) {
- const selectedEdges = document.querySelectorAll(edgeList.join(","));
- selectedEdges.forEach(edge => edge.classList.add("hide"));
- }
- }, [collapsedNodes, collapsedEdges]);
-
- const [size, setSize] = React.useState({
- width: 1,
- height: 1,
- });
+ const [paneWidth, setPaneWidth] = React.useState(2000);
+ const [paneHeight, setPaneHeight] = React.useState(2000);
const handleNodeClick = React.useCallback(
(_: React.MouseEvent<SVGElement>, data: NodeData) => {
if (setSelectedNode) setSelectedNode({ nodeData: data });
- if (openNodeModal) openNodeModal();
+ setVisible("node")(true);
},
- [openNodeModal, setSelectedNode]
+ [setSelectedNode, setVisible]
);
const onInit = React.useCallback(
@@ -103,27 +90,25 @@ export const Graph = ({ isWidget = false, openNodeModal }: GraphProps) => {
(layout: ElkRoot) => {
if (layout.width && layout.height) {
const areaSize = layout.width * layout.height;
- const changeRatio = Math.abs((areaSize * 100) / (size.width * size.height) - 100);
+ const changeRatio = Math.abs((areaSize * 100) / (paneWidth * paneHeight) - 100);
- setSize({
- width: (layout.width as number) + 400,
- height: (layout.height as number) + 400,
- });
+ setPaneWidth((layout.width as number) + 400);
+ setPaneHeight((layout.height as number) + 400);
setTimeout(() => {
setLoading(false);
+ validateHiddenNodes();
window.requestAnimationFrame(() => {
if (changeRatio > 70 || isWidget) centerView();
});
});
}
},
- [centerView, isWidget, setLoading, size.height, size.width]
+ [centerView, isWidget, paneHeight, paneWidth, setLoading, validateHiddenNodes]
);
const onCanvasClick = React.useCallback(() => {
- const input = document.querySelector("input:focus") as HTMLInputElement;
- if (input) input.blur();
+ (document.activeElement as HTMLElement)?.blur();
}, []);
const memoizedNode = React.useCallback(
@@ -142,10 +127,14 @@ export const Graph = ({ isWidget = false, openNodeModal }: GraphProps) => {
if (nodes.length > 6_000) return <ErrorView />;
+ if (nodes.length > 400 && !isWidget) {
+ if (!isPremium) return <PremiumView />;
+ }
+
return (
<>
<Loading message="Painting graph..." loading={loading} />
- <StyledEditorWrapper onContextMenu={e => e.preventDefault()} widget={isWidget}>
+ <StyledEditorWrapper widget={isWidget}>
<TransformWrapper
maxScale={2}
minScale={0.05}
@@ -167,16 +156,20 @@ export const Graph = ({ isWidget = false, openNodeModal }: GraphProps) => {
>
<Canvas
className="jsoncrack-canvas"
+ ref={canvasRef}
nodes={nodes}
edges={edges}
- maxWidth={size.width}
- maxHeight={size.height}
+ maxHeight={paneHeight}
+ maxWidth={paneWidth}
+ height={paneHeight}
+ width={paneWidth}
direction={direction}
onLayoutChange={onLayoutChange}
onCanvasClick={onCanvasClick}
node={memoizedNode}
edge={memoizedEdge}
key={direction}
+ pannable={false}
zoomable={false}
animated={false}
readonly={true}
diff --git a/src/components/MonacoEditor/index.tsx b/src/components/MonacoEditor/index.tsx
index c8096651..c507b434 100644
--- a/src/components/MonacoEditor/index.tsx
+++ b/src/components/MonacoEditor/index.tsx
@@ -2,7 +2,7 @@ import React from "react";
import styled from "styled-components";
import Editor, { loader, Monaco } from "@monaco-editor/react";
import debounce from "lodash.debounce";
-import { Loading } from "src/components/Loading";
+import { Loading } from "src/layout/Loading";
import useJson from "src/store/useJson";
import useStored from "src/store/useStored";
diff --git a/src/components/SearchInput/index.tsx b/src/components/SearchInput/index.tsx
index 2de24686..ce6df16a 100644
--- a/src/components/SearchInput/index.tsx
+++ b/src/components/SearchInput/index.tsx
@@ -1,95 +1,29 @@
import React from "react";
-import styled from "styled-components";
+import { Flex, Input, Text } from "@mantine/core";
+import { getHotkeyHandler } from "@mantine/hooks";
import { AiOutlineSearch } from "react-icons/ai";
-import { IoCloseSharp } from "react-icons/io5";
import { useFocusNode } from "src/hooks/useFocusNode";
-const StyledInputWrapper = styled.div`
- display: flex;
- align-items: center;
- justify-content: space-between;
- background: ${({ theme }) => theme.BACKGROUND_TERTIARY};
- border-radius: 4px;
- height: 25px;
-`;
-
-const StyledForm = styled.form`
- display: flex;
- align-items: center;
- padding: 4px 6px;
-`;
-
-const StyledInput = styled.input<{ hasInput: boolean }>`
- background: none;
- color: ${({ theme }) => theme.TEXT_NORMAL};
- outline: none;
- border: none;
- width: 112px;
- font-size: 14px;
- font-weight: 500;
- transition: width 0.3s;
-
- &::-webkit-search-decoration,
- &::-webkit-search-cancel-button,
- &::-webkit-search-results-button,
- &::-webkit-search-results-decoration {
- display: none;
- }
-
- &:focus {
- width: ${({ hasInput }) => hasInput && "165px"};
- }
-`;
-
-const StyledSearchButton = styled.button`
- display: grid;
- background: none;
- color: ${({ theme }) => theme.INTERACTIVE_NORMAL};
- padding: 0;
- min-height: unset;
-
- &:hover {
- box-shadow: none;
- }
-`;
-
-const StyledCountInfo = styled.span`
- font-size: 14px;
- letter-spacing: 2px;
- padding: 0 6px;
- opacity: 0.5;
-`;
-
export const SearchInput: React.FC = () => {
- const [content, setContent, skip, nodeCount, currentNode] = useFocusNode();
-
- const onSubmit = (e: React.FormEvent<HTMLFormElement>) => {
- e.preventDefault();
- skip();
- };
-
- const handleClear = (e: React.MouseEvent<HTMLButtonElement>) => {
- e.preventDefault();
- setContent({ value: "", debounced: "" });
- };
+ const [searchValue, setValue, skip, nodeCount, currentNode] = useFocusNode();
return (
- <StyledInputWrapper>
- <StyledForm onSubmit={onSubmit}>
- <StyledInput
- type="search"
- value={content.value}
- onChange={e => setContent(val => ({ ...val, value: e.target.value }))}
- placeholder="Search Node"
- hasInput={!!content.value.length}
- />
- <StyledCountInfo>
- {content.value && `${nodeCount}/${nodeCount > 0 ? currentNode + 1 : "0"}`}
- </StyledCountInfo>
- <StyledSearchButton type="reset" aria-label="search" onClick={handleClear}>
- {content.value ? <IoCloseSharp size={18} /> : <AiOutlineSearch size={18} />}
- </StyledSearchButton>
- </StyledForm>
- </StyledInputWrapper>
+ <Input
+ type="search"
+ size="xs"
+ id="search-node"
+ value={searchValue}
+ onChange={e => setValue(e.currentTarget.value)}
+ placeholder="Search Node"
+ onKeyDown={getHotkeyHandler([["Enter", skip]])}
+ icon={<AiOutlineSearch />}
+ rightSection={
+ <Flex h={30} align="center" gap="sm">
+ <Text size="xs" color="dimmed">
+ {searchValue && `${nodeCount}/${nodeCount > 0 ? currentNode + 1 : "0"}`}
+ </Text>
+ </Flex>
+ }
+ />
);
};
diff --git a/src/components/Sidebar/index.tsx b/src/components/Sidebar/index.tsx
deleted file mode 100644
index 52d86ba1..00000000
--- a/src/components/Sidebar/index.tsx
+++ /dev/null
@@ -1,263 +0,0 @@
-import React from "react";
-import styled from "styled-components";
-import { Tooltip } from "@mantine/core";
-import toast from "react-hot-toast";
-import { AiOutlineDelete, AiOutlineSave, AiOutlineFileAdd, AiOutlineEdit } from "react-icons/ai";
-import { CgArrowsMergeAltH, CgArrowsShrinkH } from "react-icons/cg";
-import { TiFlowMerge } from "react-icons/ti";
-import {
- VscAccount,
- VscCloud,
- VscCollapseAll,
- VscExpandAll,
- VscSettingsGear,
-} from "react-icons/vsc";
-import useGraph from "src/store/useGraph";
-import useJson from "src/store/useJson";
-import useModal from "src/store/useModal";
-import { getNextDirection } from "src/utils/getNextDirection";
-
-const StyledSidebar = styled.div`
- display: flex;
- justify-content: space-between;
- flex-direction: column;
- align-items: center;
- width: fit-content;
- background: ${({ theme }) => theme.BACKGROUND_TERTIARY};
- padding: 4px;
- border-right: 1px solid ${({ theme }) => theme.BACKGROUND_MODIFIER_ACCENT};
- width: 50px;
- text-align: center;
-
- @media only screen and (max-width: 768px) {
- flex-direction: row;
- width: 100%;
- }
-`;
-
-const StyledElement = styled.button`
- display: flex;
- align-items: center;
- justify-content: center;
- height: 45px;
- font-size: 24px;
- font-weight: 600;
- cursor: pointer;
- color: ${({ theme }) => theme.SIDEBAR_ICONS};
- width: 100%;
-
- svg {
- vertical-align: middle;
- }
-
- a {
- display: flex;
- }
-
- &:hover :is(a, svg) {
- color: ${({ theme }) => theme.INTERACTIVE_HOVER};
- }
-
- @media only screen and (max-width: 768px) {
- font-size: 22px;
- }
-`;
-
-const StyledText = styled.span<{ secondary?: boolean }>`
- color: ${({ theme, secondary }) => (secondary ? theme.INTERACTIVE_HOVER : theme.ORANGE)};
-`;
-
-const StyledFlowIcon = styled(TiFlowMerge)<{ rotate: number }>`
- transform: rotate(${({ rotate }) => `${rotate}deg`});
-`;
-
-const StyledTopWrapper = styled.nav`
- display: flex;
- justify-content: space-between;
- flex-direction: column;
- align-items: center;
- width: 100%;
-
- .mobile {
- display: none;
- }
-
- @media only screen and (max-width: 768px) {
- justify-content: space-evenly;
- flex-direction: row;
-
- .mobile {
- display: initial;
- }
-
- .desktop {
- display: none;
- }
- }
-`;
-
-const StyledBottomWrapper = styled.nav`
- display: flex;
- justify-content: space-between;
- flex-direction: column;
- align-items: center;
- width: 100%;
-
- @media only screen and (max-width: 768px) {
- display: none;
- }
-`;
-
-const StyledLogo = styled.a`
- color: ${({ theme }) => theme.FULL_WHITE};
- border-bottom: 1px solid ${({ theme }) => theme.BACKGROUND_MODIFIER_ACCENT};
- width: 100%;
-
- @media only screen and (max-width: 768px) {
- border-bottom: 0;
- }
-`;
-
-function rotateLayout(direction: "LEFT" | "RIGHT" | "DOWN" | "UP") {
- if (direction === "LEFT") return 90;
- if (direction === "UP") return 180;
- if (direction === "RIGHT") return 270;
- return 360;
-}
-
-const SidebarButton: React.FC<{
- onClick: () => void;
- deviceDisplay?: "desktop" | "mobile";
- title: string;
- component: React.ReactNode;
-}> = ({ onClick, deviceDisplay, title, component }) => {
- return (
- <Tooltip className={deviceDisplay} label={title} color="gray" position="right" withArrow>
- <StyledElement onClick={onClick}>{component}</StyledElement>
- </Tooltip>
- );
-};
-
-export const Sidebar: React.FC = () => {
- const setVisible = useModal(state => state.setVisible);
- const setDirection = useGraph(state => state.setDirection);
- const getJson = useJson(state => state.getJson);
-
- const collapseGraph = useGraph(state => state.collapseGraph);
- const expandGraph = useGraph(state => state.expandGraph);
- const toggleFold = useGraph(state => state.toggleFold);
- const toggleFullscreen = useGraph(state => state.toggleFullscreen);
-
- const direction = useGraph(state => state.direction);
- const foldNodes = useGraph(state => state.foldNodes);
- const fullscreen = useGraph(state => state.fullscreen);
- const graphCollapsed = useGraph(state => state.graphCollapsed);
-
- const handleSave = () => {
- const a = document.createElement("a");
- const file = new Blob([getJson()], { type: "text/plain" });
-
- a.href = window.URL.createObjectURL(file);
- a.download = "jsoncrack.json";
- a.click();
- };
-
- const toggleFoldNodes = () => {
- toggleFold(!foldNodes);
- toast(`${foldNodes ? "Unfolded" : "Folded"} nodes`);
- };
-
- const toggleDirection = () => {
- const nextDirection = getNextDirection(direction);
- setDirection(nextDirection);
- };
-
- const toggleExpandCollapseGraph = () => {
- if (graphCollapsed) expandGraph();
- else collapseGraph();
-
- toast(`${graphCollapsed ? "Expanded" : "Collapsed"} graph.`);
- };
-
- return (
- <StyledSidebar>
- <StyledTopWrapper>
- <StyledElement href="/" as={StyledLogo}>
- <StyledText>J</StyledText>
- <StyledText secondary>C</StyledText>
- </StyledElement>
-
- <SidebarButton
- title="Edit JSON"
- deviceDisplay="mobile"
- onClick={() => toggleFullscreen(!fullscreen)}
- component={<AiOutlineEdit />}
- />
-
- <SidebarButton
- title="Import File"
- onClick={() => setVisible("import")(true)}
- component={<AiOutlineFileAdd />}
- />
-
- <SidebarButton
- title="Rotate Layout"
- onClick={toggleDirection}
- component={<StyledFlowIcon rotate={rotateLayout(direction)} />}
- />
-
- <SidebarButton
- title={foldNodes ? "Unfold Nodes" : "Fold Nodes"}
- deviceDisplay="desktop"
- onClick={toggleFoldNodes}
- component={foldNodes ? <CgArrowsShrinkH /> : <CgArrowsMergeAltH />}
- />
-
- <SidebarButton
- title={graphCollapsed ? "Expand Graph" : "Collapse Graph"}
- onClick={toggleExpandCollapseGraph}
- component={graphCollapsed ? <VscExpandAll /> : <VscCollapseAll />}
- />
-
- <SidebarButton
- title="Download JSON"
- deviceDisplay="desktop"
- onClick={handleSave}
- component={<AiOutlineSave />}
- />
-
- <SidebarButton
- title="Delete JSON"
- onClick={() => setVisible("clear")(true)}
- component={<AiOutlineDelete />}
- />
-
- <SidebarButton
- title="View Cloud"
- deviceDisplay="desktop"
- onClick={() => setVisible("cloud")(true)}
- component={<VscCloud />}
- />
-
- <SidebarButton
- title="Settings"
- deviceDisplay="mobile"
- onClick={() => setVisible("settings")(true)}
- component={<VscSettingsGear />}
- />
- </StyledTopWrapper>
- <StyledBottomWrapper>
- <SidebarButton
- title="Account"
- onClick={() => setVisible("account")(true)}
- component={<VscAccount />}
- />
- <SidebarButton
- title="Settings"
- onClick={() => setVisible("settings")(true)}
- component={<VscSettingsGear />}
- />
- </StyledBottomWrapper>
- </StyledSidebar>
- );
-};
diff --git a/src/constants/theme.ts b/src/constants/theme.ts
index 3dd30f62..dfc56bb3 100644
--- a/src/constants/theme.ts
+++ b/src/constants/theme.ts
@@ -20,7 +20,7 @@ const fixedColors = {
const nodeColors = {
dark: {
NODE_COLORS: {
- TEXT: "#35D073",
+ TEXT: "#DCE5E7",
NODE_KEY: "#59b8ff",
NODE_VALUE: "#DCE5E7",
INTEGER: "#e8c479",
@@ -36,10 +36,10 @@ const nodeColors = {
},
light: {
NODE_COLORS: {
- TEXT: "#748700",
+ TEXT: "#000",
NODE_KEY: "#761CEA",
NODE_VALUE: "#535353",
- INTEGER: "#A771FE",
+ INTEGER: "#FD0079",
NULL: "#afafaf",
BOOL: {
FALSE: "#FF0000",
@@ -72,6 +72,9 @@ export const darkTheme = {
MODAL_BACKGROUND: "#36393E",
TEXT_NORMAL: "#dcddde",
TEXT_POSITIVE: "hsl(139,calc(var(--saturation-factor, 1)*51.6%),52.2%)",
+ GRID_BG_COLOR: "#1C1C1C",
+ GRID_COLOR_PRIMARY: "#2A2A2A",
+ GRID_COLOR_SECONDARY: "#252525",
};
export const lightTheme = {
@@ -86,7 +89,7 @@ export const lightTheme = {
INTERACTIVE_NORMAL: "#4f5660",
INTERACTIVE_HOVER: "#2e3338",
INTERACTIVE_ACTIVE: "#060607",
- BACKGROUND_NODE: "#FAFAFA",
+ BACKGROUND_NODE: "#F6F8FA",
BACKGROUND_TERTIARY: "#e3e5e8",
BACKGROUND_SECONDARY: "#f2f3f5",
BACKGROUND_PRIMARY: "#FFFFFF",
@@ -94,6 +97,9 @@ export const lightTheme = {
MODAL_BACKGROUND: "#FFFFFF",
TEXT_NORMAL: "#2e3338",
TEXT_POSITIVE: "#008736",
+ GRID_BG_COLOR: "#FAFAFA",
+ GRID_COLOR_PRIMARY: "#EBEBEB",
+ GRID_COLOR_SECONDARY: "#EEEEEE",
};
const themeDs = {
diff --git a/src/containers/Editor/BottomBar.tsx b/src/containers/Editor/BottomBar.tsx
index 97f52a0d..e33f3f8e 100644
--- a/src/containers/Editor/BottomBar.tsx
+++ b/src/containers/Editor/BottomBar.tsx
@@ -2,6 +2,7 @@ import React from "react";
import Head from "next/head";
import { useRouter } from "next/router";
import styled from "styled-components";
+import { Flex, Text } from "@mantine/core";
import toast from "react-hot-toast";
import {
AiOutlineCloudSync,
@@ -10,6 +11,7 @@ import {
AiOutlineLock,
AiOutlineUnlock,
} from "react-icons/ai";
+import { MdReportGmailerrorred, MdOutlineCheckCircleOutline } from "react-icons/md";
import { VscAccount } from "react-icons/vsc";
import { saveJson, updateJson } from "src/services/db/json";
import useJson from "src/store/useJson";
@@ -46,7 +48,7 @@ const StyledRight = styled.div`
gap: 4px;
`;
-const StyledBottomBarItem = styled.button`
+const StyledBottomBarItem = styled.button<{ error?: boolean }>`
display: flex;
align-items: center;
gap: 4px;
@@ -56,7 +58,8 @@ const StyledBottomBarItem = styled.button`
padding: 4px;
font-size: 12px;
font-weight: 400;
- color: ${({ theme }) => theme.INTERACTIVE_NORMAL};
+ color: ${({ theme, error }) => (error ? theme.DANGER : theme.INTERACTIVE_NORMAL)};
+ background: ${({ error }) => error && "rgba(255, 99, 71, 0.4)"};
&:hover:not(&:disabled) {
background-image: linear-gradient(rgba(0, 0, 0, 0.1) 0 0);
@@ -76,6 +79,7 @@ const StyledImg = styled.img<{ light: boolean }>`
export const BottomBar = () => {
const { replace, query } = useRouter();
const data = useJson(state => state.data);
+ const hasError = useJson(state => state.hasError);
const user = useUser(state => state.user);
const lightmode = useStored(state => state.lightmode);
const hasChanges = useJson(state => state.hasChanges);
@@ -151,6 +155,19 @@ export const BottomBar = () => {
<VscAccount />
{user ? user.name : "Login"}
</StyledBottomBarItem>
+ <StyledBottomBarItem error={!!hasError}>
+ {hasError ? (
+ <Flex align="center" gap={2}>
+ <MdReportGmailerrorred color="red" size={16} />
+ <Text fw="bold">Invalid Format</Text>
+ </Flex>
+ ) : (
+ <Flex align="center" gap={2}>
+ <MdOutlineCheckCircleOutline />
+ <Text>Valid Format</Text>
+ </Flex>
+ )}
+ </StyledBottomBarItem>
<StyledBottomBarItem onClick={handleSaveJson} disabled={isUpdating}>
{hasChanges ? <AiOutlineCloudUpload /> : <AiOutlineCloudSync />}
{hasChanges ? "Unsaved Changes" : "Saved"}
diff --git a/src/containers/Editor/JsonEditor/index.tsx b/src/containers/Editor/JsonEditor/index.tsx
index 5a839f27..38818af4 100644
--- a/src/containers/Editor/JsonEditor/index.tsx
+++ b/src/containers/Editor/JsonEditor/index.tsx
@@ -1,6 +1,5 @@
import React from "react";
import styled from "styled-components";
-import { ErrorContainer } from "src/components/ErrorContainer";
import { MonacoEditor } from "src/components/MonacoEditor";
const StyledEditorWrapper = styled.div`
@@ -13,7 +12,6 @@ const StyledEditorWrapper = styled.div`
export const JsonEditor: React.FC = () => {
return (
<StyledEditorWrapper>
- <ErrorContainer />
<MonacoEditor />
</StyledEditorWrapper>
);
diff --git a/src/containers/Editor/LiveEditor/GraphCanvas.tsx b/src/containers/Editor/LiveEditor/GraphCanvas.tsx
index 8f28038a..6d9df644 100644
--- a/src/containers/Editor/LiveEditor/GraphCanvas.tsx
+++ b/src/containers/Editor/LiveEditor/GraphCanvas.tsx
@@ -1,15 +1,6 @@
import React from "react";
import { Graph } from "src/components/Graph";
-import { NodeModal } from "src/containers/Modals/NodeModal";
export const GraphCanvas = ({ isWidget = false }: { isWidget?: boolean }) => {
- const [isNodeModalVisible, setNodeModalVisible] = React.useState(false);
- const openNodeModal = React.useCallback(() => setNodeModalVisible(true), []);
-
- return (
- <>
- <Graph openNodeModal={openNodeModal} isWidget={isWidget} />
- <NodeModal opened={isNodeModalVisible} onClose={() => setNodeModalVisible(false)} />
- </>
- );
+ return <Graph isWidget={isWidget} />;
};
diff --git a/src/containers/Editor/LiveEditor/Tools.tsx b/src/containers/Editor/LiveEditor/Tools.tsx
index 2ccf2c7a..316ba184 100644
--- a/src/containers/Editor/LiveEditor/Tools.tsx
+++ b/src/containers/Editor/LiveEditor/Tools.tsx
@@ -1,34 +1,55 @@
import React from "react";
import styled from "styled-components";
+import { Flex, Menu, Text } from "@mantine/core";
+import { useHotkeys } from "@mantine/hooks";
+import toast from "react-hot-toast";
import { AiOutlineFullscreen, AiOutlineMinus, AiOutlinePlus } from "react-icons/ai";
+import { CgArrowsMergeAltH, CgArrowsShrinkH, CgChevronDown } from "react-icons/cg";
import { FiDownload } from "react-icons/fi";
import { MdCenterFocusWeak } from "react-icons/md";
+import { TiFlowMerge } from "react-icons/ti";
+import {
+ VscCollapseAll,
+ VscExpandAll,
+ VscLayoutSidebarLeft,
+ VscLayoutSidebarLeftOff,
+ VscSettingsGear,
+} from "react-icons/vsc";
import { SearchInput } from "src/components/SearchInput";
import useGraph from "src/store/useGraph";
+import useJson from "src/store/useJson";
import useModal from "src/store/useModal";
+import useStored from "src/store/useStored";
+import { getNextDirection } from "src/utils/getNextDirection";
export const StyledTools = styled.div`
position: relative;
display: flex;
align-items: center;
gap: 4px;
- flex-direction: row-reverse;
+ justify-content: space-between;
height: 36px;
padding: 4px 16px;
- background: ${({ theme }) => theme.BACKGROUND_PRIMARY};
+ background: ${({ theme }) => theme.BACKGROUND_SECONDARY};
color: ${({ theme }) => theme.SILVER};
box-shadow: 0 1px 0px ${({ theme }) => theme.BACKGROUND_TERTIARY};
- z-index: 1;
+ z-index: 36;
@media only screen and (max-width: 320px) {
display: none;
}
`;
+const Section = styled.div`
+ display: flex;
+ align-items: center;
+ gap: 8px;
+`;
+
const StyledToolElement = styled.button<{ hide?: boolean }>`
display: ${({ hide }) => (hide ? "none" : "grid")};
place-content: center;
- font-size: 20px;
+ font-size: 12px;
background: none;
color: ${({ theme }) => theme.INTERACTIVE_NORMAL};
padding: 6px;
@@ -45,35 +66,198 @@ const StyledToolElement = styled.button<{ hide?: boolean }>`
}
`;
+const StyledLogo = styled.img<{ invert: boolean }>`
+ filter: ${({ invert }) => invert && "invert()"};
+`;
+
+const StyledFlowIcon = styled(TiFlowMerge)<{ rotate: number }>`
+ transform: rotate(${({ rotate }) => `${rotate}deg`});
+`;
+
+function rotateLayout(direction: "LEFT" | "RIGHT" | "DOWN" | "UP") {
+ if (direction === "LEFT") return 90;
+ if (direction === "UP") return 180;
+ if (direction === "RIGHT") return 270;
+ return 360;
+}
+
+function fullscreenBrowser() {
+ if (!document.fullscreenElement) {
+ document.documentElement.requestFullscreen();
+ } else if (document.exitFullscreen) {
+ document.exitFullscreen();
+ }
+}
+
export const Tools: React.FC<{ isWidget?: boolean }> = ({ isWidget = false }) => {
+ const getJson = useJson(state => state.getJson);
const setVisible = useModal(state => state.setVisible);
-
+ const direction = useGraph(state => state.direction);
const fullscreen = useGraph(state => state.fullscreen);
const toggleFullscreen = useGraph(state => state.toggleFullscreen);
-
const zoomIn = useGraph(state => state.zoomIn);
const zoomOut = useGraph(state => state.zoomOut);
const centerView = useGraph(state => state.centerView);
+ const foldNodes = useGraph(state => state.foldNodes);
+ const toggleFold = useGraph(state => state.toggleFold);
+ const setDirection = useGraph(state => state.setDirection);
+ const graphCollapsed = useGraph(state => state.graphCollapsed);
+ const expandGraph = useGraph(state => state.expandGraph);
+ const collapseGraph = useGraph(state => state.collapseGraph);
+ const lightmode = useStored(state => state.lightmode);
+
+ const CoreKey = navigator.userAgent.indexOf("Mac OS X") ? "⌘" : "CTRL";
+
const toggleEditor = () => toggleFullscreen(!fullscreen);
+ const toggleFoldNodes = () => {
+ toggleFold(!foldNodes);
+ toast(`${foldNodes ? "Unfolded" : "Folded"} nodes`);
+ };
+
+ const toggleDirection = () => {
+ const nextDirection = getNextDirection(direction);
+ setDirection(nextDirection);
+ };
+
+ const toggleExpandCollapseGraph = () => {
+ if (graphCollapsed) expandGraph();
+ else collapseGraph();
+
+ toast(`${graphCollapsed ? "Expanded" : "Collapsed"} graph.`);
+ };
+
+ const handleSave = () => {
+ const a = document.createElement("a");
+ const file = new Blob([getJson()], { type: "text/plain" });
+
+ a.href = window.URL.createObjectURL(file);
+ a.download = "jsoncrack.json";
+ a.click();
+ };
+
+ useHotkeys([
+ ["mod+shift+e", toggleEditor],
+ ["mod+shift+d", toggleDirection],
+ ["mod+shift+f", toggleFoldNodes],
+ ["mod+shift+c", toggleExpandCollapseGraph],
+ [
+ "mod+f",
+ () => {
+ const input = document.querySelector("#search-node") as HTMLInputElement;
+ input.focus();
+ },
+ ],
+ ]);
+
return (
<StyledTools>
- <StyledToolElement title="fullscreen" hide={isWidget} onClick={toggleEditor}>
- <AiOutlineFullscreen />
- </StyledToolElement>
- <SearchInput />
- <StyledToolElement title="save" onClick={() => setVisible("download")(true)}>
- <FiDownload />
- </StyledToolElement>
- <StyledToolElement title="center canvas" onClick={centerView}>
- <MdCenterFocusWeak />
- </StyledToolElement>
- <StyledToolElement title="zoom out" onClick={zoomOut}>
- <AiOutlineMinus />
- </StyledToolElement>
- <StyledToolElement title="zoom in" onClick={zoomIn}>
- <AiOutlinePlus />
- </StyledToolElement>
+ <Section>
+ <StyledToolElement as="a" title="Herowand" href="https://herowand.com">
+ <Flex gap="xs" align="center" justify="center">
+ <StyledLogo
+ src="/assets/icon.png"
+ width="auto"
+ height="16"
+ alt="logo"
+ invert={lightmode}
+ />
+ </Flex>
+ </StyledToolElement>
+ <StyledToolElement title="Import File" onClick={() => setVisible("import")(true)}>
+ Import
+ </StyledToolElement>
+ <Menu shadow="md" closeOnItemClick={false}>
+ <Menu.Target>
+ <StyledToolElement>
+ <Flex align="center" gap={3}>
+ View <CgChevronDown />
+ </Flex>
+ </StyledToolElement>
+ </Menu.Target>
+ <Menu.Dropdown>
+ <Menu.Item
+ fz={12}
+ onClick={toggleEditor}
+ icon={fullscreen ? <VscLayoutSidebarLeft /> : <VscLayoutSidebarLeftOff />}
+ rightSection={
+ <Text ml="md" fz={10} color="dimmed">
+ {CoreKey} Shift E
+ </Text>
+ }
+ >
+ {fullscreen ? "Show" : "Hide"} Editor
+ </Menu.Item>
+ <Menu.Item
+ fz={12}
+ onClick={toggleDirection}
+ icon={<StyledFlowIcon rotate={rotateLayout(direction)} />}
+ rightSection={
+ <Text ml="md" fz={10} color="dimmed">
+ {CoreKey} Shift D
+ </Text>
+ }
+ >
+ Rotate Layout
+ </Menu.Item>
+ <Menu.Item
+ fz={12}
+ onClick={toggleFoldNodes}
+ icon={foldNodes ? <CgArrowsShrinkH /> : <CgArrowsMergeAltH />}
+ rightSection={
+ <Text ml="md" fz={10} color="dimmed">
+ {CoreKey} Shift F
+ </Text>
+ }
+ >
+ {foldNodes ? "Unfold" : "Fold"} Nodes
+ </Menu.Item>
+ <Menu.Item
+ fz={12}
+ onClick={toggleExpandCollapseGraph}
+ icon={graphCollapsed ? <VscExpandAll /> : <VscCollapseAll />}
+ rightSection={
+ <Text ml="md" fz={10} color="dimmed">
+ {CoreKey} Shift C
+ </Text>
+ }
+ >
+ {graphCollapsed ? "Expand" : "Collapse"} Nodes
+ </Menu.Item>
+ </Menu.Dropdown>
+ </Menu>
+ <StyledToolElement title="Cloud" onClick={() => setVisible("cloud")(true)}>
+ Cloud
+ </StyledToolElement>
+ <StyledToolElement title="Download as File" onClick={handleSave}>
+ Download
+ </StyledToolElement>
+ </Section>
+ <Section>
+ <StyledToolElement title="Zoom Out" onClick={zoomOut}>
+ <AiOutlineMinus size="18" />
+ </StyledToolElement>
+ <StyledToolElement title="Zoom In" onClick={zoomIn}>
+ <AiOutlinePlus size="18" />
+ </StyledToolElement>
+ <StyledToolElement title="Save as Image" onClick={() => setVisible("download")(true)}>
+ <FiDownload size="18" />
+ </StyledToolElement>
+ <StyledToolElement title="Center Canvas" onClick={centerView}>
+ <MdCenterFocusWeak size="18" />
+ </StyledToolElement>
+ <SearchInput />
+ <StyledToolElement title="Fullscreen" hide={isWidget} onClick={fullscreenBrowser}>
+ <AiOutlineFullscreen size="18" />
+ </StyledToolElement>
+ <StyledToolElement
+ title="Settings"
+ hide={isWidget}
+ onClick={() => setVisible("settings")(true)}
+ >
+ <VscSettingsGear size="18" />
+ </StyledToolElement>
+ </Section>
</StyledTools>
);
};
diff --git a/src/containers/Editor/LiveEditor/index.tsx b/src/containers/Editor/LiveEditor/index.tsx
index 793393c5..99ab766d 100644
--- a/src/containers/Editor/LiveEditor/index.tsx
+++ b/src/containers/Editor/LiveEditor/index.tsx
@@ -1,7 +1,6 @@
import React from "react";
import styled from "styled-components";
import { GraphCanvas } from "src/containers/Editor/LiveEditor/GraphCanvas";
-import { Tools } from "src/containers/Editor/LiveEditor/Tools";
const StyledLiveEditor = styled.div`
position: relative;
@@ -11,7 +10,6 @@ const StyledLiveEditor = styled.div`
const LiveEditor: React.FC = () => {
return (
<StyledLiveEditor>
- <Tools />
<GraphCanvas />
</StyledLiveEditor>
);
diff --git a/src/containers/Editor/Panes.tsx b/src/containers/Editor/Panes.tsx
index 154f16ff..2527dbde 100644
--- a/src/containers/Editor/Panes.tsx
+++ b/src/containers/Editor/Panes.tsx
@@ -10,6 +10,7 @@ export const StyledEditor = styled(Allotment)`
position: relative !important;
display: flex;
background: ${({ theme }) => theme.BACKGROUND_SECONDARY};
+ height: calc(100vh - 63px);
`;
const LiveEditor = dynamic(() => import("src/containers/Editor/LiveEditor"), {
@@ -28,7 +29,7 @@ const Panes: React.FC = () => {
return (
<StyledEditor proportionalLayout={false} vertical={isMobile}>
<Allotment.Pane
- preferredSize={isMobile ? "100%" : 400}
+ preferredSize={isMobile ? "100%" : 450}
minSize={fullscreen ? 0 : 300}
maxSize={isMobile ? Infinity : 800}
visible={!fullscreen}
diff --git a/src/containers/Home/index.tsx b/src/containers/Home/index.tsx
index 0d4d9d1a..bab64a39 100644
--- a/src/containers/Home/index.tsx
+++ b/src/containers/Home/index.tsx
@@ -15,13 +15,13 @@ import { IoHeart } from "react-icons/io5";
import { SiVisualstudiocode } from "react-icons/si";
import vscDarkPlus from "react-syntax-highlighter/dist/cjs/styles/prism/vsc-dark-plus";
import { CarbonAds } from "src/components/CarbonAds";
-import { Footer } from "src/components/Footer";
-import { Navbar } from "src/components/Navbar";
-import { Producthunt } from "src/components/Producthunt";
import { Sponsors } from "src/components/Sponsors";
import { SupportButton } from "src/components/SupportButton";
import { baseURL } from "src/constants/data";
import { TABS } from "src/constants/previewSection";
+import { Footer } from "src/layout/Footer";
+import { Navbar } from "src/layout/Navbar";
+import { Producthunt } from "src/layout/Producthunt";
import * as Styles from "./styles";
const SyntaxHighlighter = dynamic(() => import("react-syntax-highlighter/dist/cjs/prism-async"), {
diff --git a/src/containers/ModalController/index.tsx b/src/containers/ModalController/index.tsx
index 9488bf77..c3ca5b2a 100644
--- a/src/containers/ModalController/index.tsx
+++ b/src/containers/ModalController/index.tsx
@@ -9,6 +9,7 @@ import { LoginModal } from "src/containers/Modals/LoginModal";
import { SettingsModal } from "src/containers/Modals/SettingsModal";
import { ShareModal } from "src/containers/Modals/ShareModal";
import useModal from "src/store/useModal";
+import { NodeModal } from "../Modals/NodeModal";
import { PremiumModal } from "../Modals/PremiumModal";
export const ModalController = () => {
@@ -24,6 +25,7 @@ export const ModalController = () => {
loginModal,
shareModal,
premiumModal,
+ nodeModal,
] = useModal(
state => [
state.import,
@@ -35,6 +37,7 @@ export const ModalController = () => {
state.login,
state.share,
state.premium,
+ state.node,
],
shallow
);
@@ -50,6 +53,7 @@ export const ModalController = () => {
<PremiumModal opened={premiumModal} onClose={() => setVisible("premium")(false)} />
<LoginModal opened={loginModal} onClose={() => setVisible("login")(false)} />
<ShareModal opened={shareModal} onClose={() => setVisible("share")(false)} />
+ <NodeModal opened={nodeModal} onClose={() => setVisible("node")(false)} />
</>
);
};
diff --git a/src/containers/Modals/HerowandModal/index.tsx b/src/containers/Modals/HerowandModal/index.tsx
index f91e43d3..c21aca21 100644
--- a/src/containers/Modals/HerowandModal/index.tsx
+++ b/src/containers/Modals/HerowandModal/index.tsx
@@ -10,8 +10,6 @@ export const HerowandModal = () => {
getInitialValueInEffect: true,
});
- console.log(isNewsVisible);
-
React.useEffect(() => {
if (isNewsVisible) setOpened(true);
else setOpened(false);
diff --git a/src/containers/Modals/NodeModal/index.tsx b/src/containers/Modals/NodeModal/index.tsx
index 53ff272d..e9d6b1a6 100644
--- a/src/containers/Modals/NodeModal/index.tsx
+++ b/src/containers/Modals/NodeModal/index.tsx
@@ -1,6 +1,7 @@
import React from "react";
-import { Modal, Stack, Text, ScrollArea, ModalProps } from "@mantine/core";
+import { Modal, Stack, Text, ScrollArea, ModalProps, Button } from "@mantine/core";
import { Prism } from "@mantine/prism";
+import { FiExternalLink } from "react-icons/fi";
import { shallow } from "zustand/shallow";
import useGraph from "src/store/useGraph";
import { dataToString } from "src/utils/dataToString";
@@ -24,11 +25,17 @@ const CodeBlock: React.FC<{ children: any }> = ({ children }) => {
};
export const NodeModal: React.FC<ModalProps> = ({ opened, onClose }) => {
- const [nodeData, path] = useGraph(
- state => [dataToString(state.selectedNode.text), state.selectedNode.path],
+ const [nodeData, path, isParent] = useGraph(
+ state => [
+ dataToString(state.selectedNode.text),
+ state.selectedNode.path,
+ state.selectedNode.data?.isParent,
+ ],
shallow
);
+ const isEditVisible = path !== "{Root}" && !isParent;
+
return (
<Modal title="Node Content" size="auto" opened={opened} onClose={onClose} centered>
<Stack py="sm" spacing="sm">
@@ -38,6 +45,17 @@ export const NodeModal: React.FC<ModalProps> = ({ opened, onClose }) => {
</Text>
<CodeBlock>{nodeData}</CodeBlock>
</Stack>
+ {isEditVisible && (
+ <Button
+ component="a"
+ href="https://editor.herowand.com"
+ leftIcon={<FiExternalLink />}
+ variant="filled"
+ >
+ Edit
+ </Button>
+ )}
+
<Stack spacing="xs">
<Text fz="sm" fw={700}>
Node Path
diff --git a/src/hooks/useFocusNode.tsx b/src/hooks/useFocusNode.tsx
index 549e7701..9bbca0cb 100644
--- a/src/hooks/useFocusNode.tsx
+++ b/src/hooks/useFocusNode.tsx
@@ -1,4 +1,5 @@
import React from "react";
+import { useDebouncedValue } from "@mantine/hooks";
import useGraph from "src/store/useGraph";
import { searchQuery, cleanupHighlight, highlightMatchedNodes } from "src/utils/search";
@@ -6,28 +7,15 @@ export const useFocusNode = () => {
const zoomPanPinch = useGraph(state => state.zoomPanPinch);
const [selectedNode, setSelectedNode] = React.useState(0);
const [nodeCount, setNodeCount] = React.useState(0);
- const [content, setContent] = React.useState({
- value: "",
- debounced: "",
- });
+ const [value, setValue] = React.useState("");
+ const [debouncedValue] = useDebouncedValue(value, 600);
const skip = () => setSelectedNode(current => current + 1);
- React.useEffect(() => {
- const debouncer = setTimeout(() => {
- setContent(val => ({ ...val, debounced: content.value }));
- }, 800);
-
- return () => clearTimeout(debouncer);
- }, [content.value]);
-
React.useEffect(() => {
if (!zoomPanPinch) return;
+ const matchedNodes: NodeListOf<Element> = searchQuery(`span[data-key*='${debouncedValue}' i]`);
const ref = zoomPanPinch.instance.wrapperComponent;
-
- const matchedNodes: NodeListOf<Element> = searchQuery(
- `span[data-key*='${content.debounced}' i]`
- );
const matchedNode: Element | null = matchedNodes[selectedNode] || null;
cleanupHighlight();
@@ -46,7 +34,6 @@ export const useFocusNode = () => {
(ref.offsetLeft - y) * newScale +
ref.clientHeight / 8 -
matchedNode.getBoundingClientRect().height / 8;
-
highlightMatchedNodes(matchedNodes, selectedNode);
setNodeCount(matchedNodes.length);
@@ -57,12 +44,12 @@ export const useFocusNode = () => {
}
return () => {
- if (!content.value) {
+ if (!value) {
setSelectedNode(0);
setNodeCount(0);
}
};
- }, [content.debounced, content, selectedNode, zoomPanPinch]);
+ }, [selectedNode, debouncedValue, value, zoomPanPinch]);
- return [content, setContent, skip, nodeCount, selectedNode] as const;
+ return [value, setValue, skip, nodeCount, selectedNode] as const;
};
diff --git a/src/hooks/useToggleHide.ts b/src/hooks/useToggleHide.ts
new file mode 100644
index 00000000..f2dea0c6
--- /dev/null
+++ b/src/hooks/useToggleHide.ts
@@ -0,0 +1,39 @@
+import React from "react";
+import useGraph from "src/store/useGraph";
+
+const useToggleHide = () => {
+ const collapsedNodes = useGraph(state => state.collapsedNodes);
+ const collapsedEdges = useGraph(state => state.collapsedEdges);
+
+ const nodeList = React.useMemo(
+ () => collapsedNodes.map(id => `[id$="node-${id}"]`),
+ [collapsedNodes]
+ );
+ const edgeList = React.useMemo(
+ () => collapsedEdges.map(id => `[class$="edge-${id}"]`),
+ [collapsedEdges]
+ );
+
+ const validateHiddenNodes = React.useCallback(() => {
+ const hiddenItems = document.body.querySelectorAll(".hide");
+ hiddenItems.forEach(item => item.classList.remove("hide"));
+
+ if (nodeList.length) {
+ const selectedNodes = document.body.querySelectorAll(nodeList.join(","));
+ selectedNodes.forEach(node => node.classList.add("hide"));
+ }
+
+ if (edgeList.length) {
+ const selectedEdges = document.body.querySelectorAll(edgeList.join(","));
+ selectedEdges.forEach(edge => edge.classList.add("hide"));
+ }
+ }, [nodeList, edgeList]);
+
+ React.useEffect(() => {
+ validateHiddenNodes();
+ }, [validateHiddenNodes]);
+
+ return { validateHiddenNodes };
+};
+
+export default useToggleHide;
diff --git a/src/components/Footer/index.tsx b/src/layout/Footer/index.tsx
similarity index 100%
rename from src/components/Footer/index.tsx
rename to src/layout/Footer/index.tsx
diff --git a/src/components/Loading/index.tsx b/src/layout/Loading/index.tsx
similarity index 100%
rename from src/components/Loading/index.tsx
rename to src/layout/Loading/index.tsx
diff --git a/src/components/Navbar/index.tsx b/src/layout/Navbar/index.tsx
similarity index 100%
rename from src/components/Navbar/index.tsx
rename to src/layout/Navbar/index.tsx
diff --git a/src/components/Producthunt/index.tsx b/src/layout/Producthunt/index.tsx
similarity index 100%
rename from src/components/Producthunt/index.tsx
rename to src/layout/Producthunt/index.tsx
diff --git a/src/pages/docs.tsx b/src/pages/docs.tsx
index c12ee29c..85000a6b 100644
--- a/src/pages/docs.tsx
+++ b/src/pages/docs.tsx
@@ -4,7 +4,7 @@ import Head from "next/head";
import styled from "styled-components";
import { Button } from "@mantine/core";
import materialDark from "react-syntax-highlighter/dist/cjs/styles/prism/material-dark";
-import { Footer } from "src/components/Footer";
+import { Footer } from "src/layout/Footer";
const SyntaxHighlighter = dynamic(() => import("react-syntax-highlighter/dist/cjs/prism-async"), {
ssr: false,
diff --git a/src/pages/editor.tsx b/src/pages/editor.tsx
index 8e010ef3..9a2b4fc5 100644
--- a/src/pages/editor.tsx
+++ b/src/pages/editor.tsx
@@ -2,17 +2,15 @@ import React from "react";
import Head from "next/head";
import { useRouter } from "next/router";
import styled from "styled-components";
-import { Loading } from "src/components/Loading";
-import { Sidebar } from "src/components/Sidebar";
import { BottomBar } from "src/containers/Editor/BottomBar";
+import { Tools } from "src/containers/Editor/LiveEditor/Tools";
import Panes from "src/containers/Editor/Panes";
+import { Loading } from "src/layout/Loading";
import useJson from "src/store/useJson";
import useUser from "src/store/useUser";
export const StyledPageWrapper = styled.div`
- display: flex;
- flex-direction: row;
- height: calc(100vh - 28px);
+ height: calc(100vh - 27px);
width: 100%;
@media only screen and (max-width: 768px) {
@@ -52,7 +50,7 @@ const EditorPage: React.FC = () => {
<meta name="description" content="View your JSON data in graphs instantly." />
</Head>
<StyledPageWrapper>
- <Sidebar />
+ <Tools />
<StyledEditorWrapper>
<Panes />
</StyledEditorWrapper>
diff --git a/src/pages/pricing.tsx b/src/pages/pricing.tsx
index f228c8e9..70f2b885 100644
--- a/src/pages/pricing.tsx
+++ b/src/pages/pricing.tsx
@@ -1,8 +1,8 @@
import React from "react";
import styled from "styled-components";
import { Button } from "@mantine/core";
-import { Footer } from "src/components/Footer";
import { PricingCards } from "src/containers/PricingCards";
+import { Footer } from "src/layout/Footer";
const StyledPageWrapper = styled.div`
padding: 5%;
diff --git a/src/pages/sign-in.tsx b/src/pages/sign-in.tsx
index d4a35e46..9321b263 100644
--- a/src/pages/sign-in.tsx
+++ b/src/pages/sign-in.tsx
@@ -6,8 +6,8 @@ import styled from "styled-components";
import { Button, Center, Container, Stack } from "@mantine/core";
import { AiOutlineGithub, AiOutlineGoogle } from "react-icons/ai";
import { altogic } from "src/api/altogic";
-import { Footer } from "src/components/Footer";
-import { Navbar } from "src/components/Navbar";
+import { Footer } from "src/layout/Footer";
+import { Navbar } from "src/layout/Navbar";
import useUser from "src/store/useUser";
const StyledPageWrapper = styled.div`
diff --git a/src/store/useJson.tsx b/src/store/useJson.tsx
index bb2d4fb6..1d340fc4 100644
--- a/src/store/useJson.tsx
+++ b/src/store/useJson.tsx
@@ -111,7 +111,7 @@ const useJson = create<JsonStates & JsonActions>()((set, get) => ({
return undefined;
}
},
- setError: (hasError: boolean) => set({ hasError }),
+ setError: hasError => set({ hasError }),
setHasChanges: (hasChanges: boolean) => set({ hasChanges }),
}));