begin refactor to 0.4, not successful yet

This commit is contained in:
Quinn Dougherty 2022-09-09 17:38:21 +08:00
parent f01ffa806e
commit 7e6d3a32db
5 changed files with 26 additions and 23 deletions

View File

@ -0,0 +1,18 @@
import React from "react";
import dynamic from "next/dynamic";
const SquiggleEditor = dynamic<any>(
() => import("@quri/squiggle-components").then((mod) => mod.SquiggleEditor),
{
loading: () => <p>Loading...</p>,
ssr: false,
}
)
export function DynamicSquiggleEditor( props: any ) {
return (
<SquiggleEditor
defaultCode={props.defaultCode}
/>
)
};

View File

@ -1,20 +0,0 @@
import React from "react";
import dynamic from "next/dynamic";
const SquiggleEditorWithImportedBindings = dynamic<any>(
() => import("@quri/squiggle-components").then((mod) => mod.SquiggleEditorWithImportedBindings),
{
loading: () => <p>Loading...</p>,
ssr: false,
}
)
export function DynamicSquiggleEditorWithImportedBindings( props: any ) {
return (
<SquiggleEditorWithImportedBindings
defaultCode={props.defaultCode}
showSummary={true}
bindingsImportUrl={props.bindingsImportUrl}
/>
)
};

View File

@ -10,7 +10,7 @@ export default function Layout({ children }: Props) {
return ( return (
<> <>
<Head> <Head>
<title>GUCEM</title> <title>squiggle-next-template</title>
<meta name="description" content="Generated by create next app" /> <meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" /> <link rel="icon" href="/favicon.ico" />
</Head> </Head>

View File

@ -1,5 +1,6 @@
{ {
"private": true, "private": true,
"version": "0.0.1",
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",
"build": "next build", "build": "next build",

View File

@ -1,4 +1,4 @@
import { DynamicSquiggleEditorWithImportedBindings as SquiggleEditor } from "../components/DynamicSquiggleEditorWithImportedBindings" import { DynamicSquiggleEditor as SquiggleEditor } from "../components/DynamicSquiggleEditor"
# Squiggle demonstration # Squiggle demonstration
@ -13,6 +13,10 @@ f(z)`} />
We can also import assignments from files that live in `/public/estimates/` of the repo. We can also import assignments from files that live in `/public/estimates/` of the repo.
<SquiggleEditor defaultCode="foo.bar(beta(1,2), ski)" bindingsImportUrl="/estimates/baz.squiggle" /> <SquiggleEditor
defaultCode={`
@import(estimates/baz.squiggle, baz)
baz.foo.bar(beta(1,2), baz.ski)`}
/>
Files you import for bindings have to consist only of assignments: they cannot end in an expression, unless that expression is a record. Files you import for bindings have to consist only of assignments: they cannot end in an expression, unless that expression is a record.