Skip to content

Instantly share code, notes, and snippets.

@Chadtech
Created September 7, 2017 14:59
Show Gist options
  • Save Chadtech/dbfc6b7291488926441f1c3f6a288f7f to your computer and use it in GitHub Desktop.
Save Chadtech/dbfc6b7291488926441f1c3f6a288f7f to your computer and use it in GitHub Desktop.
navItemAttrs : String -> NavigationPoint -> NavigationPoint -> List (Attribute Msg)
navItemAttrs navPointName thisNavPoint currentNavPoint =
let
base =
[ title base
, subtitle ""
, onClick (Navigate thisNavPoint)
]
in
if currentNavPoint == thisNavPoint then
isActive :: base
else
base
-- IN PRACTICE --
view =
navItem
(navItemAttrs "Customer" Customer model.navigationPoint)
[]
-- ANOTHER IDEA --
navItem_ : List (Attribute Msg) -> String -> NavigationPoint -> NavigationPoint -> Html Msg
navItem_ attrs navPointName thisNavPoint currentNavPoint =
let
base =
List.append
[ title base
, subtitle ""
, onClick (Navigate thisNavPoint)
]
attrs
in
if currentNavPoint == thisNavPoint then
navItem (isActive :: base) []
else
navItem base []
view =
navItem_ [] "Customer" Customer model.navigationPoint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment