{-| Module: IHP.Modal.ViewFunctions Description: View Helper Functions to use modals Copyright: (c) digitally induced GmbH, 2020 -} module IHP.Modal.ViewFunctions (modal, renderModal) where import IHP.Prelude import IHP.Controller.Context import IHP.HSX.QQ (hsx) import IHP.Modal.Types import Text.Blaze.Html5 (Html) renderModal modal = renderModal' modal True renderModal' Modal { .. } show = [hsx| |] where modalClassName :: Text modalClassName = "modal fade overflow-auto " <> if show then "show" else "" backdropClassName :: Text backdropClassName = "modal-backdrop fade " <> if show then "show" else "" displayStyle :: Text displayStyle = if show then "display: block" else "display: none" modalInner = [hsx| |] renderModalFooter = case modalFooter of Just modalFooter -> [hsx||] Nothing -> mempty renderModalHeader :: Text -> Text -> Html renderModalHeader title closeUrl = [hsx| |] modal :: (?context :: ControllerContext) => Html modal = case maybeFromFrozenContext of Just (ModalContainer html) -> html Nothing -> mempty