From 3a60c2a1f44baf6c2d2cad2f329600e63d99f6c2 Mon Sep 17 00:00:00 2001 From: Hayleigh Thompson Date: Thu, 20 Jul 2023 22:52:07 +0100 Subject: :recycle: Explicitly handle namespaced elements in the vdom tree. --- test/examples/svg.gleam | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'test/examples/svg.gleam') diff --git a/test/examples/svg.gleam b/test/examples/svg.gleam index f1859d4..19c7652 100644 --- a/test/examples/svg.gleam +++ b/test/examples/svg.gleam @@ -3,7 +3,7 @@ import gleam/int import lustre import lustre/attribute.{attribute} -import lustre/element.{Element, element, text} +import lustre/element.{Element, namespaced, text} import lustre/html.{button, div, p, svg} import lustre/event @@ -48,24 +48,29 @@ pub fn render(model: Model) -> Element(Msg) { div( [], [ - button([event.on_click(Incr)], [plus()]), - button([event.on_click(Decr)], [minus()]), + button( + [event.on_click(Incr)], + [plus([attribute.style([#("color", "red")])])], + ), + button([event.on_click(Decr)], [minus([])]), button([event.on_click(Reset)], [text("Reset")]), p([], [text(int.to_string(model))]), ], ) } -fn plus() { +fn plus(attrs) { svg( [ attribute("width", "15"), attribute("height", "15"), attribute("viewBox", "0 0 15 15"), attribute("fill", "none"), + ..attrs ], [ - element( + namespaced( + "http://www.w3.org/2000/svg", "path", [ attribute( @@ -82,16 +87,18 @@ fn plus() { ) } -fn minus() { +fn minus(attrs) { svg( [ attribute("width", "15"), attribute("height", "15"), attribute("viewBox", "0 0 15 15"), attribute("fill", "none"), + ..attrs ], [ - element( + namespaced( + "http://www.w3.org/2000/svg", "path", [ attribute( -- cgit v1.2.3