diff options
Diffstat (limited to 'frontend/app/Form/Input.hs')
-rw-r--r-- | frontend/app/Form/Input.hs | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/frontend/app/Form/Input.hs b/frontend/app/Form/Input.hs index e43651c..99fd821 100644 --- a/frontend/app/Form/Input.hs +++ b/frontend/app/Form/Input.hs @@ -3,30 +3,29 @@ module Form.Input ) where -import Data.Text qualified as T import Form.Internal import Miso -import Miso.String (fromMisoString, toMisoString) +import Miso.String (MisoString, null, strip) -input :: String -> Form T.Text T.Text +input :: MisoString -> Form MisoString MisoString input label = - let parse :: T.Text -> Either String T.Text + let parse :: MisoString -> Either MisoString MisoString parse i = - let i' = T.strip i - in if T.null i' then Left "required" else Right i' + let i' = strip i + in if Miso.String.null i' then Left "required" else Right i' in Form { view = \i -> [ div_ [] $ [ label_ [] $ - [ text (toMisoString label), + [ text label, div_ [] $ [ input_ [ type_ "text", - value_ (toMisoString i), - onInput fromMisoString + value_ i, + onInput id ], div_ [] $ - [either (text . toMisoString) (\_ -> text "") (parse i)] + [either text (\_ -> text "") (parse i)] ] ] ] |