aboutsummaryrefslogtreecommitdiff
path: root/client/src/Component/Input.hs
diff options
context:
space:
mode:
authorJoris2018-06-24 22:02:00 +0200
committerJoris2018-06-24 22:02:00 +0200
commitdf83b634006c699cfa1e921bf74ce951a906a62f (patch)
tree65584291f8e93268326c6385df6c33d954b52199 /client/src/Component/Input.hs
parent33b85b7f12798f5762d940ed5c30f775cdd7b751 (diff)
downloadbudget-df83b634006c699cfa1e921bf74ce951a906a62f.tar.gz
budget-df83b634006c699cfa1e921bf74ce951a906a62f.tar.bz2
budget-df83b634006c699cfa1e921bf74ce951a906a62f.zip
Use date input type
Diffstat (limited to 'client/src/Component/Input.hs')
-rw-r--r--client/src/Component/Input.hs38
1 files changed, 25 insertions, 13 deletions
diff --git a/client/src/Component/Input.hs b/client/src/Component/Input.hs
index 92f8ec9..c1eb4e8 100644
--- a/client/src/Component/Input.hs
+++ b/client/src/Component/Input.hs
@@ -17,16 +17,20 @@ import qualified Component.Button as Button
import qualified Icon
data InputIn t a b = InputIn
- { _inputIn_reset :: Event t a
- , _inputIn_label :: Text
- , _inputIn_initialValue :: Text
+ { _inputIn_reset :: Event t a
+ , _inputIn_hasResetButton :: Bool
+ , _inputIn_label :: Text
+ , _inputIn_initialValue :: Text
+ , _inputIn_inputType :: Text
}
defaultInputIn :: (Reflex t) => InputIn t a b
defaultInputIn = InputIn
- { _inputIn_reset = R.never
- , _inputIn_label = ""
- , _inputIn_initialValue = ""
+ { _inputIn_reset = R.never
+ , _inputIn_hasResetButton = True
+ , _inputIn_label = ""
+ , _inputIn_initialValue = ""
+ , _inputIn_inputType = "text"
}
data InputOut t = InputOut
@@ -40,11 +44,13 @@ input inputIn =
rec
let resetValue = R.leftmost
[ fmap (const "") (_inputIn_reset inputIn)
- , fmap (const "") (_buttonOut_clic reset)
+ , fmap (const "") resetClic
]
attributes = R.ffor value (\v ->
- if T.null v then M.empty else M.singleton "class" "filled")
+ if T.null v && _inputIn_inputType inputIn /= "date"
+ then M.empty
+ else M.singleton "class" "filled")
value = R._textInput_value textInput
@@ -52,14 +58,20 @@ input inputIn =
& R.attributes .~ attributes
& R.setValue .~ resetValue
& R.textInputConfig_initialValue .~ (_inputIn_initialValue inputIn)
+ & R.textInputConfig_inputType .~ (_inputIn_inputType inputIn)
R.el "label" $ R.text (_inputIn_label inputIn)
- reset <- Button.button $
- (Button.defaultButtonIn Icon.cross)
- { _buttonIn_class = R.constDyn "reset"
- , _buttonIn_tabIndex = Just (-1)
- }
+ resetClic <-
+ if _inputIn_hasResetButton inputIn
+ then
+ _buttonOut_clic <$> (Button.button $
+ (Button.defaultButtonIn Icon.cross)
+ { _buttonIn_class = R.constDyn "reset"
+ , _buttonIn_tabIndex = Just (-1)
+ })
+ else
+ return R.never
let enter = fmap (const ()) $ R.ffilter ((==) 13) . R._textInput_keypress $ textInput