-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbridge.ml
76 lines (60 loc) · 1.96 KB
/
bridge.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
module React = struct
let string = Tyxml.Html.txt
let list a = a
let useState : (unit -> 'state) -> 'state * (('state -> 'state) -> unit) =
fun f -> f (), fun _ -> ()
let useReducer
: ('state -> 'action -> 'state) -> 'state -> 'state * ('action -> unit)
=
fun _ s -> s, fun _ -> ()
let useEffect0 : (unit -> (unit -> unit) option) -> unit = fun _ -> ()
let useEffect1 : (unit -> (unit -> unit) option) -> 'a array -> unit =
fun _ _ -> ()
end
module Js = struct
module Global = struct
type timeoutId = unit
let clearTimeout : timeoutId -> unit = fun _ -> ()
let setTimeout : (unit -> unit) -> int -> timeoutId = fun _ _ -> ()
end
end
module Dom = struct
open Tyxml.Html
let opt_concat f el list =
match el with
| None -> list
| Some el -> f el :: list
module Div = struct
let createElement ?cls ~children () =
div ~a:([] |> opt_concat (fun cls -> a_class [ cls ]) cls) children
end
module Ul = struct
let createElement ?cls ~children () =
ul ~a:([] |> opt_concat (fun cls -> a_class [ cls ]) cls) children
end
module Form = struct
let createElement ?action ?form_method ~children () =
form
~a:([] |> opt_concat a_action action |> opt_concat a_method form_method)
children
end
(** Input is needed as ReasonReact does not have a high level type for type_ attribute, it's just plain string *)
module Input = struct
let createElement ?cls ~input_type ?name ?value () =
input
~a:
([ a_input_type input_type ]
|> opt_concat a_name name
|> opt_concat a_value value
|> opt_concat (fun cls -> a_class [ cls ]) cls
)
()
end
module P = struct let createElement ~children () = p children end
module Textarea = struct
let createElement ?cls ~name ~value () =
textarea
~a:([ a_name name ] |> opt_concat (fun cls -> a_class [ cls ]) cls)
(Tyxml.Html.txt value)
end
end