diff --git a/pages/deploy/[[...slug]].tsx b/pages/deploy/[[...slug]].tsx index 1614fa6..370151f 100644 --- a/pages/deploy/[[...slug]].tsx +++ b/pages/deploy/[[...slug]].tsx @@ -1,8 +1,9 @@ -import React from "react"; import dynamic from "next/dynamic"; +import React from "react"; +import Split from "react-split"; import { useSnapshot } from "valtio"; import state from "../../state"; -import Split from "react-split"; +import { getSplit, saveSplit } from "../../state/actions/persistSplits"; const DeployEditor = dynamic(() => import("../../components/DeployEditor"), { ssr: false, @@ -17,21 +18,22 @@ const LogBox = dynamic(() => import("../../components/LogBox"), { }); const Deploy = () => { - const snap = useSnapshot(state); + const { deployLogs } = useSnapshot(state); return ( saveSplit("deployVertical", e)} >
{ width: "100%", height: "100%", }} + onDragEnd={(e) => saveSplit("deployHorizontal", e)} >
@@ -48,7 +51,7 @@ const Deploy = () => {
(state.deployLogs = [])} />
diff --git a/pages/develop/[[...slug]].tsx b/pages/develop/[[...slug]].tsx index d094997..d3de800 100644 --- a/pages/develop/[[...slug]].tsx +++ b/pages/develop/[[...slug]].tsx @@ -1,14 +1,15 @@ -import dynamic from "next/dynamic"; -import { useSnapshot } from "valtio"; -import Hotkeys from "react-hot-keys"; -import { Play } from "phosphor-react"; -import Split from "react-split"; - import type { NextPage } from "next"; -import { compileCode } from "../../state/actions"; -import state from "../../state"; -import Button from "../../components/Button"; +import dynamic from "next/dynamic"; +import { Play } from "phosphor-react"; +import Hotkeys from "react-hot-keys"; +import Split from "react-split"; +import { useSnapshot } from "valtio"; import Box from "../../components/Box"; +import Button from "../../components/Button"; +import state from "../../state"; +import { compileCode } from "../../state/actions"; +import { getSplit, saveSplit } from "../../state/actions/persistSplits"; + const HooksEditor = dynamic(() => import("../../components/HooksEditor"), { ssr: false, @@ -24,11 +25,12 @@ const Home: NextPage = () => { return ( saveSplit("developVertical", e)} >
diff --git a/pages/test/[[...slug]].tsx b/pages/test/[[...slug]].tsx index 2d0bdeb..4fc3be3 100644 --- a/pages/test/[[...slug]].tsx +++ b/pages/test/[[...slug]].tsx @@ -1,22 +1,17 @@ -import { - Container, - Flex, - Box, - Tabs, - Tab, - Input, - Select, - Text, - Button, -} from "../../components"; -import { Play } from "phosphor-react"; import dynamic from "next/dynamic"; -import { useSnapshot } from "valtio"; +import { Play } from "phosphor-react"; +import { FC, useCallback, useEffect, useState } from "react"; import Split from "react-split"; +import { useSnapshot } from "valtio"; +import { + Box, Button, Container, + Flex, Input, + Select, Tab, Tabs, Text +} from "../../components"; +import transactionsData from "../../content/transactions.json"; import state from "../../state"; import { sendTransaction } from "../../state/actions"; -import { useCallback, useEffect, useState, FC } from "react"; -import transactionsData from "../../content/transactions.json"; +import { getSplit, saveSplit } from "../../state/actions/persistSplits"; const DebugStream = dynamic(() => import("../../components/DebugStream"), { ssr: false, @@ -349,16 +344,17 @@ const Transaction: FC = ({ header, ...props }) => { }; const Test = () => { - const snap = useSnapshot(state); + const { transactionLogs, splits } = useSnapshot(state); const [tabHeaders, setTabHeaders] = useState(["test1.json"]); return ( saveSplit("testVertical", e)} > { > { width: "100%", height: "100%", }} + onDragEnd={(e) => saveSplit("testHorizontal", e)} > { > (state.transactionLogs = [])} /> diff --git a/state/actions/persistSplits.ts b/state/actions/persistSplits.ts new file mode 100644 index 0000000..9d23619 --- /dev/null +++ b/state/actions/persistSplits.ts @@ -0,0 +1,16 @@ +import { snapshot } from "valtio" +import state from ".." + +export type SplitSize = number[] + +export const saveSplit = (splitId: string, event: SplitSize) => { + console.log(splitId, event) + state.splits[splitId] = event +} + +export const getSplit = (splitId: string): SplitSize | null => { + const { splits } = snapshot(state) + const split = splits[splitId] + return split ? split : null +} + diff --git a/state/index.ts b/state/index.ts index 1b7cbed..661426d 100644 --- a/state/index.ts +++ b/state/index.ts @@ -1,7 +1,8 @@ -import { proxy, ref, subscribe } from "valtio"; -import { devtools } from 'valtio/utils' import type monaco from "monaco-editor"; +import { proxy, ref, subscribe } from "valtio"; +import { devtools } from 'valtio/utils'; import { XrplClient } from "xrpl-client"; +import { SplitSize } from "./actions/persistSplits"; export interface IFile { name: string; @@ -55,6 +56,9 @@ export interface IState { editorSettings: { tabSize: number; }; + splits: { + [id: string]: SplitSize + }; client: XrplClient | null; clientStatus: "offline" | "online"; mainModalOpen: boolean; @@ -83,6 +87,7 @@ let initialState: IState = { editorSettings: { tabSize: 2, }, + splits: {}, client: null, clientStatus: "offline" as "offline", mainModalOpen: false, @@ -139,4 +144,4 @@ if (typeof window !== "undefined") { } }); } -export default state \ No newline at end of file +export default state