Add check to only show secondary pageactions when needed
Rename pageactionprime.* -> pageaction.*
This commit is contained in:
parent
4e17a36933
commit
8ee3d723c7
@ -253,6 +253,11 @@ uniworxMessages = UniWorXMessages . map SomeMessage
|
||||
data MenuType = NavbarAside | NavbarRight | NavbarSecondary | PageActionPrime | PageActionSecondary | Footer
|
||||
deriving (Eq, Ord, Enum, Bounded, Read, Show, Generic)
|
||||
|
||||
instance Universe MenuType
|
||||
instance Finite MenuType
|
||||
|
||||
makePrisms ''MenuType
|
||||
|
||||
data MenuItem = MenuItem
|
||||
{ menuItemLabel :: UniWorXMessage
|
||||
, menuItemIcon :: Maybe Text -- currently from: https://fontawesome.com/icons?d=gallery
|
||||
@ -262,6 +267,8 @@ data MenuItem = MenuItem
|
||||
, menuItemType :: MenuType
|
||||
}
|
||||
|
||||
makeLenses_ ''MenuItem
|
||||
|
||||
instance RedirectUrl UniWorX MenuItem where
|
||||
toTextUrl MenuItem{..} = toTextUrl menuItemRoute
|
||||
instance HasRoute UniWorX MenuItem where
|
||||
@ -932,15 +939,13 @@ siteLayout headingOverride widget = do
|
||||
contentHeadline = (toWidget <$> headingOverride) <|> (pageHeading =<< mcurrentRoute)
|
||||
breadcrumbsWgt :: Widget
|
||||
breadcrumbsWgt = $(widgetFile "widgets/breadcrumbs")
|
||||
pageactionprime :: Widget
|
||||
pageactionprime = $(widgetFile "widgets/pageactionprime") -- TODO: rename, since it also shows secondary pageActions now
|
||||
pageaction :: Widget
|
||||
pageaction = $(widgetFile "widgets/pageaction")
|
||||
-- functions to determine if there are page-actions (primary or secondary)
|
||||
isPageAction :: MenuType -> Bool
|
||||
isPageAction PageActionPrime = True
|
||||
isPageAction PageActionSecondary = True
|
||||
isPageAction _ = False
|
||||
hasPageActions :: Bool
|
||||
hasPageActions = any (isPageAction . menuItemType . view _1) menuTypes
|
||||
hasPageActions, hasSecondaryPageActions, hasPrimaryPageActions :: Bool
|
||||
hasPageActions = hasPrimaryPageActions || hasSecondaryPageActions
|
||||
hasSecondaryPageActions = any (is _PageActionSecondary) $ toListOf (traverse . _1 . _menuItemType) menuTypes
|
||||
hasPrimaryPageActions = any (is _PageActionPrime) $ toListOf (traverse . _1 . _menuItemType) menuTypes
|
||||
|
||||
pc <- widgetToPageContent $ do
|
||||
addStylesheetRemote "https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,800,900|Roboto:300,400,600"
|
||||
|
||||
@ -22,9 +22,9 @@ $if not isModal
|
||||
<a .breadcrumbs__link href="@{fst back}">#{snd back} -->
|
||||
^{headline}
|
||||
|
||||
$if not isModal
|
||||
<!-- prime page actions -->
|
||||
^{pageactionprime}
|
||||
$if not isModal && hasPageActions
|
||||
<!-- page actions -->
|
||||
^{pageaction}
|
||||
|
||||
<!-- actual content -->
|
||||
^{widget}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
$newline never
|
||||
$if hasPageActions
|
||||
<div .pagenav>
|
||||
<div .pagenav>
|
||||
$if hasPrimaryPageActions
|
||||
<div .pagenav-prime>
|
||||
$forall (MenuItem{menuItemLabel, menuItemType, menuItemModal}, menuIdent, route) <- menuTypes
|
||||
$case menuItemType
|
||||
@ -10,7 +10,7 @@ $if hasPageActions
|
||||
<div .modal.js-modal #modal-#{menuIdent} data-trigger=#{menuIdent} data-closeable data-dynamic>
|
||||
<a .pagenav__link-wrapper href=#{route} ##{menuIdent}>_{SomeMessage menuItemLabel}
|
||||
$of _
|
||||
<!-- TODO: add check if there are any PageActionSecondarys -->
|
||||
$if hasSecondaryPageActions
|
||||
<div .pagenav-secondary>
|
||||
<div .pagenav-secondary__list>
|
||||
$forall (MenuItem{menuItemLabel, menuItemType, menuItemModal}, menuIdent, route) <- menuTypes
|
||||
Loading…
Reference in New Issue
Block a user