aboutsummaryrefslogtreecommitdiff
path: root/examples/components
diff options
context:
space:
mode:
Diffstat (limited to 'examples/components')
-rw-r--r--examples/components/gleam.toml7
-rw-r--r--examples/components/manifest.toml15
-rw-r--r--examples/components/src/components.gleam91
3 files changed, 0 insertions, 113 deletions
diff --git a/examples/components/gleam.toml b/examples/components/gleam.toml
deleted file mode 100644
index 3cac691..0000000
--- a/examples/components/gleam.toml
+++ /dev/null
@@ -1,7 +0,0 @@
-name = "components"
-version = "1.0.0"
-target = "javascript"
-
-[dependencies]
-gleam_stdlib = "~> 0.34"
-lustre = { path = "../../" }
diff --git a/examples/components/manifest.toml b/examples/components/manifest.toml
deleted file mode 100644
index 1c72364..0000000
--- a/examples/components/manifest.toml
+++ /dev/null
@@ -1,15 +0,0 @@
-# This file was generated by Gleam
-# You typically do not need to edit this file
-
-packages = [
- { name = "gleam_erlang", version = "0.24.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "26BDB52E61889F56A291CB34167315780EE4AA20961917314446542C90D1C1A0" },
- { name = "gleam_json", version = "0.7.0", build_tools = ["gleam"], requirements = ["thoas", "gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "CB405BD93A8828BCD870463DE29375E7B2D252D9D124C109E5B618AAC00B86FC" },
- { name = "gleam_otp", version = "0.9.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "5FADBBEC5ECF3F8B6BE91101D432758503192AE2ADBAD5602158977341489F71" },
- { name = "gleam_stdlib", version = "0.34.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "1FB8454D2991E9B4C0C804544D8A9AD0F6184725E20D63C3155F0AEB4230B016" },
- { name = "lustre", version = "3.1.1", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_json", "gleam_otp", "gleam_stdlib"], source = "local", path = "../.." },
- { name = "thoas", version = "0.4.1", build_tools = ["rebar3"], requirements = [], otp_app = "thoas", source = "hex", outer_checksum = "4918D50026C073C4AB1388437132C77A6F6F7C8AC43C60C13758CC0ADCE2134E" },
-]
-
-[requirements]
-gleam_stdlib = { version = "~> 0.34" }
-lustre = { path = "../../" }
diff --git a/examples/components/src/components.gleam b/examples/components/src/components.gleam
deleted file mode 100644
index 03400bf..0000000
--- a/examples/components/src/components.gleam
+++ /dev/null
@@ -1,91 +0,0 @@
-// IMPORTS ---------------------------------------------------------------------
-
-import gleam/dynamic
-import gleam/function
-import gleam/int
-import gleam/list
-import gleam/dict
-import gleam/result
-import lustre
-import lustre/attribute
-import lustre/effect
-import lustre/element.{element, text}
-import lustre/element/html.{button, div, li, ol, p, slot}
-import lustre/event
-
-// MAIN ------------------------------------------------------------------------
-
-pub fn main() {
- let counter =
- lustre.component(
- counter_init,
- counter_update,
- counter_view,
- dict.from_list([
- #("count", fn(attr) {
- dynamic.int(attr)
- |> result.map(GotCount)
- }),
- ]),
- )
-
- let assert Ok(_) = lustre.register(counter, "custom-counter")
- // A `simple` lustre application doesn't produce `Effect`s. These are best to
- // start with if you're just getting started with lustre or you know you don't
- // need the runtime to manage any side effects.
- let app = lustre.simple(init, update, view)
- let assert Ok(_) = lustre.start(app, "[data-lustre-app]", Nil)
-
- Nil
-}
-
-fn init(_) {
- []
-}
-
-fn update(history, msg) {
- case msg {
- "reset" -> []
- _ -> [msg, ..history]
- }
-}
-
-fn view(history) {
- let on_custom_click = event.on("custom-click", function.constant(Ok("click")))
-
- div([], [
- button([event.on_click("reset")], [text("Reset")]),
- ol([], list.map(history, fn(msg) { li([], [text(msg)]) })),
- element(
- "custom-counter",
- [on_custom_click, attribute.property("count", list.length(history))],
- [ol([], list.map(history, fn(msg) { li([], [text(msg)]) }))],
- ),
- ])
-}
-
-// COUNTER ---------------------------------------------------------------------
-
-fn counter_init() {
- #(0, effect.none())
-}
-
-type CounterMsg {
- GotCount(Int)
- Clicked
-}
-
-fn counter_update(count, msg) {
- case msg {
- GotCount(count) -> #(count, effect.none())
- Clicked -> #(count, event.emit("custom-click", Nil))
- }
-}
-
-fn counter_view(count) {
- div([], [
- button([event.on_click(Clicked)], [text("Click me!")]),
- p([], [text("Count: "), text(int.to_string(count))]),
- slot([]),
- ])
-}