{-|
Module: IHP.Modal.ControllerFunctions
Description: Controller Helper Functions to use modals
Copyright: (c) digitally induced GmbH, 2020
-}
module IHP.Modal.ControllerFunctions (setModal) where

import IHP.Prelude
import IHP.Controller.Context
import IHP.Controller.Layout
import IHP.Modal.Types
import qualified IHP.ViewSupport as ViewSupport
import Text.Blaze.Html5 (Html)

setModal :: (?context :: ControllerContext, ViewSupport.View view) => view -> IO ()
setModal :: view -> IO ()
setModal view
view = do
    Html
html <- do
        ControllerContext
context <- ControllerContext -> IO ControllerContext
freeze ?context::ControllerContext
ControllerContext
?context
        let ?context = context
        let ?view = view
        Html -> IO Html
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html -> IO Html) -> Html -> IO Html
forall a b. (a -> b) -> a -> b
$ view -> Html
forall theView.
(View theView, ?context::ControllerContext, ?view::theView) =>
theView -> Html
ViewSupport.html view
view
        
    ModalContainer -> IO ()
forall value.
(?context::ControllerContext, Typeable value) =>
value -> IO ()
putContext (Html -> ModalContainer
ModalContainer Html
html)