From f156840d652612b81fd9b3cabe3d2fc89045c462 Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Fri, 17 Jun 2022 07:31:59 -0700 Subject: [PATCH 1/4] Added toggle to optionally display code editor --- .../src/components/SquigglePlayground.tsx | 112 ++++++++++++------ 1 file changed, 74 insertions(+), 38 deletions(-) diff --git a/packages/components/src/components/SquigglePlayground.tsx b/packages/components/src/components/SquigglePlayground.tsx index a0615ca4..18999d8d 100644 --- a/packages/components/src/components/SquigglePlayground.tsx +++ b/packages/components/src/components/SquigglePlayground.tsx @@ -9,6 +9,7 @@ import { CodeIcon, CogIcon, CurrencyDollarIcon, + EyeIcon, } from "@heroicons/react/solid"; import clsx from "clsx"; @@ -31,6 +32,7 @@ interface PlaygroundProps { showControls?: boolean; /** Whether to show the summary table in the playground */ showSummary?: boolean; + showEditor?: boolean; } const schema = yup @@ -64,6 +66,7 @@ const schema = yup showTypes: yup.boolean(), showControls: yup.boolean(), showSummary: yup.boolean(), + showEditor: yup.boolean(), showSettingsPage: yup.boolean().default(false), diagramStart: yup .number() @@ -196,6 +199,7 @@ const SquigglePlayground: FC = ({ showTypes = false, showControls = false, showSummary = false, + showEditor = true, }) => { const [squiggleString, setSquiggleString] = useState(initialSquiggleString); const [importString, setImportString] = useState("{}"); @@ -210,6 +214,7 @@ const SquigglePlayground: FC = ({ showTypes: showTypes, showControls: showControls, showSummary: showSummary, + showEditor: showEditor, leftSizePercent: 50, showSettingsPage: false, diagramStart: 0, @@ -276,6 +281,11 @@ const SquigglePlayground: FC = ({
+ = ({
); + let withEditor = ( +
+
+ + +
+ +
+
+ {samplingSettings} + {viewSettings} + {inputVariableSettings} +
+
+ +
+ +
+
+ ); + + let withoutEditor = ( + + + + + {samplingSettings} + {viewSettings} + {inputVariableSettings} + + ); + return (
- - + + -
-
-
- - -
- -
-
- {samplingSettings} - {viewSettings} - {inputVariableSettings} -
-
- -
-
- -
-
+ {vars.showEditor ? withEditor : withoutEditor}
From 8e7756fe35420e806bdd38e59fcf31da20562846 Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Fri, 17 Jun 2022 07:42:44 -0700 Subject: [PATCH 2/4] Added Module type display and better error message if no type is found --- .../components/src/components/SquiggleChart.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/components/src/components/SquiggleChart.tsx b/packages/components/src/components/SquiggleChart.tsx index 8bedd265..a8db5386 100644 --- a/packages/components/src/components/SquiggleChart.tsx +++ b/packages/components/src/components/SquiggleChart.tsx @@ -251,8 +251,20 @@ const SquiggleItem: React.FC = ({ ); } + case "module": { + return ( + + Internal Module + + ); + } default: { - return <>Should be unreachable; + return ( + <> + No display for type: {" "} + {expression.tag} + + ); } } }; From 342b5ba17b583804967b45071b73989239970c4b Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Fri, 17 Jun 2022 07:45:58 -0700 Subject: [PATCH 3/4] Tiny css cleanup --- .../src/components/SquigglePlayground.tsx | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/packages/components/src/components/SquigglePlayground.tsx b/packages/components/src/components/SquigglePlayground.tsx index 18999d8d..21e524bc 100644 --- a/packages/components/src/components/SquigglePlayground.tsx +++ b/packages/components/src/components/SquigglePlayground.tsx @@ -385,7 +385,7 @@ const SquigglePlayground: FC = ({ ); let withEditor = ( -
+
@@ -422,31 +422,33 @@ const SquigglePlayground: FC = ({ ); let withoutEditor = ( - - - - - {samplingSettings} - {viewSettings} - {inputVariableSettings} - +
+ + + + + {samplingSettings} + {viewSettings} + {inputVariableSettings} + +
); return (
- + Date: Fri, 17 Jun 2022 15:47:37 -0700 Subject: [PATCH 4/4] Refactors to address CR --- .../src/components/SquiggleItem.tsx | 4 +- .../src/components/SquigglePlayground.tsx | 69 ++++++++++--------- 2 files changed, 37 insertions(+), 36 deletions(-) diff --git a/packages/components/src/components/SquiggleItem.tsx b/packages/components/src/components/SquiggleItem.tsx index 48d5a226..a64df99e 100644 --- a/packages/components/src/components/SquiggleItem.tsx +++ b/packages/components/src/components/SquiggleItem.tsx @@ -252,10 +252,10 @@ export const SquiggleItem: React.FC = ({ } default: { return ( - <> +
No display for type: {" "} {expression.tag} - +
); } } diff --git a/packages/components/src/components/SquigglePlayground.tsx b/packages/components/src/components/SquigglePlayground.tsx index 6eefd513..08486d07 100644 --- a/packages/components/src/components/SquigglePlayground.tsx +++ b/packages/components/src/components/SquigglePlayground.tsx @@ -384,25 +384,31 @@ export const SquigglePlayground: FC = ({
); + const InFirstTab: React.FC<{ children: React.ReactNode }> = ({ + children, + }) => ( + + {children} + {samplingSettings} + {viewSettings} + {inputVariableSettings} + + ); + let withEditor = (
- - -
- -
-
- {samplingSettings} - {viewSettings} - {inputVariableSettings} -
+ +
+ +
+
@@ -423,24 +429,19 @@ export const SquigglePlayground: FC = ({ let withoutEditor = (
- - - - - {samplingSettings} - {viewSettings} - {inputVariableSettings} - + + +
);