blob: cc9521010c725bf282595022149fd7cbe353aa9a (
plain)
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
|
let input id label init_value on_input =
H.div
[| HA.class_ "g-Form__Field" |]
[| H.div
[| HA.class_ "g-Form__Label" |]
[| H.label
[| HA.for_ id |]
[| H.text label |]
|]
; H.input
[| HA.id id
; HE.on_input (fun e -> on_input (Element.value (Event.target e)))
; HA.value init_value
|]
[| |]
|]
let color_input default_colors id label init_value on_input =
let
input =
H.input
[| HA.id id
; HE.on_input (fun e -> on_input (Element.value (Event.target e)))
; HA.value init_value
; HA.type_ "color"
|]
[| |]
in
H.div
[| HA.class_ "g-Form__Field" |]
[| H.div
[| HA.class_ "g-Form__Label" |]
[| H.label
[| HA.for_ id |]
[| H.text label |]
|]
; Layout.line
[| |]
(default_colors
|> Js.Array.map (fun color ->
Button.raw
[| HA.class_ "g-Form__DefaultColor"
; HA.style ("background-color: " ^ color)
; HE.on_click (fun _ ->
let () = Element.set_value input color in
on_input color)
; HA.type_ "button"
|]
[| |])
|> (fun xs -> Js.Array.concat xs [| input |]))
|]
let textarea id label init_value on_input =
H.div
[| HA.class_ "g-Form__Field" |]
[| H.div
[| HA.class_ "g-Form__Label" |]
[| H.label
[| HA.for_ id |]
[| H.text label |]
|]
; H.textarea
[| HA.id id
; HA.class_ "g-Form__Textarea"
; HE.on_input (fun e -> on_input (Element.value (Event.target e)))
|]
[| H.text init_value |]
|]
|