From a13a01b0e42beda0ff5403750972f55205a85e2b Mon Sep 17 00:00:00 2001 From: Phanabani Date: Fri, 4 Nov 2022 12:02:41 -0400 Subject: [PATCH 01/12] Rearrange and add region comments. --- dev_app/src/components/Body.tsx | 66 ++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/dev_app/src/components/Body.tsx b/dev_app/src/components/Body.tsx index 0cbb6d5..69da681 100644 --- a/dev_app/src/components/Body.tsx +++ b/dev_app/src/components/Body.tsx @@ -37,6 +37,8 @@ type ReadOnlyCallback = ( ) => boolean; function Body() { + //region State + const [json, setJson] = useState(_.cloneDeep(defaultJson)); const [deltaUpdateString, setDeltaUpdateString] = useState("{}"); const [readOnly, setReadOnly] = useState(false); @@ -49,11 +51,36 @@ function Body() { const [readOnlyBooleanEnable, setReadOnlyBooleanEnable] = useState(false); const textareaRef = useRef(null); - const readOnlyBooleanRef = useRef(null); - const readOnlyFunctionRef = useRef(null); - const readOnlyRef = useRef(null); - const customInputRef = useRef(null); - const minusMenuRef = useRef(null); + + //endregion + //region Memos + + const style1 = { + width: "100%", + }; + const style2 = { + verticalAlign: "top", + }; + const style3 = { + backgroundColor: "#e0e0e0", + border: "1px lightgrey solid", + }; + const style4 = { + margin: "0 15px", + minWidth: "200px", + }; + const style5 = { + backgroundColor: "black", + color: "yellow", + border: "1px solid green", + }; + const customInputElement = customInput ? : undefined; + const minusMenuElement = minusMenu ? ( + + ) : undefined; + + //endregion + //region Callbacks const onFullyUpdate = useCallback((newJson: object) => { setGlobalUpdateString(JSON.stringify(newJson, null, 4)); @@ -145,31 +172,8 @@ function Body() { setDeltaUpdateString("{}"); }, []); - // Render - - const style1 = { - width: "100%", - }; - const style2 = { - verticalAlign: "top", - }; - const style3 = { - backgroundColor: "#e0e0e0", - border: "1px lightgrey solid", - }; - const style4 = { - margin: "0 15px", - minWidth: "200px", - }; - const style5 = { - backgroundColor: "black", - color: "yellow", - border: "1px solid green", - }; - const customInputElement = customInput ? : undefined; - const minusMenuElement = minusMenu ? ( - - ) : undefined; + //endregion + //region Render return (
@@ -287,6 +291,8 @@ function Body() {
); + + //endregion } export default Body; From 528de7c90c6a524a8ad29fa782c4c1556345101f Mon Sep 17 00:00:00 2001 From: Phanabani Date: Fri, 4 Nov 2022 12:09:26 -0400 Subject: [PATCH 02/12] Rename styles. --- dev_app/src/components/Body.tsx | 67 +++++++++++++++++---------------- 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/dev_app/src/components/Body.tsx b/dev_app/src/components/Body.tsx index 69da681..9b07170 100644 --- a/dev_app/src/components/Body.tsx +++ b/dev_app/src/components/Body.tsx @@ -10,6 +10,28 @@ import React, { useCallback, useRef, useState } from "react"; import { JsonTree } from "react-editable-json-tree"; import { trySetRefAttr } from "../utils/misc"; +const styles = { + table: { + width: "100%", + }, + cell: { + verticalAlign: "top", + }, + code: { + backgroundColor: "#e0e0e0", + border: "1px lightgrey solid", + }, + container: { + margin: "0 15px", + minWidth: "200px", + }, + customInput: { + backgroundColor: "black", + color: "yellow", + border: "1px solid green", + }, +}; + const defaultJson = { error: new Error("error"), func: () => { @@ -55,26 +77,7 @@ function Body() { //endregion //region Memos - const style1 = { - width: "100%", - }; - const style2 = { - verticalAlign: "top", - }; - const style3 = { - backgroundColor: "#e0e0e0", - border: "1px lightgrey solid", - }; - const style4 = { - margin: "0 15px", - minWidth: "200px", - }; - const style5 = { - backgroundColor: "black", - color: "yellow", - border: "1px solid green", - }; - const customInputElement = customInput ? : undefined; + const customInputElement = customInput ? : undefined; const minusMenuElement = minusMenu ? ( ) : undefined; @@ -177,7 +180,7 @@ function Body() { return (
-
+
- +
- - - -
@@ -250,8 +253,8 @@ function Body() {
-
+
+
-
-
{globalUpdateString}
+
+
+
{globalUpdateString}
-
-
{deltaUpdateString}
+
+
+
{deltaUpdateString}
-
+
+