76 lines
1.5 KiB
Elm
76 lines
1.5 KiB
Elm
module Page exposing (..)
|
|
|
|
import Browser exposing (Document)
|
|
import Html exposing (Html, a, div, input, node, p, text)
|
|
import Html.Attributes exposing (href, placeholder, type_, value)
|
|
import Html.Events exposing (onInput)
|
|
|
|
|
|
type Page
|
|
= Login
|
|
| TokenData
|
|
| NotFound String
|
|
|
|
|
|
fromPath : String -> Page
|
|
fromPath path =
|
|
case path of
|
|
"/" ->
|
|
TokenData
|
|
|
|
"/login" ->
|
|
Login
|
|
|
|
other ->
|
|
NotFound other
|
|
|
|
|
|
template : String -> List (Html msg) -> Browser.Document msg
|
|
template title body =
|
|
{ title = title
|
|
, body =
|
|
[ node "main"
|
|
[]
|
|
[ navBar
|
|
, div [] body
|
|
, footer
|
|
]
|
|
]
|
|
}
|
|
|
|
|
|
navBar : Html msg
|
|
navBar =
|
|
node "nav"
|
|
[]
|
|
[ p []
|
|
[ viewLink "/" "Mi"
|
|
, text " - "
|
|
, viewLink "/switch" "Switch tracker"
|
|
, text " - "
|
|
, viewLink "/logout" "Logout"
|
|
]
|
|
]
|
|
|
|
|
|
footer : Html msg
|
|
footer =
|
|
node "footer"
|
|
[]
|
|
[ p []
|
|
[ a [ href "https://within.website" ] [ text "From Within" ]
|
|
, text " - "
|
|
, a [ href "https://tulpa.dev/cadey/mi" ] [ text "Source code" ]
|
|
]
|
|
]
|
|
|
|
|
|
viewInput : String -> String -> String -> (String -> msg) -> Html msg
|
|
viewInput t p v toMsg =
|
|
input [ type_ t, placeholder p, value v, onInput toMsg ] []
|
|
|
|
|
|
viewLink : String -> String -> Html msg
|
|
viewLink path title =
|
|
a [ href path ] [ text title ]
|