Added simple input component for SquigglePlayground
This commit is contained in:
parent
7f6fe1a0aa
commit
afb7613bcc
|
@ -11,7 +11,6 @@ import { yupResolver } from "@hookform/resolvers/yup";
|
||||||
import {
|
import {
|
||||||
defaultBindings,
|
defaultBindings,
|
||||||
environment,
|
environment,
|
||||||
defaultImports,
|
|
||||||
} from "@quri/squiggle-lang";
|
} from "@quri/squiggle-lang";
|
||||||
|
|
||||||
interface FieldFloatProps {
|
interface FieldFloatProps {
|
||||||
|
@ -131,9 +130,19 @@ const schema = yup
|
||||||
})
|
})
|
||||||
.required();
|
.required();
|
||||||
|
|
||||||
|
type InputProps = {
|
||||||
|
label: string;
|
||||||
|
};
|
||||||
|
const InputItem: React.FC<InputProps> = ({ label, children }) => (
|
||||||
|
<div>
|
||||||
|
<label>{label}</label>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
let SquigglePlayground: FC<PlaygroundProps> = ({
|
let SquigglePlayground: FC<PlaygroundProps> = ({
|
||||||
initialSquiggleString = "",
|
initialSquiggleString = "",
|
||||||
height = 300,
|
height = 500,
|
||||||
showTypes = false,
|
showTypes = false,
|
||||||
showControls = false,
|
showControls = false,
|
||||||
showSummary = false,
|
showSummary = false,
|
||||||
|
@ -189,14 +198,35 @@ let SquigglePlayground: FC<PlaygroundProps> = ({
|
||||||
<Row leftPercentage={vars.leftSizePercent || 50}>
|
<Row leftPercentage={vars.leftSizePercent || 50}>
|
||||||
<Col>
|
<Col>
|
||||||
{vars.showSettingsPage ? (
|
{vars.showSettingsPage ? (
|
||||||
<div>
|
<>
|
||||||
|
<InputItem label="Sample Count">
|
||||||
<input type="number" {...register("sampleCount")} />
|
<input type="number" {...register("sampleCount")} />
|
||||||
|
</InputItem>
|
||||||
|
<InputItem label="XYPointLength Count">
|
||||||
<input type="number" {...register("xyPointLength")} />
|
<input type="number" {...register("xyPointLength")} />
|
||||||
|
</InputItem>
|
||||||
|
<InputItem label="Chart Height (in Pixels)">
|
||||||
<input type="number" {...register("chartHeight")} />
|
<input type="number" {...register("chartHeight")} />
|
||||||
<input type="number" {...register("leftSizePercent")} />
|
</InputItem>
|
||||||
|
<InputItem label="Show Types">
|
||||||
<input type="checkbox" {...register("showTypes")} />
|
<input type="checkbox" {...register("showTypes")} />
|
||||||
|
</InputItem>
|
||||||
|
<InputItem label="Show Controls">
|
||||||
<input type="checkbox" {...register("showControls")} />
|
<input type="checkbox" {...register("showControls")} />
|
||||||
|
</InputItem>
|
||||||
|
<InputItem label="Show Summary Statistics">
|
||||||
<input type="checkbox" {...register("showSummary")} />
|
<input type="checkbox" {...register("showSummary")} />
|
||||||
|
</InputItem>
|
||||||
|
<InputItem label="Editor Width">
|
||||||
|
<input
|
||||||
|
type="range"
|
||||||
|
min="1"
|
||||||
|
max="100"
|
||||||
|
className="slider"
|
||||||
|
{...register("leftSizePercent")}
|
||||||
|
/>
|
||||||
|
</InputItem>
|
||||||
|
<InputItem label="Json Editor for imports">
|
||||||
<JsonEditor
|
<JsonEditor
|
||||||
value={importString}
|
value={importString}
|
||||||
onChange={getChangeJson}
|
onChange={getChangeJson}
|
||||||
|
@ -205,7 +235,8 @@ let SquigglePlayground: FC<PlaygroundProps> = ({
|
||||||
height={100}
|
height={100}
|
||||||
/>
|
/>
|
||||||
{importsAreValid ? "Valid" : "Invalid"}
|
{importsAreValid ? "Valid" : "Invalid"}
|
||||||
</div>
|
</InputItem>
|
||||||
|
</>
|
||||||
) : (
|
) : (
|
||||||
<CodeEditor
|
<CodeEditor
|
||||||
value={squiggleString}
|
value={squiggleString}
|
||||||
|
|
|
@ -16,7 +16,7 @@ including sampling settings, in squiggle.
|
||||||
name="Normal"
|
name="Normal"
|
||||||
args={{
|
args={{
|
||||||
initialSquiggleString: "normal(5,2)",
|
initialSquiggleString: "normal(5,2)",
|
||||||
height: 500,
|
height: 800,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{Template.bind({})}
|
{Template.bind({})}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user