aboutsummaryrefslogtreecommitdiff
path: root/examples/server_demo/src/demo/app.gleam
diff options
context:
space:
mode:
authorHayleigh Thompson <me@hayleigh.dev>2024-01-27 02:24:50 +0000
committerHayleigh Thompson <me@hayleigh.dev>2024-01-27 02:24:50 +0000
commitc34d1a0e9003d483752720466def696c30f705c8 (patch)
treeb6e693c3b3d971a9d449daeb461b1a867177ad39 /examples/server_demo/src/demo/app.gleam
parent235fcd2ae0229272ebb0927806d301c8b887c1ba (diff)
downloadlustre-c34d1a0e9003d483752720466def696c30f705c8.tar.gz
lustre-c34d1a0e9003d483752720466def696c30f705c8.zip
:construction: Start replacing old test examples with structured examples.
Diffstat (limited to 'examples/server_demo/src/demo/app.gleam')
-rw-r--r--examples/server_demo/src/demo/app.gleam88
1 files changed, 0 insertions, 88 deletions
diff --git a/examples/server_demo/src/demo/app.gleam b/examples/server_demo/src/demo/app.gleam
deleted file mode 100644
index 13d09a8..0000000
--- a/examples/server_demo/src/demo/app.gleam
+++ /dev/null
@@ -1,88 +0,0 @@
-// IMPORTS ---------------------------------------------------------------------
-
-import gleam/dict.{type Dict}
-import gleam/dynamic.{type Decoder}
-import gleam/int
-import gleam/json
-import gleam/result
-import lustre/attribute
-import lustre/effect.{type Effect}
-import lustre/element.{type Element}
-import lustre/element/html
-import lustre/event
-import lustre/server
-import lustre/ui
-
-// MODEL -----------------------------------------------------------------------
-
-pub type Model =
- Int
-
-pub fn init(count: Int) -> #(Model, Effect(Msg)) {
- #(count, effect.none())
-}
-
-// UPDATE ----------------------------------------------------------------------
-
-pub opaque type Msg {
- Incr
- Decr
- Reset(Int)
-}
-
-pub fn update(model: Model, msg: Msg) -> #(Model, Effect(Msg)) {
- case msg {
- Incr -> #(model + 1, effect.none())
- Decr -> #(model - 1, effect.none())
- Reset(count) -> #(
- count,
- effect.event(
- "changed",
- json.string("You reset the count to: " <> int.to_string(count)),
- ),
- )
- }
-}
-
-pub fn on_attribute_change() -> Dict(String, Decoder(Msg)) {
- dict.from_list([
- #("count", fn(dyn) {
- dyn
- |> dynamic.int
- |> result.map(Reset)
- }),
- ])
-}
-
-// VIEW ------------------------------------------------------------------------
-
-pub fn view(model: Model) -> Element(Msg) {
- let count = int.to_string(model)
-
- ui.centre(
- [attribute.style([#("width", "100vw"), #("height", "100vh")])],
- ui.sequence([], [
- ui.button([event.on_click(Decr)], [element.text("-")]),
- ui.centre([], html.span([], [element.text(count)])),
- ui.button([event.on_click(Incr)], [element.text("+")]),
- ]),
- )
- // ui.cluster([], [
- // ui.input([event.on_input(Change), attribute.value(model.input)]),
- // html.span([], [element.text(model.input)]),
- // ]),
- // ui.centre(
- // [
- // event.on("mousemove", on_mouse_move),
- // server.include(["offsetX", "offsetY"]),
- // attribute.style([
- // #("aspect-ratio", "1 / 1 "),
- // #("background-color", "var(--element-background)"),
- // ]),
- // ],
- // html.div([], [
- // html.p([], [element.text("x: " <> int.to_string(model.mouse.0))]),
- // html.p([], [element.text("y: " <> int.to_string(model.mouse.1))]),
- // ]),
- // ),
-}