Skip to content

Instantly share code, notes, and snippets.

@rrichardson
Created August 24, 2015 20:31
Show Gist options
  • Save rrichardson/f87841c867725466dee1 to your computer and use it in GitHub Desktop.
Save rrichardson/f87841c867725466dee1 to your computer and use it in GitHub Desktop.
(=>) = (,)
navb : Address NavAction -> M.State -> List Html
navb addr model =
[ div [class "navbar-spacer"] []
, nav [class "navbar"]
[ div [class "centered container" ]
[
ul [class "navbar-list"]
[ li [class "navbar-item"] [
a [ classList ["active" => (model.page == "home"), "navbar-link" => True],
href "#home", onClick addr NavHome ]
[ text "Home" ]
]
, li [class "navbar-item"] [
a [ classList ["active" => (model.page == "find"), "navbar-link" => True],
href "#find", onClick addr NavFind ]
[ text "Find" ]
]
, li [class "navbar-item"] [
a [ classList ["active" => (model.page == "profile"), "navbar-link" => True],
href "#profile", onClick addr NavProfile ]
[ text "Profile" ]
]
, signInItem addr model
]
]
]
]
signInItem : Address NavAction -> M.State -> Html
signInItem addr model =
let (name, url, act) = if isJust model.user
then ("Sign Out", "#signout", NavSignOut) else ("Sign In", "#signin", NavSignIn)
in
li [class "navbar-item"] [
a [ classList ["active" => (model.page == "signin"), "navbar-link" => True],
href url, onClick addr act ]
[ text name ]
]
@alesch
Copy link

alesch commented Aug 24, 2015

What is this first line: (=>) = (,)?

@alesch
Copy link

alesch commented Aug 24, 2015

These navbar* classes are not part of Skeleton, right?

@pdamoc
Copy link

pdamoc commented Aug 25, 2015

@alesch, (=>) = (,) is used to avoid extra parentheses and to ascribe meaning to the tuple. Without it, line 11 would have probably been:

a [ classList [("active", (model.page == "home")), ("navbar-link", True)],

making it less obvious that there is a semantic link between active and model.page == "home".

At least this is how I read it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment