diff --git a/packages/components/package.json b/packages/components/package.json index aa62c4a3..db9b3160 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -3,6 +3,8 @@ "version": "0.2.20", "license": "MIT", "dependencies": { + "@headlessui/react": "^1.6.4", + "@heroicons/react": "^1.0.6", "@hookform/resolvers": "^2.8.10", "@quri/squiggle-lang": "^0.2.8", "@react-hook/size": "^2.1.2", diff --git a/packages/components/src/components/CodeEditor.tsx b/packages/components/src/components/CodeEditor.tsx index b052d7e1..473afd93 100644 --- a/packages/components/src/components/CodeEditor.tsx +++ b/packages/components/src/components/CodeEditor.tsx @@ -29,6 +29,7 @@ export let CodeEditor: FC = ({ mode="golang" theme="github" width={"100%"} + fontSize={14} height={String(height) + "px"} minLines={oneLine ? lineCount : undefined} maxLines={oneLine ? lineCount : undefined} diff --git a/packages/components/src/components/ErrorBox.tsx b/packages/components/src/components/ErrorBox.tsx index eb34b9d5..1eaed201 100644 --- a/packages/components/src/components/ErrorBox.tsx +++ b/packages/components/src/components/ErrorBox.tsx @@ -1,12 +1,21 @@ import * as React from "react"; +import { XCircleIcon } from "@heroicons/react/solid"; + export const ErrorBox: React.FC<{ heading: string; children: React.ReactNode; }> = ({ heading = "Error", children }) => { return ( -
-

{heading}

- {children} +
+
+
+
+
+

{heading}

+
{children}
+
+
); -}; +}; \ No newline at end of file diff --git a/packages/components/src/components/SquiggleChart.tsx b/packages/components/src/components/SquiggleChart.tsx index 08586dcc..3b4232ce 100644 --- a/packages/components/src/components/SquiggleChart.tsx +++ b/packages/components/src/components/SquiggleChart.tsx @@ -54,7 +54,7 @@ export const VariableBox: React.FC = ({ return (
-

{heading}

+

{heading}

{children}
diff --git a/packages/components/src/components/SquigglePlayground.tsx b/packages/components/src/components/SquigglePlayground.tsx index cf02c96b..a66d33b9 100644 --- a/packages/components/src/components/SquigglePlayground.tsx +++ b/packages/components/src/components/SquigglePlayground.tsx @@ -8,6 +8,9 @@ import { useForm, useWatch } from "react-hook-form"; import * as yup from "yup"; import { yupResolver } from "@hookform/resolvers/yup"; import { defaultBindings, environment } from "@quri/squiggle-lang"; +import { Tab } from "@headlessui/react"; +import { CodeIcon } from "@heroicons/react/solid"; +import { CogIcon } from "@heroicons/react/solid"; interface ShowBoxProps { height: number; @@ -15,9 +18,7 @@ interface ShowBoxProps { } const ShowBox: React.FC = ({ height, children }) => ( -
- {children} -
+
{children}
); interface TitleProps { @@ -26,12 +27,7 @@ interface TitleProps { } const Display: React.FC = ({ maxHeight, children }) => ( -
- {children} -
+
{children}
); interface PlaygroundProps { @@ -88,12 +84,70 @@ type InputProps = { }; const InputItem: React.FC = ({ label, children }) => ( -
- - {children} +
+ +
{children}
); +let numberStyle = + "max-w-lg block w-full shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:max-w-xs sm:text-sm border-gray-300 rounded-md"; +let checkboxStyle = + "focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300 rounded"; + +const tabs = [ + { name: "Editor", href: "#", current: true }, + { name: "Settings", href: "#", current: false }, +]; + +function classNames(...classes) { + return classes.filter(Boolean).join(" "); +} + +function Example() { + return ( +
+
+ + {/* Use an "onChange" listener to redirect the user to the selected tab URL. */} + +
+
+
+ +
+
+
+ ); +} + let SquigglePlayground: FC = ({ initialSquiggleString = "", height = 500, @@ -142,80 +196,186 @@ let SquigglePlayground: FC = ({ setImportsAreValid(false); } }; + + let tab = (key, icon) => ( + + classNames( + "whitespace-nowrap pb-1 pt-2 px-1 border-b-2 font-medium text-sm focus-within:outline-none group inline-flex items-center", + selected + ? "border-slate-400 text-gray-500" + : "border-transparent text-gray-400 hover:text-gray-600 hover:border-slate-300" + ) + } + > + {icon} + {key} + + ); + return ( - - -
-
- {vars.showSettingsPage ? ( - <> - - - - - - - - - - - - - - - - - - - - - - - <> - + +
+
+
+ + {tab( + "Code", + +
+
+
+
+
+ + + + + + <> +
+ + <> + +

+ How many samples to use for Monte Carlo simulations. + This can be overridden by specific programs. +

+ +
+ + <> + +

+ When distributions are converted into PointSet shapes, + we need to know how many coordinates to use. +

+ +
+ + + + + + +
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+ + <> + + {importsAreValid ? "Valid" : "Invalid"} + + +
- - - ) : ( - - )} +
+
+
+ +
+
+ +
+
-
- - - -
-
- + +
); }; export default SquigglePlayground; diff --git a/yarn.lock b/yarn.lock index 282fcbaf..af03d222 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1824,6 +1824,16 @@ dependencies: "@hapi/hoek" "^9.0.0" +"@headlessui/react@^1.6.4": + version "1.6.4" + resolved "https://registry.yarnpkg.com/@headlessui/react/-/react-1.6.4.tgz#c73084e23386bef5fb86cd16da3352c3a844bb4c" + integrity sha512-0yqz1scwbFtwljmbbKjXsSGl5ABEYNICVHZnMCWo0UtOZodo2Tpu94uOVgCRjRZ77l2WcTi2S0uidINDvG7lsA== + +"@heroicons/react@^1.0.6": + version "1.0.6" + resolved "https://registry.yarnpkg.com/@heroicons/react/-/react-1.0.6.tgz#35dd26987228b39ef2316db3b1245c42eb19e324" + integrity sha512-JJCXydOFWMDpCP4q13iEplA503MQO3xLoZiKum+955ZCtHINWnx26CUxVxxFQu/uLb4LW3ge15ZpzIkXKkJ8oQ== + "@hookform/resolvers@^2.8.10": version "2.8.10" resolved "https://registry.yarnpkg.com/@hookform/resolvers/-/resolvers-2.8.10.tgz#b66d7a7848b1b1dd5b976a73fff36bb366666e7d"