Here, a tooltip title attribute needs to be added if it is Just.
let
divAttributes =
[ HA.classList
[ ( "my-div", True ) ]
]
combinedAttributes =
case settings.tooltip of
Just tooltip ->
divAttributes ++ [ HA.title tooltip ]
Nothing ->
divAttributes
in
H.div
combinedAttributes
[ content ]
This can be easier written with the Maybe.map and Maybe.withDefault functions.
let
divAttributes =
[ HA.classList
[ ( "my-div", True ) ]
]
tooltipAttribute =
Maybe.map (\tooltip -> [ HA.title tooltip ]) settings.tooltip |> Maybe.withDefault []
-- or you can do:
settings.tooltip |> Maybe.map (\tooltip -> [ HA.title tooltip ]) |> Maybe.withDefault []
in
H.div
(divAttributes ++ tooltipAttribute)
[ content ]