Highlighting in Navigation of current favorite (Halfway-done without breadcrumbs)
This commit is contained in:
parent
66f066fc95
commit
af6d97454d
@ -110,6 +110,16 @@ type MsgRenderer = MsgRendererS UniWorX -- see Utils
|
|||||||
pattern CSheetR tid csh shn ptn
|
pattern CSheetR tid csh shn ptn
|
||||||
= CourseR tid csh (SheetR 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
|
-- Menus and Favourites
|
||||||
data MenuItem = MenuItem
|
data MenuItem = MenuItem
|
||||||
@ -419,12 +429,16 @@ instance Yesod UniWorX where
|
|||||||
-- Get the breadcrumbs, as defined in the YesodBreadcrumbs instance.
|
-- Get the breadcrumbs, as defined in the YesodBreadcrumbs instance.
|
||||||
(title, parents) <- breadcrumbs
|
(title, parents) <- breadcrumbs
|
||||||
|
|
||||||
|
-- let isParent :: Route UniWorX -> Bool
|
||||||
|
-- isParent r = r == (fst parents)
|
||||||
|
|
||||||
|
|
||||||
let
|
let
|
||||||
menu = defaultLinks ++ maybe [] pageActions mcurrentRoute
|
menu = defaultLinks ++ maybe [] pageActions mcurrentRoute
|
||||||
|
|
||||||
menuTypes <- filterM (menuItemAccessCallback . menuItem) menu
|
menuTypes <- filterM (menuItemAccessCallback . menuItem) menu
|
||||||
|
|
||||||
-- Lookup Favourites if possible
|
-- Lookup Favourites & Theme if possible
|
||||||
favourites' <- do
|
favourites' <- do
|
||||||
muid <- maybeAuthId
|
muid <- maybeAuthId
|
||||||
case muid of
|
case muid of
|
||||||
@ -440,6 +454,11 @@ instance Yesod UniWorX where
|
|||||||
courseRoute = CourseR courseTerm courseShorthand CShowR
|
courseRoute = CourseR courseTerm courseShorthand CShowR
|
||||||
in (c, courseRoute, ) <$> filterM (menuItemAccessCallback . menuItem) (pageActions courseRoute)
|
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
|
-- TODO: Lookup theme in Cookie/DB and set variable accordingly
|
||||||
-- let currentTheme = "theme--default"
|
-- let currentTheme = "theme--default"
|
||||||
let currentTheme = "theme--aberdeen-reds" :: Text
|
let currentTheme = "theme--aberdeen-reds" :: Text
|
||||||
|
|||||||
@ -6,7 +6,7 @@ $newline never
|
|||||||
$forall menuType <- menuTypes
|
$forall menuType <- menuTypes
|
||||||
$case menuType
|
$case menuType
|
||||||
$of NavbarAside (MenuItem label mIcon route _)
|
$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}>
|
<a .asidenav__link-wrapper href=@{route}>
|
||||||
<div .glyphicon.glyphicon--#{fromMaybe "none" mIcon}>
|
<div .glyphicon.glyphicon--#{fromMaybe "none" mIcon}>
|
||||||
<div .asidenav__link-label>#{label}
|
<div .asidenav__link-label>#{label}
|
||||||
@ -18,7 +18,7 @@ $newline never
|
|||||||
<ul .asidenav__list>
|
<ul .asidenav__list>
|
||||||
$forall (Course{..}, courseRoute, pageActions) <- favourites
|
$forall (Course{..}, courseRoute, pageActions) <- favourites
|
||||||
$# TODO: this list-item should also be marked as active if one of its children is shown
|
$# 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}>
|
<a .asidenav__link-wrapper href=@{courseRoute}>
|
||||||
<div .asidenav__link-shorthand>#{courseShorthand}
|
<div .asidenav__link-shorthand>#{courseShorthand}
|
||||||
<div .asidenav__link-label>#{courseName}
|
<div .asidenav__link-label>#{courseName}
|
||||||
|
|||||||
Reference in New Issue
Block a user