more layout

This commit is contained in:
Cadey Ratio 2020-11-15 16:53:45 -05:00
parent c85bb78f6c
commit cd8a820d57
3 changed files with 41 additions and 10 deletions

View File

@ -17,6 +17,9 @@
node: document.getElementById("app") node: document.getElementById("app")
}); });
</script> </script>
<noscript>
You must enable JavaScript for this page to work.
</noscript>
<script src="/static/install-sw.js"></script> <script src="/static/install-sw.js"></script>
</main> </main>
</body> </body>

29
sina/src/Layout.elm Normal file
View File

@ -0,0 +1,29 @@
module Layout exposing (template)
import Browser exposing (Document)
import Html exposing (Html, a, div, h1, main_, nav, text)
import Html.Attributes exposing (class, href)
template : String -> List (Html msg) -> Document msg
template title body =
{ title = title
, body =
[ main_
[]
([ nav
[ class "nav" ]
[ a [ href "/" ] [ text "Mi" ]
, text " - "
, a [ href "/posse" ] [ text "POSSE" ]
, text " - "
, a [ href "/switches" ] [ text "Switches" ]
, text " - "
, a [ href "/webmentions" ] [ text "WebMentions" ]
]
, h1 [] [ text title ]
]
++ body
)
]
}

View File

@ -1,9 +1,10 @@
module Main exposing (..) module Main exposing (main)
import Browser import Browser
import Html exposing (Html, div, h1, img, p, pre, text) import Html exposing (Html, div, h1, img, p, pre, text)
import Html.Attributes exposing (src) import Html.Attributes exposing (src)
import Http import Http
import Layout
import Mi import Mi
@ -39,28 +40,26 @@ update msg model =
( Failure (Mi.errorToString why), Cmd.none ) ( Failure (Mi.errorToString why), Cmd.none )
view : Model -> Html Msg view : Model -> Browser.Document msg
view model = view model =
case model of case model of
Failure why -> Failure why ->
div [] Layout.template "Error"
[ h1 [] [ text "Error" ] [ p [] [ text why ]
, p [] [ text why ]
] ]
Loading -> Loading ->
div [] [ h1 [] [ text "Loading" ] ] Layout.template "Loading" []
Success msg -> Success msg ->
div [] Layout.template "Mi"
[ h1 [] [ text "Mi" ] [ pre [] [ text msg ]
, pre [] [ text msg ]
] ]
main : Program () Model Msg main : Program () Model Msg
main = main =
Browser.element Browser.document
{ view = view { view = view
, init = init , init = init
, update = update , update = update