aboutsummaryrefslogtreecommitdiff
path: root/client/src/Component/Modal.hs
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/Component/Modal.hs')
-rw-r--r--client/src/Component/Modal.hs19
1 files changed, 11 insertions, 8 deletions
diff --git a/client/src/Component/Modal.hs b/client/src/Component/Modal.hs
index b86fee0..d7943a9 100644
--- a/client/src/Component/Modal.hs
+++ b/client/src/Component/Modal.hs
@@ -23,11 +23,12 @@ data ModalIn t m a = ModalIn
, _modalIn_content :: m a
}
-data ModalOut a = ModalOut
+data ModalOut t a = ModalOut
{ _modalOut_content :: a
+ , _modalOut_hide :: Event t ()
}
-modal :: forall t m a. MonadWidget t m => ModalIn t m a -> m (ModalOut a)
+modal :: forall t m a. MonadWidget t m => ModalIn t m a -> m (ModalOut t a)
modal modalIn = do
rec
let showEvent = R.leftmost
@@ -48,6 +49,7 @@ modal modalIn = do
return $ ModalOut
{ _modalOut_content = content
+ , _modalOut_hide = curtainClick
}
getAttributes :: Bool -> LM.Map Text Text
@@ -67,12 +69,13 @@ performShowEffects showEvent elem = do
let showEffects =
flip fmap showEvent (\show -> do
- if show
- then
- do
- Node.appendChild body elem
- Element.setClassName body ("modal" :: JSString)
- else
+ if show then
+ do
+ Node.appendChild body elem
+ Element.setClassName body ("modal" :: JSString)
+ else
+ do
+ Node.removeChild body elem
Element.setClassName body ("" :: JSString)
)