aboutsummaryrefslogtreecommitdiff
path: root/test-apps/nested-element-map/src/app.gleam
diff options
context:
space:
mode:
Diffstat (limited to 'test-apps/nested-element-map/src/app.gleam')
-rw-r--r--test-apps/nested-element-map/src/app.gleam51
1 files changed, 51 insertions, 0 deletions
diff --git a/test-apps/nested-element-map/src/app.gleam b/test-apps/nested-element-map/src/app.gleam
new file mode 100644
index 0000000..ed91763
--- /dev/null
+++ b/test-apps/nested-element-map/src/app.gleam
@@ -0,0 +1,51 @@
+import lustre
+import lustre/element.{type Element, element}
+import lustre/element/html
+import lustre/event
+
+// MAIN ------------------------------------------------------------------------
+
+pub fn main() {
+ let app = lustre.simple(init, update, view)
+ let assert Ok(_) = lustre.start(app, "#app", Nil)
+}
+
+// MODEL -----------------------------------------------------------------------
+
+type Model =
+ String
+
+fn init(_flags) -> Model {
+ "div"
+}
+
+// UPDATE ----------------------------------------------------------------------
+pub opaque type Baby {
+ Waaa
+}
+
+pub opaque type Child {
+ BabyMsg(Baby)
+}
+
+pub opaque type Msg {
+ ChildMsg(Child)
+}
+
+fn update(model: Model, _msg: Msg) -> Model {
+ model
+}
+
+// VIEW ------------------------------------------------------------------------
+
+fn view(_model: Model) -> Element(Msg) {
+ html.div([], [
+ html.text("parent"),
+ html.div([], [
+ html.text("child"),
+ html.div([event.on_click(Waaa)], [html.text("baby")])
+ |> element.map(BabyMsg),
+ ])
+ |> element.map(ChildMsg),
+ ])
+}