-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathPage.elm
More file actions
41 lines (30 loc) · 1.06 KB
/
Page.elm
File metadata and controls
41 lines (30 loc) · 1.06 KB
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
module Page exposing (ParentMsg(..), SubMsg(..), logoutView, wrapChildMsg, wrapParentMsg)
import Html as H
import Html.Attributes as HA
import Html.Events as HE
import Route
import Session
type ParentMsg
= SetPlayer Route.Route (Maybe Session.Player)
| Logout
{-| Messages that child pages raise to here.
-}
type SubMsg a
= ParentMsg ParentMsg -- A message that are global and handled by the top level update
| ChildMsg a -- A message that is just for the child's update
wrapParentMsg : (b -> ParentMsg) -> b -> SubMsg a
wrapParentMsg f =
f >> ParentMsg
wrapChildMsg : (b -> a) -> b -> SubMsg a
wrapChildMsg f =
f >> ChildMsg
logoutView : Session.Player -> H.Html (SubMsg a)
logoutView player =
H.div [ HA.class "logged-in" ]
[ H.div [ HA.class "logged-in-left" ] [ Route.routeLink Route.Lobby [ H.text "Lobby" ] ]
, H.div [ HA.class "logged-in-right" ]
[ H.text player.playerId
, H.text " "
, H.button [ HA.class "btn", HE.onClick (ParentMsg Logout) ] [ H.text "logout" ]
]
]