From f350db196bcab490b8a6b67f9536f0b9b7322073 Mon Sep 17 00:00:00 2001 From: Hayleigh Thompson Date: Mon, 10 Jul 2023 23:11:32 +0100 Subject: =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Replace=20React=20with=20diffhtml?= =?UTF-8?q?=20(#10)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * :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. --- test/example/src/main.gleam | 56 --------------------------------------------- 1 file changed, 56 deletions(-) delete mode 100644 test/example/src/main.gleam (limited to 'test/example/src') 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)), - ], - ) -} -- cgit v1.2.3