fradrive/src/Utils/Frontend/Notification.hs
Gregor Kleen 1348c91c3c feat: navbar header containers
BREAKING CHANGE: major navigation refactor
2020-02-06 16:27:28 +01:00

44 lines
1.1 KiB
Haskell

module Utils.Frontend.Notification
( NotificationType(..)
, notification
, notificationWidget
) where
import ClassyPrelude.Yesod
import Settings
import Utils.Message
import Utils.Icon
import Control.Lens
import Control.Lens.Extras (is)
data NotificationType
= NotificationNarrow
| NotificationBroad
deriving (Eq, Ord, Read, Show, Enum, Bounded, Generic, Typeable)
makePrisms ''NotificationType
notification :: NotificationType
-> Message
-> WidgetFor site ()
notification nType Message{ messageIcon = messageIcon', .. }
= $(widgetFile "widgets/notification")
where
messageIcon = fromMaybe defaultIcon messageIcon'
defaultIcon = case messageStatus of
Success -> IconNotificationSuccess
Info -> IconNotificationInfo
Warning -> IconNotificationWarning
Error -> IconNotificationError
notificationWidget :: Yesod site
=> NotificationType
-> MessageStatus
-> WidgetFor site ()
-> WidgetFor site ()
notificationWidget nType ms = notification nType <=< messageWidget ms