aboutsummaryrefslogtreecommitdiff
path: root/client/src/Component
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/Component')
-rw-r--r--client/src/Component/Button.hs10
-rw-r--r--client/src/Component/Input.hs38
2 files changed, 25 insertions, 23 deletions
diff --git a/client/src/Component/Button.hs b/client/src/Component/Button.hs
index bf604f1..46c0afa 100644
--- a/client/src/Component/Button.hs
+++ b/client/src/Component/Button.hs
@@ -31,20 +31,10 @@ defaultButtonIn content = ButtonIn
, _buttonIn_submit = False
}
--- defaultButtonIn :: MonadWidget t m => ButtonIn t m
--- defaultButtonIn = ButtonIn
--- { _buttonIn_class = R.constDyn ""
--- , _buttonIn_content = R.blank
--- , _buttonIn_waiting = R.never
--- , _buttonIn_tabIndex = Nothing
--- , _buttonIn_submit = False
--- }
-
data ButtonOut t = ButtonOut
{ _buttonOut_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
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