aboutsummaryrefslogtreecommitdiff
path: root/js/elements.ml
blob: b3c07a292fdb4798db578ebaa4ce0cc98cb26987 (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
let input_field :
    ?name:Jstr.t ->
    ?id':Jstr.t ->
    ?value':Jstr.t ->
    label:Jstr.t ->
    unit ->
    Brr.El.t =
 fun ?name ?id' ?(value' = Jstr.empty) ~label () ->
  let name' = name in
  let input =
    Brr.El.input
      ~at:
        Brr.At.
          [
            if_some (Option.map Brr.At.id id');
            if_some (Option.map Brr.At.name name');
            class' (Jstr.v "input");
            type' (Jstr.v "text");
            value value';
          ]
      ()
  and label =
    Brr.El.label
      ~at:
        Brr.At.
          [
            if_some (Option.map Brr.At.for' id');
            class' (Jstr.v "field-label is-normal");
          ]
      [ Brr.El.txt label ]
  in

  Brr.El.div
    ~at:Brr.At.[ class' (Jstr.v "field is-horizontal") ]
    [ label; Brr.El.div ~at:Brr.At.[ class' (Jstr.v "field-body") ] [ input ] ]