A React component for embedding Ligo code snippets on a page.
Quick start
- Install package
yarn add @ligolang/compact-ligo-ide
- Add
CompactLigoIde
component to a page
import { Code, CompactLigoIde, Result } from "@ligolang/compact-ligo-ide";
<CompactLigoIde language="cameligo">
<Code>
{`type storage = int
(* variant defining pseudo multi-entrypoint actions *)
type action =
| Increment of int
| Decrement of int
let add (a,b: int * int) : int = a + b
let sub (a,b: int * int) : int = a - b
(* real entrypoint that re-routes the flow based on the action provided *)
let main (p,s: action * storage) =
let storage =
match p with
| Increment n -> add (s, n)
| Decrement n -> sub (s, n)
in ([] : operation list), storage
`}
</Code>
<Compile>
<Entrypoint>main</Entrypoint>
</Compile>
<DryRun>
<Entrypoint>main</Entrypoint>
<Parameter>Increment 1</Parameter>
<Storage>0</Storage>
</DryRun>
<Deploy>
<Entrypoint>main</Entrypoint>
<Storage>0</Storage>
</Deploy>
</CompactLigoIde>;
- Apply styling
<style type="text/css">
.compactLigoIde {
height: 600px;
width: 600px;
}
</style>
Available configuration elements
<Code>
<Compile>
<DryRun>
<Deploy>
<EvaluateFunction>
<EvaluateValue>
<Entrypoint>
<Parameter>
<Storage>
Contribute
Starting dev server
- Install dependencies with
yarn install
- Run
yarn start
- Open http://localhost:1234 in a browser
Build package
Run yarn build
.
Publish package
Run npm publish --access=public
.