diff options
author | Hayleigh Thompson <me@hayleigh.dev> | 2022-05-22 03:46:24 +0100 |
---|---|---|
committer | Hayleigh Thompson <me@hayleigh.dev> | 2022-05-22 03:46:24 +0100 |
commit | af7c2e44f3bb3e52cea363c4188a39fc1924931f (patch) | |
tree | 3d6747c9f63d2221e453718b1dd41ea824f0987e /test/playground/main.gleam | |
parent | d408e6b8bd47b8c5ac5d2218943c11d576705583 (diff) | |
download | lustre-af7c2e44f3bb3e52cea363c4188a39fc1924931f.tar.gz lustre-af7c2e44f3bb3e52cea363c4188a39fc1924931f.zip |
:construction: Experiment using monaco editor for the lustre playground.
Diffstat (limited to 'test/playground/main.gleam')
-rw-r--r-- | test/playground/main.gleam | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/playground/main.gleam b/test/playground/main.gleam new file mode 100644 index 0000000..6b7f7f7 --- /dev/null +++ b/test/playground/main.gleam @@ -0,0 +1,32 @@ +import gleam/io +import lustre +import lustre/attribute.{ Attribute, attribute } +import lustre/element.{ Element } +import playground/monaco + +pub type Action { + OnInput(String) +} + +pub fn main () { + let init = "// Write some Gleam code here" + + let update = fn (_, action) { + case action { + OnInput(input) -> + io.debug(input) + } + } + + let render = fn (state) { + monaco.render([ + attribute("value", state), + monaco.on_change(fn (code, dispatch) { + dispatch(OnInput(code)) + }) + ]) + } + + lustre.simple(init, update, render) + |> lustre.start("[data-lustre-container]") +} |