aboutsummaryrefslogtreecommitdiff
path: root/client/src/Component/Button.hs
diff options
context:
space:
mode:
authorJoris2019-10-22 22:26:38 +0200
committerJoris2019-10-22 22:26:38 +0200
commit613ffccac4b3ab25c6d4c631fab757da0b35acf6 (patch)
tree13e448af89f4079bb62d7ce8b5a44b6a64515129 /client/src/Component/Button.hs
parent80f09e8b3a5c856e60922a73c9161a8c5392e4d4 (diff)
downloadbudget-613ffccac4b3ab25c6d4c631fab757da0b35acf6.tar.gz
budget-613ffccac4b3ab25c6d4c631fab757da0b35acf6.tar.bz2
budget-613ffccac4b3ab25c6d4c631fab757da0b35acf6.zip
Harmonize view component code style
Diffstat (limited to 'client/src/Component/Button.hs')
-rw-r--r--client/src/Component/Button.hs56
1 files changed, 28 insertions, 28 deletions
diff --git a/client/src/Component/Button.hs b/client/src/Component/Button.hs
index b1175d7..6faecef 100644
--- a/client/src/Component/Button.hs
+++ b/client/src/Component/Button.hs
@@ -1,8 +1,8 @@
module Component.Button
- ( ButtonIn(..)
- , ButtonOut(..)
- , button
- , defaultButtonIn
+ ( In(..)
+ , Out(..)
+ , view
+ , defaultIn
) where
import qualified Data.Map as M
@@ -14,44 +14,44 @@ import qualified Reflex.Dom as R
import qualified View.Icon as Icon
-data ButtonIn t m = ButtonIn
- { _buttonIn_class :: Dynamic t Text
- , _buttonIn_content :: m ()
- , _buttonIn_waiting :: Event t Bool
- , _buttonIn_tabIndex :: Maybe Int
- , _buttonIn_submit :: Bool
+data In t m = In
+ { _in_class :: Dynamic t Text
+ , _in_content :: m ()
+ , _in_waiting :: Event t Bool
+ , _in_tabIndex :: Maybe Int
+ , _in_submit :: Bool
}
-defaultButtonIn :: MonadWidget t m => m () -> ButtonIn t m
-defaultButtonIn content = ButtonIn
- { _buttonIn_class = R.constDyn ""
- , _buttonIn_content = content
- , _buttonIn_waiting = R.never
- , _buttonIn_tabIndex = Nothing
- , _buttonIn_submit = False
+defaultIn :: MonadWidget t m => m () -> In t m
+defaultIn content = In
+ { _in_class = R.constDyn ""
+ , _in_content = content
+ , _in_waiting = R.never
+ , _in_tabIndex = Nothing
+ , _in_submit = False
}
-data ButtonOut t = ButtonOut
- { _buttonOut_clic :: Event t ()
+data Out t = Out
+ { _out_clic :: Event t ()
}
-button :: forall t m. MonadWidget t m => ButtonIn t m -> m (ButtonOut t)
-button buttonIn = do
- dynWaiting <- R.holdDyn False $ _buttonIn_waiting buttonIn
+view :: forall t m. MonadWidget t m => In t m -> m (Out t)
+view input = do
+ dynWaiting <- R.holdDyn False $ _in_waiting input
let attr = do
- buttonClass <- _buttonIn_class buttonIn
+ buttonClass <- _in_class input
waiting <- dynWaiting
return . M.fromList . catMaybes $
- [ Just ("type", if _buttonIn_submit buttonIn then "submit" else "button")
- , (\i -> ("tabindex", T.pack . show $ i)) <$> _buttonIn_tabIndex buttonIn
+ [ Just ("type", if _in_submit input then "submit" else "button")
+ , (\i -> ("tabindex", T.pack . show $ i)) <$> _in_tabIndex input
, Just ("class", T.intercalate " " [ buttonClass, if waiting then "waiting" else "" ])
]
(e, _) <- R.elDynAttr' "button" attr $ do
Icon.loading
- R.divClass "content" $ _buttonIn_content buttonIn
+ R.divClass "content" $ _in_content input
- return $ ButtonOut
- { _buttonOut_clic = R.domEvent R.Click e
+ return $ Out
+ { _out_clic = R.domEvent R.Click e
}