Highlighting in Navigation of current favorite (Halfway-done without breadcrumbs)

This commit is contained in:
SJost 2018-06-12 11:17:55 +02:00
parent 66f066fc95
commit af6d97454d
2 changed files with 22 additions and 3 deletions

View File

@ -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

View File

@ -6,7 +6,7 @@ $newline never
$forall menuType <- menuTypes
$case menuType
$of NavbarAside (MenuItem label mIcon route _)
<li .asidenav__list-item :Just route == mcurrentRoute:.asidenav__list-item--active>
<li .asidenav__list-item :highlight route:.asidenav__list-item--active>
<a .asidenav__link-wrapper href=@{route}>
<div .glyphicon.glyphicon--#{fromMaybe "none" mIcon}>
<div .asidenav__link-label>#{label}
@ -18,7 +18,7 @@ $newline never
<ul .asidenav__list>
$forall (Course{..}, courseRoute, pageActions) <- favourites
$# TODO: this list-item should also be marked as active if one of its children is shown
<li .asidenav__list-item :Just courseRoute == mcurrentRoute:.asidenav__list-item--active>
<li .asidenav__list-item :highlight courseRoute:.asidenav__list-item--active>
<a .asidenav__link-wrapper href=@{courseRoute}>
<div .asidenav__link-shorthand>#{courseShorthand}
<div .asidenav__link-label>#{courseName}