diff --git a/src/Foundation.hs b/src/Foundation.hs index 02672d94f..2cd146bba 100644 --- a/src/Foundation.hs +++ b/src/Foundation.hs @@ -110,6 +110,16 @@ type MsgRenderer = MsgRendererS UniWorX -- see Utils pattern CSheetR tid csh shn ptn = CourseR tid csh (SheetR shn ptn) +-- Change this to use breadcrumbs, but only last breadcrumb should match +isSubrouteOf :: Maybe (Route UniWorX) -> (Route UniWorX -> Bool) -- DEPRECATED +isSubrouteOf Nothing _ = False +isSubrouteOf (Just (CourseR t2 s2 _)) (CourseR t1 s1 _) = t1 == t2 && s1 == s2 +isSubrouteOf (Just (TermEditR)) (TermShowR) = True +isSubrouteOf (Just (TermEditExistR _)) (TermShowR) = True +isSubrouteOf (Just r2) r1 = r1 == r2 + +-- isSubrouteOf _ _ = False + -- Menus and Favourites data MenuItem = MenuItem @@ -419,12 +429,16 @@ instance Yesod UniWorX where -- Get the breadcrumbs, as defined in the YesodBreadcrumbs instance. (title, parents) <- breadcrumbs +-- let isParent :: Route UniWorX -> Bool +-- isParent r = r == (fst parents) + + let menu = defaultLinks ++ maybe [] pageActions mcurrentRoute menuTypes <- filterM (menuItemAccessCallback . menuItem) menu - -- Lookup Favourites if possible + -- Lookup Favourites & Theme if possible favourites' <- do muid <- maybeAuthId case muid of @@ -440,6 +454,11 @@ instance Yesod UniWorX where courseRoute = CourseR courseTerm courseShorthand CShowR in (c, courseRoute, ) <$> filterM (menuItemAccessCallback . menuItem) (pageActions courseRoute) + let highlight :: Route UniWorX -> Bool + highlight = isSubrouteOf mcurrentRoute -- TODO + -- IDEA: highlight on last route in breadcrumbs only + -- toHighlight = undefined -- TODO: last breadcrumb in order only + -- TODO: Lookup theme in Cookie/DB and set variable accordingly -- let currentTheme = "theme--default" let currentTheme = "theme--aberdeen-reds" :: Text diff --git a/templates/widgets/asidenav.hamlet b/templates/widgets/asidenav.hamlet index 2ab729e25..4d6c5a137 100644 --- a/templates/widgets/asidenav.hamlet +++ b/templates/widgets/asidenav.hamlet @@ -6,7 +6,7 @@ $newline never $forall menuType <- menuTypes $case menuType $of NavbarAside (MenuItem label mIcon route _) -