aboutsummaryrefslogtreecommitdiff
path: root/client/src/Component/Pages.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/Pages.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/Pages.hs')
-rw-r--r--client/src/Component/Pages.hs45
1 files changed, 22 insertions, 23 deletions
diff --git a/client/src/Component/Pages.hs b/client/src/Component/Pages.hs
index 7843ef6..7284a36 100644
--- a/client/src/Component/Pages.hs
+++ b/client/src/Component/Pages.hs
@@ -1,41 +1,40 @@
module Component.Pages
- ( widget
- , PagesIn(..)
- , PagesOut(..)
+ ( view
+ , In(..)
+ , Out(..)
) where
import qualified Data.Text as T
import Reflex.Dom (Dynamic, Event, MonadWidget)
import qualified Reflex.Dom as R
-import Component.Button (ButtonIn (..), ButtonOut (..))
import qualified Component.Button as Button
import qualified Util.Reflex as ReflexUtil
import qualified View.Icon as Icon
-data PagesIn t = PagesIn
- { _pagesIn_total :: Dynamic t Int
- , _pagesIn_perPage :: Int
- , _pagesIn_reset :: Event t ()
+data In t = In
+ { _in_total :: Dynamic t Int
+ , _in_perPage :: Int
+ , _in_reset :: Event t ()
}
-data PagesOut t = PagesOut
- { _pagesOut_currentPage :: Dynamic t Int
+data Out t = Out
+ { _out_currentPage :: Dynamic t Int
}
-widget :: forall t m. MonadWidget t m => PagesIn t -> m (PagesOut t)
-widget pagesIn = do
+view :: forall t m. MonadWidget t m => In t -> m (Out t)
+view input = do
currentPage <- ReflexUtil.divVisibleIf ((> 0) <$> total) $ pageButtons total perPage reset
- return $ PagesOut
- { _pagesOut_currentPage = currentPage
+ return $ Out
+ { _out_currentPage = currentPage
}
where
- total = _pagesIn_total pagesIn
- perPage = _pagesIn_perPage pagesIn
- reset = _pagesIn_reset pagesIn
+ total = _in_total input
+ perPage = _in_perPage input
+ reset = _in_reset input
pageButtons :: forall t m. MonadWidget t m => Dynamic t Int -> Int -> Event t () -> m (Dynamic t Int)
pageButtons total perPage reset = do
@@ -75,14 +74,14 @@ range currentPage maxPage = [start..end]
pageButton :: forall t m. MonadWidget t m => Dynamic t (Maybe Int) -> Dynamic t Int -> m () -> m (Event t Int)
pageButton currentPage page content = do
- clic <- _buttonOut_clic <$> (Button.button $ ButtonIn
- { _buttonIn_class = do
+ clic <- Button._out_clic <$> (Button.view $ Button.In
+ { Button._in_class = do
cp <- currentPage
p <- page
if cp == Just p then "page current" else "page"
- , _buttonIn_content = content
- , _buttonIn_waiting = R.never
- , _buttonIn_tabIndex = Nothing
- , _buttonIn_submit = False
+ , Button._in_content = content
+ , Button._in_waiting = R.never
+ , Button._in_tabIndex = Nothing
+ , Button._in_submit = False
})
return . fmap fst $ R.attach (R.current page) clic