aboutsummaryrefslogtreecommitdiff
path: root/src/View/Form.ml
diff options
context:
space:
mode:
Diffstat (limited to 'src/View/Form.ml')
-rw-r--r--src/View/Form.ml31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/View/Form.ml b/src/View/Form.ml
index db73b0c..cc95210 100644
--- a/src/View/Form.ml
+++ b/src/View/Form.ml
@@ -15,7 +15,17 @@ let input id label init_value on_input =
[| |]
|]
-let color_input id label init_value on_input =
+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
@@ -24,13 +34,20 @@ let color_input id label init_value on_input =
[| 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
- ; HA.type_ "color"
- |]
+ ; 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 =