github.com/simpleiot/simpleiot@v0.18.3/frontend/src/View.elm (about)

     1  module View exposing (View, map, none, placeholder, toBrowserDocument)
     2  
     3  import Browser
     4  import Element exposing (Element)
     5  
     6  
     7  type alias View msg =
     8      { title : String
     9      , attributes : List (Element.Attribute msg)
    10      , element : Element msg
    11      }
    12  
    13  
    14  placeholder : String -> View msg
    15  placeholder str =
    16      { title = str
    17      , attributes = []
    18      , element = Element.text str
    19      }
    20  
    21  
    22  none : View msg
    23  none =
    24      placeholder ""
    25  
    26  
    27  map : (a -> b) -> View a -> View b
    28  map fn view =
    29      { title = view.title
    30      , attributes = view.attributes |> List.map (Element.mapAttribute fn)
    31      , element = Element.map fn view.element
    32      }
    33  
    34  
    35  toBrowserDocument : View msg -> Browser.Document msg
    36  toBrowserDocument view =
    37      { title = view.title
    38      , body =
    39          [ Element.layout view.attributes view.element
    40          ]
    41      }