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/example/src | |
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/example/src')
-rw-r--r-- | test/example/src/main.gleam | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/test/example/src/main.gleam b/test/example/src/main.gleam deleted file mode 100644 index 7c9400f..0000000 --- a/test/example/src/main.gleam +++ /dev/null @@ -1,56 +0,0 @@ -// IMPORTS --------------------------------------------------------------------- - -import gleam/javascript/promise.{Promise} -import gleam/string -import lustre -import lustre/cmd.{Cmd} -import lustre/element.{Element} -import lustre/event - -// MAIN ------------------------------------------------------------------------ - -pub fn main() -> Promise(fn(Msg) -> Nil) { - let selector = "[data-lustre-container]" - let program = lustre.application(init(), update, render) - - use _ <- promise.tap(lustre.start(program, selector)) - Nil -} - -// MODEL ----------------------------------------------------------------------- - -type Model = - Int - -fn init() -> #(Model, Cmd(Msg)) { - #(0, cmd.none()) -} - -// UPDATE ---------------------------------------------------------------------- - -pub opaque type Msg { - SetCount(Int) -} - -fn update(_: Model, msg: Msg) -> #(Model, Cmd(Msg)) { - case msg { - SetCount(n) -> #(n, cmd.none()) - } -} - -// RENDER ---------------------------------------------------------------------- - -fn render(model: Model) -> Element(Msg) { - element.div( - [], - [ - element.map( - fn() { - element.button([event.on_click(model + 1)], [element.text("+")]) - }, - SetCount, - ), - element.text(string.inspect(model)), - ], - ) -} |