Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions examples/break-brr/details/Makefile
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions examples/break-brr/details/dune
Original file line number Diff line number Diff line change
@@ -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))
12 changes: 12 additions & 0 deletions examples/break-brr/details/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="main.js"></script>
</head>
<body>
</body>
</html>
37 changes: 37 additions & 0 deletions examples/break-brr/details/main.ml
Original file line number Diff line number Diff line change
@@ -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 <details> 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)