all repos

onasty @ a2448ac

a one-time notes service

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

Olexandr Smirnov Olexandr Smirnov
ss2316544@gmail.com
web: button component; improve code consistency (#168)..., 10 months ago
1
module Components.Utils exposing (commonContainer, 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
commonContainer : List (Html msg) -> Html msg
27
commonContainer child =
28
    H.div [ A.class "py-8 w-full max-w-4xl mx-auto " ]
29
        [ H.div [ A.class "rounded-lg border border-gray-200 shadow-sm" ] child ]