all repos

onasty @ a705d9c

a one-time notes service

onasty/web/src/Components/Utils.elm (view raw)

Olexandr Smirnov Olexandr Smirnov
ss2316544@gmail.com
web: general refactor (#158)..., 11 months ago
1
module Components.Utils exposing (loadSvg, viewIf, viewMaybe)
2
3
import Html as H exposing (Html)
4
import Html.Attributes as A
5
6
7
viewIf : Bool -> Html msg -> Html msg
8
viewIf condition html =
9
    if condition then
10
        html
11
12
    else
13
        H.text ""
14
15
16
viewMaybe : Maybe a -> (a -> Html msg) -> Html msg
17
viewMaybe maybeValue toHtml =
18
    case maybeValue of
19
        Just value ->
20
            toHtml value
21
22
        Nothing ->
23
            H.text ""
24
25
26
loadSvg : { path : String, class : String } -> Html msg
27
loadSvg { path, class } =
28
    H.img [ A.src ("/static/" ++ path), A.class class ] []