From aa64d6bdaa9fd23d205c18974dac8f29d29fd4f3 Mon Sep 17 00:00:00 2001 From: Joris Date: Tue, 5 Apr 2016 14:08:02 +0200 Subject: Highlight current page in header --- src/client/elm/View/Header.elm | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'src/client') diff --git a/src/client/elm/View/Header.elm b/src/client/elm/View/Header.elm index 7a6fefc..2edde27 100644 --- a/src/client/elm/View/Header.elm +++ b/src/client/elm/View/Header.elm @@ -5,6 +5,8 @@ module View.Header import Signal exposing (Address) import Dict +import TransitRouter + import Route exposing (..) import Html exposing (..) @@ -21,18 +23,26 @@ import View.Click exposing (clickTo) renderHeader : Address Action -> Model -> Html renderHeader address model = - let item route name additionalClasses = + let item = specialItem True "" + specialItem showCurrent additionalClasses route name = a - ([ class ("item " ++ additionalClasses) ] ++ clickTo route) - [ text (getMessage name model.translations) ] + ( [ classList + [ ("item", True) + , (additionalClasses, True) + , ("current", showCurrent && TransitRouter.getRoute model == route) + ] + ] ++ clickTo route + ) + [ text (getMessage name model.translations) + ] in header [] - ( [item Home "SharedCost" "title"] ++ - case model.view of + ( case model.view of LoggedInView { me, users } -> - [ item Income "Income" "" - , item Stat "Statistics" "" + [ specialItem True "title" Home "SharedCost" + , item Income "Income" + , item Stat "Statistics" , button [ class "signOut item" , onClick address SignOut @@ -47,5 +57,5 @@ renderHeader address model = ] ] _ -> - [] + [specialItem False "title" Home "SharedCost"] ) -- cgit v1.2.3