From 2d0e6432cdb48109776d8298d3ebe6e77e333c70 Mon Sep 17 00:00:00 2001 From: Vyacheslav Matyukhin Date: Wed, 5 Oct 2022 17:10:53 +0400 Subject: [PATCH] fix #1199 --- packages/components/src/components/Alert.tsx | 2 +- .../src/components/FunctionChart.tsx | 36 +++++++++++++++---- .../components/SquiggleViewer/VariableBox.tsx | 4 +-- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/packages/components/src/components/Alert.tsx b/packages/components/src/components/Alert.tsx index bc2e2f92..cb579536 100644 --- a/packages/components/src/components/Alert.tsx +++ b/packages/components/src/components/Alert.tsx @@ -30,7 +30,7 @@ export const Alert: React.FC<{ className={clsx("h-5 w-5 flex-shrink-0", iconColor)} aria-hidden="true" /> -
+
{heading}
diff --git a/packages/components/src/components/FunctionChart.tsx b/packages/components/src/components/FunctionChart.tsx index 2da5d367..fda699e9 100644 --- a/packages/components/src/components/FunctionChart.tsx +++ b/packages/components/src/components/FunctionChart.tsx @@ -1,9 +1,15 @@ import * as React from "react"; -import { SqLambda, environment, SqValueTag } from "@quri/squiggle-lang"; +import { + SqLambda, + environment, + SqValueTag, + SqError, +} from "@quri/squiggle-lang"; import { FunctionChart1Dist } from "./FunctionChart1Dist"; import { FunctionChart1Number } from "./FunctionChart1Number"; import { DistributionPlottingSettings } from "./DistributionChart"; -import { ErrorAlert, MessageAlert } from "./Alert"; +import { MessageAlert } from "./Alert"; +import { SquiggleErrorAlert } from "./SquiggleErrorAlert"; export type FunctionChartSettings = { start: number; @@ -19,6 +25,25 @@ interface FunctionChartProps { height: number; } +const FunctionCallErrorAlert = ({ error }: { error: SqError }) => { + const [expanded, setExpanded] = React.useState(false); + if (expanded) { + } + return ( + +
+ setExpanded(!expanded)} + > + {expanded ? "Hide" : "Show"} error details + + {expanded ? : null} +
+
+ ); +}; + export const FunctionChart: React.FC = ({ fn, chartSettings, @@ -26,7 +51,8 @@ export const FunctionChart: React.FC = ({ distributionPlotSettings, height, }) => { - if (fn.parameters.length > 1) { + console.log(fn.parameters().length); + if (fn.parameters().length !== 1) { return ( Only functions with one parameter are displayed. @@ -47,9 +73,7 @@ export const FunctionChart: React.FC = ({ const validResult = getValidResult(); if (validResult.tag === "Error") { - return ( - {validResult.value.toString()} - ); + return ; } switch (validResult.value.tag) { diff --git a/packages/components/src/components/SquiggleViewer/VariableBox.tsx b/packages/components/src/components/SquiggleViewer/VariableBox.tsx index 9ad59597..ca0fc875 100644 --- a/packages/components/src/components/SquiggleViewer/VariableBox.tsx +++ b/packages/components/src/components/SquiggleViewer/VariableBox.tsx @@ -1,4 +1,4 @@ -import { SqValue, SqValueLocation } from "@quri/squiggle-lang"; +import { SqValue } from "@quri/squiggle-lang"; import React, { useContext, useReducer } from "react"; import { Tooltip } from "../ui/Tooltip"; import { LocalItemSettings, MergedItemSettings } from "./utils"; @@ -70,7 +70,7 @@ export const VariableBox: React.FC = ({
{location.path.items.length ? (
) : null}