aboutsummaryrefslogtreecommitdiff
path: root/src/Lib/Dom
diff options
context:
space:
mode:
authorJoris2020-08-08 21:04:28 +0200
committerJoris2020-08-08 21:04:28 +0200
commit38e42723a916b7d5c2a15e514b3f3e6dcab398dd (patch)
tree1b7415ae64ac9768b12fc4d543ee61d615d11e7e /src/Lib/Dom
parent3e39f97d844dbe0ff5f57e3977bc220d366d4c0e (diff)
Propose already defined colors in the form
Diffstat (limited to 'src/Lib/Dom')
-rw-r--r--src/Lib/Dom/HA.ml18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/Lib/Dom/HA.ml b/src/Lib/Dom/HA.ml
index a7a45ce..53fb84d 100644
--- a/src/Lib/Dom/HA.ml
+++ b/src/Lib/Dom/HA.ml
@@ -1,3 +1,21 @@
+let concat xs ys =
+ let partition_class =
+ Js.Array.reduce
+ (fun (class_acc, rest_acc) z ->
+ match z with
+ | H.TextAttr ("class", c) -> (class_acc ^ " " ^ c, rest_acc)
+ | _ -> (class_acc, Js.Array.concat [| z |] rest_acc)
+ )
+ ("", [| |])
+ in
+ let (xs_class, xs_rest) = partition_class xs in
+ let (ys_class, ys_rest) = partition_class ys in
+ let rest = Js.Array.concat xs_rest ys_rest in
+ if xs_class == "" && ys_class == "" then
+ rest
+ else
+ Js.Array.concat [| H.TextAttr ("class", xs_class ^ " " ^ ys_class) |] rest
+
(* Attribute creation *)
let id v = H.TextAttr ("id", v)