Commit 852c5a8b authored by Darya Rednikina's avatar Darya Rednikina
Browse files

(#3) Added some kind of nav bar (ctr+c from spa example)

Needs a lot of styling
parent 75e2e602
module Page exposing (Page(..), view)
import Browser exposing (Document)
import Html exposing (Html)
import Html exposing (Html, a, div, li, nav, text, ul)
import Html.Attributes exposing (class, classList, href)
import Route exposing (Route)
view :
Page
-> { title : String, content : Html msg }
-> Document msg
view _ { title, content } =
view page { title, content } =
{ title = title
, body = [ content ]
, body = viewHeader page :: [ content ]
}
viewHeader : Page -> Html msg
viewHeader page =
case page of
Register ->
div [] []
Login ->
div [] []
_ ->
nav [ class "navbar navbar-light" ]
[ div [ class "container" ]
[ a [ class "navbar-brand", Route.href Route.Projects ]
[ text "conduit" ]
, ul [ class "nav navbar-nav pull-xs-right" ] <|
[ navbarLink page Route.Projects [ text "Projects" ] ]
]
]
navbarLink : Page -> Route -> List (Html msg) -> Html msg
navbarLink page route linkContent =
li [ classList [ ( "nav-item", True ), ( "active", isActive page route ) ] ]
[ a [ class "nav-link", Route.href route ] linkContent ]
isActive : Page -> Route -> Bool
isActive page route =
case ( page, route ) of
( Projects, Route.Projects ) ->
True
_ ->
False
{-| PAGE type for future configurations of header/footer/...
-}
type Page
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment