diff options
author | Hayleigh Thompson <me@hayleigh.dev> | 2023-07-10 23:11:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-10 23:11:32 +0100 |
commit | f350db196bcab490b8a6b67f9536f0b9b7322073 (patch) | |
tree | 59664ca671be2cfdb473424ca1bf737cf12622e8 /test/playground | |
parent | 6d314230346336ba5b452b1df39b908ffa666f45 (diff) | |
download | lustre-f350db196bcab490b8a6b67f9536f0b9b7322073.tar.gz lustre-f350db196bcab490b8a6b67f9536f0b9b7322073.zip |
♻️ Replace React with diffhtml (#10)
* :wrench: Remove react dependency, add vite for running examples.
* :heavy_plus_sign: Update stdlib version to 0.29
* :fire: Remove old examples.
* :sparkles: Vendor diffhtml and update runtime ffi code to replace react.
* :recycle: Refactor all the things now react is gone.
* :memo: Remove references to react in the readme.
* :sparkles: Create a simple counter example.
Diffstat (limited to 'test/playground')
-rw-r--r-- | test/playground/index.html | 37 | ||||
-rw-r--r-- | test/playground/main.gleam | 28 | ||||
-rw-r--r-- | test/playground/monaco.gleam | 15 |
3 files changed, 0 insertions, 80 deletions
diff --git a/test/playground/index.html b/test/playground/index.html deleted file mode 100644 index c20cc48..0000000 --- a/test/playground/index.html +++ /dev/null @@ -1,37 +0,0 @@ -<!DOCTYPE html> -<html lang="en" hidden> - -<head> - <meta charset="UTF-8"> - <meta http-equiv="X-UA-Compatible" content="IE=edge"> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <title>Lustre Playground</title> - - <script type="module"> - // `example` is set up as an alias in our `package.json` to point to - // some of Gleam's build artifacts. - import { main } from 'playground/main.mjs' - - document.addEventListener('DOMContentLoaded', main) - - // This is so dumb. Parcel refuses to work with https imports, and when - // we try to use a script tag it "helpfully" strips the `type="module"` - // attribute meaning the shim doesn't work anyway. - // - // Here we're manually creating the script and setting its source using - // a string to stop parcle meddling with it. It works but,, eesh. - document.querySelector('head').appendChild((() => { - const script = document.createElement('script') - script.type = 'module' - script.innerHTML = `import 'https://cdn.skypack.dev/twind/shim'` - - return script - })()) - </script> -</head> - -<body class="bg-gray-100"> - <div data-lustre-container class="p-8 h-screen w-screen"></div> -</body> - -</html>
\ No newline at end of file diff --git a/test/playground/main.gleam b/test/playground/main.gleam deleted file mode 100644 index 0b0bbe1..0000000 --- a/test/playground/main.gleam +++ /dev/null @@ -1,28 +0,0 @@ -import gleam/io -import lustre -import lustre/attribute.{attribute} -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]") -} diff --git a/test/playground/monaco.gleam b/test/playground/monaco.gleam deleted file mode 100644 index 14958ac..0000000 --- a/test/playground/monaco.gleam +++ /dev/null @@ -1,15 +0,0 @@ -import gleam/dynamic -import lustre/attribute.{ Attribute } -import lustre/element.{ Element } -import lustre/event - -pub external fn render (attributes: List(Attribute(action))) -> Element(action) - = "../playground.mjs" "monaco" - -pub fn on_change (handler: fn (String, fn (action) -> Nil) -> Nil) -> Attribute(action) { - event.on("change", fn (e, dispatch) { - let assert Ok(code) = dynamic.string(e) - - handler(code, dispatch) - }) -}
\ No newline at end of file |