Lint components

This commit is contained in:
Sam Nolan 2022-05-02 17:01:09 +00:00
parent 213808d3aa
commit 8452995c31
2 changed files with 25 additions and 24 deletions

View File

@ -6,7 +6,7 @@ import { distributionErrorToString } from "@quri/squiggle-lang";
import { createClassFromSpec } from "react-vega"; import { createClassFromSpec } from "react-vega";
import * as chartSpecification from "../vega-specs/spec-distributions.json"; import * as chartSpecification from "../vega-specs/spec-distributions.json";
import { ErrorBox } from "./ErrorBox"; import { ErrorBox } from "./ErrorBox";
import { useSize } from 'react-use'; import { useSize } from "react-use";
let SquiggleVegaChart = createClassFromSpec({ let SquiggleVegaChart = createClassFromSpec({
spec: chartSpecification as Spec, spec: chartSpecification as Spec,
@ -23,12 +23,12 @@ export const DistributionChart: React.FC<DistributionChartProps> = ({
height, height,
width, width,
}: DistributionChartProps) => { }: DistributionChartProps) => {
const [sized, _] = useSize((size) => { const [sized, _] = useSize((size) => {
let shape = distribution.pointSet(); let shape = distribution.pointSet();
let widthProp = width !== undefined ? width - 20 : size.width - 10; let widthProp = width !== undefined ? width - 20 : size.width - 10;
if (shape.tag === "Ok") { if (shape.tag === "Ok") {
return ( <div> return (
<div>
<SquiggleVegaChart <SquiggleVegaChart
data={{ con: shape.value.continuous, dis: shape.value.discrete }} data={{ con: shape.value.continuous, dis: shape.value.discrete }}
width={widthProp} width={widthProp}
@ -38,13 +38,14 @@ export const DistributionChart: React.FC<DistributionChartProps> = ({
</div> </div>
); );
} else { } else {
return (<div> return (
<div>
<ErrorBox heading="Distribution Error"> <ErrorBox heading="Distribution Error">
{distributionErrorToString(shape.value)} {distributionErrorToString(shape.value)}
</ErrorBox> </ErrorBox>
</div> </div>
) );
} }
}) });
return sized; return sized;
}; };

View File

@ -121,7 +121,7 @@ const SquiggleItem: React.FC<SquiggleItemProps> = ({
<RecordKeyHeader>{key}</RecordKeyHeader> <RecordKeyHeader>{key}</RecordKeyHeader>
<SquiggleItem <SquiggleItem
expression={r} expression={r}
width={width !== undefined? width - 20 : width} width={width !== undefined ? width - 20 : width}
height={50} height={50}
/> />
</> </>