From 166cd04e4b28770ede854dafc9ae30eae64102fe Mon Sep 17 00:00:00 2001 From: Joris Date: Mon, 28 Mar 2016 17:51:14 +0200 Subject: Create an empty but reachable user page --- src/client/elm/View/Click.elm | 24 ++++++++++++++++++++++++ src/client/elm/View/Header.elm | 15 +++++++++------ 2 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 src/client/elm/View/Click.elm (limited to 'src/client/elm/View') diff --git a/src/client/elm/View/Click.elm b/src/client/elm/View/Click.elm new file mode 100644 index 0000000..a722cac --- /dev/null +++ b/src/client/elm/View/Click.elm @@ -0,0 +1,24 @@ +module View.Click + ( clickTo + ) where + +import Signal +import Json.Decode as Json + +import Html exposing (..) +import Html.Attributes exposing (..) +import Html.Events exposing (..) + +import TransitRouter +import Route exposing (Route, toPath) + +clickTo : Route -> List Attribute +clickTo route = + let path = toPath route + in [ href path + , onWithOptions + "click" + { stopPropagation = True, preventDefault = True } + Json.value + (\_ -> Signal.message TransitRouter.pushPathAddress path) + ] diff --git a/src/client/elm/View/Header.elm b/src/client/elm/View/Header.elm index f1b0e76..5a37d9b 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 Route exposing (..) + import Html exposing (..) import Html.Attributes exposing (..) import Html.Events exposing (..) @@ -15,24 +17,25 @@ import Action exposing (..) import Model.View exposing (..) import View.Icon exposing (renderIcon) +import View.Click exposing (clickTo) renderHeader : Address Action -> Model -> Html renderHeader address model = header [] - [ button - [ class "title" ] + [ a + ( [ class "title" ] ++ clickTo Home) [ h1 [] [ text (getMessage "SharedCost" model.translations) ] ] , case model.view of - LoggedInView { users, account } -> + LoggedInView { home } -> div [ class "signedPanel" ] - [ button - [ class "user" ] - [ Dict.get account.me users + [ a + ( [ class "user" ] ++ clickTo User) + [ Dict.get home.account.me home.users |> Maybe.map .name |> Maybe.withDefault "" |> text -- cgit v1.2.3