diff --git a/examples/break-brr/Makefile b/examples/break-brr/counter/Makefile similarity index 100% rename from examples/break-brr/Makefile rename to examples/break-brr/counter/Makefile diff --git a/examples/break-brr/dune b/examples/break-brr/counter/dune similarity index 100% rename from examples/break-brr/dune rename to examples/break-brr/counter/dune diff --git a/examples/break-brr/index.html b/examples/break-brr/counter/index.html similarity index 100% rename from examples/break-brr/index.html rename to examples/break-brr/counter/index.html diff --git a/examples/break-brr/main.ml b/examples/break-brr/counter/main.ml similarity index 100% rename from examples/break-brr/main.ml rename to examples/break-brr/counter/main.ml diff --git a/examples/break-brr/details/Makefile b/examples/break-brr/details/Makefile new file mode 100644 index 0000000..9d83eb4 --- /dev/null +++ b/examples/break-brr/details/Makefile @@ -0,0 +1,9 @@ +ROOT=$(realpath $(PWD)/../..) +NAME=$(subst $(ROOT)/,,$(realpath $(PWD))) + +all: + dune build index.html main.js + @echo "open $(ROOT)/_build/default/$(NAME)/index.html" + +clean: + dune clean diff --git a/examples/break-brr/details/dune b/examples/break-brr/details/dune new file mode 100644 index 0000000..03131bb --- /dev/null +++ b/examples/break-brr/details/dune @@ -0,0 +1,21 @@ +(executables + (names main) + (libraries js_of_ocaml brr lwd brr-lwd) + (modes byte)) + +(rule + (targets main.js) + (action + (run + %{bin:js_of_ocaml} + --noruntime + %{lib:js_of_ocaml-compiler:runtime.js} + --source-map + %{dep:main.bc} + -o + %{targets} + --pretty))) + +(alias + (name default) + (deps main.js index.html)) diff --git a/examples/break-brr/details/index.html b/examples/break-brr/details/index.html new file mode 100644 index 0000000..db9b0e0 --- /dev/null +++ b/examples/break-brr/details/index.html @@ -0,0 +1,12 @@ + + + + + Test + + + + + + diff --git a/examples/break-brr/details/main.ml b/examples/break-brr/details/main.ml new file mode 100644 index 0000000..6bf6c70 --- /dev/null +++ b/examples/break-brr/details/main.ml @@ -0,0 +1,37 @@ +open Brr +open Brr_lwd + +let accordion ~name ~title content = + (* TODO there might a bug in lwd: the open attribute disapears. + This does not happen if we use an Elwd.details *) + let at =[ + At.name (Jstr.v name); + At.v (Jstr.v "open") (Jstr.v "true") ] + in + El.details ~at + ((El.summary [ title ]) :: [ (El.section content) ]) + +let score = Lwd.var "Notes" + +let ui = + let e = Lwd.map (Lwd.get score) ~f:(fun score -> + accordion ~name:"test-acc" ~title:(El.txt' "Bandonéon" ) + [El.txt' score]) + in + Elwd.div [ `R e] + +let () = + let ui = Lwd.observe ui in + let on_invalidate _ = + ignore @@ G.request_animation_frame + @@ fun _ -> ignore @@ Lwd.quick_sample ui + in + let on_load _ = + El.append_children (Document.body G.document) [ Lwd.quick_sample ui ]; + Lwd.set_on_invalidate ui on_invalidate; + (* This triggers the bug, the text gets replaced but the
element + loses it's "open" attirbute. *) + Lwd.set score "Plus de notes" + in + ignore @@ Ev.listen Ev.dom_content_loaded on_load (Window.as_target G.window) +