@@ -1,8 +1,9 @@
|
|||||||
import React from "react";
|
|
||||||
import dynamic from "next/dynamic";
|
import dynamic from "next/dynamic";
|
||||||
|
import React from "react";
|
||||||
|
import Split from "react-split";
|
||||||
import { useSnapshot } from "valtio";
|
import { useSnapshot } from "valtio";
|
||||||
import state from "../../state";
|
import state from "../../state";
|
||||||
import Split from "react-split";
|
import { getSplit, saveSplit } from "../../state/actions/persistSplits";
|
||||||
|
|
||||||
const DeployEditor = dynamic(() => import("../../components/DeployEditor"), {
|
const DeployEditor = dynamic(() => import("../../components/DeployEditor"), {
|
||||||
ssr: false,
|
ssr: false,
|
||||||
@@ -17,21 +18,22 @@ const LogBox = dynamic(() => import("../../components/LogBox"), {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const Deploy = () => {
|
const Deploy = () => {
|
||||||
const snap = useSnapshot(state);
|
const { deployLogs } = useSnapshot(state);
|
||||||
return (
|
return (
|
||||||
<Split
|
<Split
|
||||||
direction="vertical"
|
direction="vertical"
|
||||||
gutterSize={4}
|
gutterSize={4}
|
||||||
gutterAlign="center"
|
gutterAlign="center"
|
||||||
sizes={[40, 60]}
|
sizes={getSplit("deployVertical") || [40, 60]}
|
||||||
style={{ height: "calc(100vh - 60px)" }}
|
style={{ height: "calc(100vh - 60px)" }}
|
||||||
|
onDragEnd={(e) => saveSplit("deployVertical", e)}
|
||||||
>
|
>
|
||||||
<main style={{ display: "flex", flex: 1, position: "relative" }}>
|
<main style={{ display: "flex", flex: 1, position: "relative" }}>
|
||||||
<DeployEditor />
|
<DeployEditor />
|
||||||
</main>
|
</main>
|
||||||
<Split
|
<Split
|
||||||
direction="horizontal"
|
direction="horizontal"
|
||||||
sizes={[50, 50]}
|
sizes={getSplit("deployHorizontal") || [50, 50]}
|
||||||
minSize={[320, 160]}
|
minSize={[320, 160]}
|
||||||
gutterSize={4}
|
gutterSize={4}
|
||||||
gutterAlign="center"
|
gutterAlign="center"
|
||||||
@@ -41,6 +43,7 @@ const Deploy = () => {
|
|||||||
width: "100%",
|
width: "100%",
|
||||||
height: "100%",
|
height: "100%",
|
||||||
}}
|
}}
|
||||||
|
onDragEnd={(e) => saveSplit("deployHorizontal", e)}
|
||||||
>
|
>
|
||||||
<div style={{ alignItems: "stretch", display: "flex" }}>
|
<div style={{ alignItems: "stretch", display: "flex" }}>
|
||||||
<Accounts />
|
<Accounts />
|
||||||
@@ -48,7 +51,7 @@ const Deploy = () => {
|
|||||||
<div>
|
<div>
|
||||||
<LogBox
|
<LogBox
|
||||||
title="Deploy Log"
|
title="Deploy Log"
|
||||||
logs={snap.deployLogs}
|
logs={deployLogs}
|
||||||
clearLog={() => (state.deployLogs = [])}
|
clearLog={() => (state.deployLogs = [])}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -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 type { NextPage } from "next";
|
||||||
import { compileCode } from "../../state/actions";
|
import dynamic from "next/dynamic";
|
||||||
import state from "../../state";
|
import { Play } from "phosphor-react";
|
||||||
import Button from "../../components/Button";
|
import Hotkeys from "react-hot-keys";
|
||||||
|
import Split from "react-split";
|
||||||
|
import { useSnapshot } from "valtio";
|
||||||
import Box from "../../components/Box";
|
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"), {
|
const HooksEditor = dynamic(() => import("../../components/HooksEditor"), {
|
||||||
ssr: false,
|
ssr: false,
|
||||||
@@ -24,11 +25,12 @@ const Home: NextPage = () => {
|
|||||||
return (
|
return (
|
||||||
<Split
|
<Split
|
||||||
direction="vertical"
|
direction="vertical"
|
||||||
sizes={[70, 30]}
|
sizes={getSplit("developVertical") || [70, 30]}
|
||||||
minSize={[100, 100]}
|
minSize={[100, 100]}
|
||||||
gutterAlign="center"
|
gutterAlign="center"
|
||||||
gutterSize={4}
|
gutterSize={4}
|
||||||
style={{ height: "calc(100vh - 60px)" }}
|
style={{ height: "calc(100vh - 60px)" }}
|
||||||
|
onDragEnd={(e) => saveSplit("developVertical", e)}
|
||||||
>
|
>
|
||||||
<main style={{ display: "flex", flex: 1, position: "relative" }}>
|
<main style={{ display: "flex", flex: 1, position: "relative" }}>
|
||||||
<HooksEditor />
|
<HooksEditor />
|
||||||
|
|||||||
@@ -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 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 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 state from "../../state";
|
||||||
import { sendTransaction } from "../../state/actions";
|
import { sendTransaction } from "../../state/actions";
|
||||||
import { useCallback, useEffect, useState, FC } from "react";
|
import { getSplit, saveSplit } from "../../state/actions/persistSplits";
|
||||||
import transactionsData from "../../content/transactions.json";
|
|
||||||
|
|
||||||
const DebugStream = dynamic(() => import("../../components/DebugStream"), {
|
const DebugStream = dynamic(() => import("../../components/DebugStream"), {
|
||||||
ssr: false,
|
ssr: false,
|
||||||
@@ -349,16 +344,17 @@ const Transaction: FC<Props> = ({ header, ...props }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const Test = () => {
|
const Test = () => {
|
||||||
const snap = useSnapshot(state);
|
const { transactionLogs } = useSnapshot(state);
|
||||||
const [tabHeaders, setTabHeaders] = useState<string[]>(["test1.json"]);
|
const [tabHeaders, setTabHeaders] = useState<string[]>(["test1.json"]);
|
||||||
return (
|
return (
|
||||||
<Container css={{ px: 0 }}>
|
<Container css={{ px: 0 }}>
|
||||||
<Split
|
<Split
|
||||||
direction="vertical"
|
direction="vertical"
|
||||||
sizes={[50, 50]}
|
sizes={getSplit("testVertical") || [50, 50]}
|
||||||
gutterSize={4}
|
gutterSize={4}
|
||||||
gutterAlign="center"
|
gutterAlign="center"
|
||||||
style={{ height: "calc(100vh - 60px)" }}
|
style={{ height: "calc(100vh - 60px)" }}
|
||||||
|
onDragEnd={(e) => saveSplit("testVertical", e)}
|
||||||
>
|
>
|
||||||
<Flex
|
<Flex
|
||||||
row
|
row
|
||||||
@@ -370,7 +366,7 @@ const Test = () => {
|
|||||||
>
|
>
|
||||||
<Split
|
<Split
|
||||||
direction="horizontal"
|
direction="horizontal"
|
||||||
sizes={[50, 50]}
|
sizes={getSplit("testHorizontal") || [50, 50]}
|
||||||
minSize={[180, 320]}
|
minSize={[180, 320]}
|
||||||
gutterSize={4}
|
gutterSize={4}
|
||||||
gutterAlign="center"
|
gutterAlign="center"
|
||||||
@@ -380,6 +376,7 @@ const Test = () => {
|
|||||||
width: "100%",
|
width: "100%",
|
||||||
height: "100%",
|
height: "100%",
|
||||||
}}
|
}}
|
||||||
|
onDragEnd={(e) => saveSplit("testHorizontal", e)}
|
||||||
>
|
>
|
||||||
<Box css={{ width: "55%", px: "$2" }}>
|
<Box css={{ width: "55%", px: "$2" }}>
|
||||||
<Tabs
|
<Tabs
|
||||||
@@ -428,7 +425,7 @@ const Test = () => {
|
|||||||
>
|
>
|
||||||
<LogBox
|
<LogBox
|
||||||
title="Development Log"
|
title="Development Log"
|
||||||
logs={snap.transactionLogs}
|
logs={transactionLogs}
|
||||||
clearLog={() => (state.transactionLogs = [])}
|
clearLog={() => (state.transactionLogs = [])}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
15
state/actions/persistSplits.ts
Normal file
15
state/actions/persistSplits.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import { snapshot } from "valtio"
|
||||||
|
import state from ".."
|
||||||
|
|
||||||
|
export type SplitSize = number[]
|
||||||
|
|
||||||
|
export const saveSplit = (splitId: string, event: SplitSize) => {
|
||||||
|
state.splits[splitId] = event
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getSplit = (splitId: string): SplitSize | null => {
|
||||||
|
const { splits } = snapshot(state)
|
||||||
|
const split = splits[splitId]
|
||||||
|
return split ? split : null
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
import { proxy, ref, subscribe } from "valtio";
|
|
||||||
import { devtools } from 'valtio/utils'
|
|
||||||
import type monaco from "monaco-editor";
|
import type monaco from "monaco-editor";
|
||||||
|
import { proxy, ref, subscribe } from "valtio";
|
||||||
|
import { devtools } from 'valtio/utils';
|
||||||
import { XrplClient } from "xrpl-client";
|
import { XrplClient } from "xrpl-client";
|
||||||
|
import { SplitSize } from "./actions/persistSplits";
|
||||||
|
|
||||||
export interface IFile {
|
export interface IFile {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -56,6 +57,9 @@ export interface IState {
|
|||||||
editorSettings: {
|
editorSettings: {
|
||||||
tabSize: number;
|
tabSize: number;
|
||||||
};
|
};
|
||||||
|
splits: {
|
||||||
|
[id: string]: SplitSize
|
||||||
|
};
|
||||||
client: XrplClient | null;
|
client: XrplClient | null;
|
||||||
clientStatus: "offline" | "online";
|
clientStatus: "offline" | "online";
|
||||||
mainModalOpen: boolean;
|
mainModalOpen: boolean;
|
||||||
@@ -84,6 +88,7 @@ let initialState: IState = {
|
|||||||
editorSettings: {
|
editorSettings: {
|
||||||
tabSize: 2,
|
tabSize: 2,
|
||||||
},
|
},
|
||||||
|
splits: {},
|
||||||
client: null,
|
client: null,
|
||||||
clientStatus: "offline" as "offline",
|
clientStatus: "offline" as "offline",
|
||||||
mainModalOpen: false,
|
mainModalOpen: false,
|
||||||
@@ -92,6 +97,9 @@ let initialState: IState = {
|
|||||||
|
|
||||||
let localStorageAccounts: string | null = null;
|
let localStorageAccounts: string | null = null;
|
||||||
let initialAccounts: IAccount[] = [];
|
let initialAccounts: IAccount[] = [];
|
||||||
|
|
||||||
|
// TODO: What exactly should we store in localStorage? editorSettings, splits, accounts?
|
||||||
|
|
||||||
// Check if there's a persited accounts in localStorage
|
// Check if there's a persited accounts in localStorage
|
||||||
if (typeof window !== "undefined") {
|
if (typeof window !== "undefined") {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user