aboutsummaryrefslogtreecommitdiff
path: root/src/View/Map/Icon.ml
blob: 9b1f40a6192d0ae8236b4bcb4db7d4c2f9357e00 (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
let create name color =
  let c = Color.from_raw color in
  let crBlack = Color.contrast_ratio { r = 0.; g = 0.; b = 0. } c in
  let crWhite = Color.contrast_ratio { r = 255.; g = 255.; b = 255. } c in
  let textCol = if crBlack > crWhite then "black" else "white" in
  Leaflet.div_icon
    { className = "marker-parent"
    ; popupAnchor = [| 0.; -34. |]
    ; html =
        H.div
          [| |]
          [| H.div
              [| HA.class_ "marker-round"
              ;  HA.style ("background-color: " ^ color)
              |]
              [| |]
          ;  H.div [| HA.class_ "marker-peak-border" |] [| |]
          ;  H.div
              [| HA.class_ "marker-peak-inner"
              ;  HA.style ("border-top-color: " ^ color)
              |]
              [| |]
          ;  H.div
              [| HA.class_ "marker-icon" |]
              [| H.i
                  [| HA.class_ ("fa fa-" ^ name)
                  ;  HA.style ("color: " ^ textCol)
                  |]
                  [| |]
              |]
          |]
    }