onasty/web/src/Components/Utils.elm(view raw)
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 |
module Components.Utils exposing (loadSvg, viewIf, viewMaybe)
import Html as H exposing (Html)
import Html.Attributes as A
viewIf : Bool -> Html msg -> Html msg
viewIf condition html =
if condition then
html
else
H.text ""
viewMaybe : Maybe a -> (a -> Html msg) -> Html msg
viewMaybe maybeValue toHtml =
case maybeValue of
Just value ->
toHtml value
Nothing ->
H.text ""
loadSvg : { path : String, class : String } -> Html msg
loadSvg { path, class } =
H.img [ A.src ("/static/" ++ path), A.class class ] []
|