aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/View/Header.elm
blob: 5597429973acc7cbe3b43993b16c0f801f8f1701 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
module View.Header exposing
  ( renderHeader
  )

import Dict

import Page exposing (..)

import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)

import Model exposing (Model)
import Model.Translations exposing (getMessage)
import Msg exposing (..)
import Model.View exposing (..)

import View.Icon exposing (renderIcon)

renderHeader : Model -> Html Msg
renderHeader model =
  header
    []
    (  [ div [ class "title" ] [ text (getMessage "SharedCost" model.translations) ] ]
    ++ let item page name =
             a
               [ href (Page.toHash page)
               , classList
                   [ ("item", True)
                   , ("current", model.page == page)
                   ]
               ]
               [ text (getMessage name model.translations)
               ]
       in  case model.view of
             LoggedInView { me, users } ->
               [ item Home "PaymentsTitle"
               , item Income "Income"
               , item Statistics "Statistics"
               , div
                   [ class "nameSignOut" ]
                   [ div
                       [ class "name" ]
                       [ Dict.get me users
                           |> Maybe.map .name
                           |> Maybe.withDefault ""
                           |> text
                       ]
                   , button
                       [ class "signOut item"
                       , onClick SignOut
                       ]
                       [ renderIcon "power-off" ]
                   ]
               ]
             _ ->
               []
    )