Navigation breadcrumbs
This commit is contained in:
parent
fba63c1e1f
commit
ab66c92871
2 changed files with 33 additions and 2 deletions
|
@ -217,6 +217,24 @@ update msg model =
|
|||
navBar : Model -> E.Element Msg
|
||||
navBar model =
|
||||
let
|
||||
isRoute : Route.Route -> Bool
|
||||
isRoute route =
|
||||
case model.route of
|
||||
Nothing ->
|
||||
False
|
||||
|
||||
Just current ->
|
||||
route == current
|
||||
|
||||
inRoute : Route.Route -> Bool
|
||||
inRoute route =
|
||||
case model.route of
|
||||
Nothing ->
|
||||
False
|
||||
|
||||
Just current ->
|
||||
List.member route <| Route.breadcrumbs current
|
||||
|
||||
navLink : Route.Route -> String -> E.Element Msg
|
||||
navLink route text =
|
||||
E.link
|
||||
|
@ -224,9 +242,12 @@ navBar model =
|
|||
, E.padding 10
|
||||
, Font.center
|
||||
, Background.color <|
|
||||
if Just route == model.route then
|
||||
if isRoute route then
|
||||
UI.colors.primary
|
||||
|
||||
else if inRoute route then
|
||||
UI.colors.secondary
|
||||
|
||||
else
|
||||
UI.colors.background
|
||||
, E.mouseOver [ Background.color UI.colors.primary ]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module Route exposing (Route(..), fromUrl, toUrl)
|
||||
module Route exposing (Route(..), breadcrumbs, fromUrl, toUrl)
|
||||
|
||||
import Url exposing (Url)
|
||||
import Url.Builder
|
||||
|
@ -37,3 +37,13 @@ toUrl route =
|
|||
fromUrl : Url.Url -> Maybe Route
|
||||
fromUrl url =
|
||||
parse parser url
|
||||
|
||||
|
||||
breadcrumbs : Route -> List Route
|
||||
breadcrumbs route =
|
||||
case route of
|
||||
Deck _ ->
|
||||
[ DeckList, route ]
|
||||
|
||||
_ ->
|
||||
[ route ]
|
||||
|
|
Loading…
Reference in a new issue