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. --- README.md | 49 +++++++++++++++++-------------------------------- 1 file changed, 17 insertions(+), 32 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 1373acb..b6d111c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Lustre -A framework for building create web apps – powered by Gleam and React! +An Elm-inspired framework for building web apps in Gleam! --- @@ -15,19 +15,25 @@ import lustre/event.{on_click} import lustre/cmd pub fn main() { - let app = lustre.application(#(0, cmd.none()), update, render) - lustre.start(app, "#app") + let app = lustre.simple(init, update, render) + let assert Ok(_) = lustre.start(app, "#app") + + Nil +} + +fn init() { + 0 } -pub type Action { +type Msg { Incr Decr } -fn update(state, action) { - case action { - Incr -> #(state + 1, cmd.none()) - Decr -> #(state - 1, cmd.none()) +fn update(state, msg) { + case msg { + Incr -> state + 1 + Decr -> state - 1 } } @@ -52,30 +58,9 @@ the browser. **It will not work if your are targetting Node.js or Erlang.** ## Installation -If available on Hex, this package can be added to your Gleam project: - -```sh -gleam add lustre -``` - -and its documentation can be found at . You will also -need to install `react` and `react-dom` from npm: +Lustre is available on [Hex](https://hex.pm/packages/lustre). You can install +it like any other Hex package: ```sh -npm i react react-dom +$ gleam add lustre ``` - ---- - -## Development - -First, make sure you have both Gleam and Node.js installed, then: - -```bash -npm i -npm start -``` - -This sets up `chokidar` to watch our gleam source code and runs the compiler -whenever we make a change. It also starts a server that will serve the examples -located in `test/example/`. -- cgit v1.2.3