diff options
author | Hayleigh Thompson <me@hayleigh.dev> | 2023-07-23 18:30:08 +0100 |
---|---|---|
committer | Hayleigh Thompson <me@hayleigh.dev> | 2023-07-23 18:30:08 +0100 |
commit | 0f6caf6af6314577dcc18adf1af4230aac4b62ba (patch) | |
tree | df4e83cfe0dcdf93a41d33302f5d844d4988ba5a | |
parent | c36593880b8fd6fd79a6e91f5330ca7bd03eb309 (diff) | |
download | lustre-0f6caf6af6314577dcc18adf1af4230aac4b62ba.tar.gz lustre-0f6caf6af6314577dcc18adf1af4230aac4b62ba.zip |
:sparkles: Update component example to test whether slots work.
-rw-r--r-- | test/examples/components.gleam | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/test/examples/components.gleam b/test/examples/components.gleam index beb4151..722b796 100644 --- a/test/examples/components.gleam +++ b/test/examples/components.gleam @@ -10,7 +10,7 @@ import lustre import lustre/attribute import lustre/effect import lustre/element.{element, text} -import lustre/element/html.{button, div, li, ol, p} +import lustre/element/html.{button, div, li, ol, p, slot} import lustre/event // MAIN ------------------------------------------------------------------------ @@ -47,7 +47,10 @@ fn init() { } fn update(history, msg) { - [msg, ..history] + case msg { + "reset" -> [] + _ -> [msg, ..history] + } } fn render(history) { @@ -58,11 +61,12 @@ fn render(history) { 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)]) }))], ), ], ) @@ -92,6 +96,7 @@ fn counter_render(count) { [ button([event.on_click(Clicked)], [text("Click me!")]), p([], [text("Count: "), text(int.to_string(count))]), + slot([]), ], ) } |