From 4d73afa642e291b8f33c32a493acb2dc409183b7 Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Fri, 9 Jun 2023 00:28:03 +0200 Subject: [PATCH] Bulma now has some input boxes. --- src/App/AuthenticationForm.purs | 47 +++++++-------------------------- src/Bulma.purs | 23 +++++++++++++++- 2 files changed, 32 insertions(+), 38 deletions(-) diff --git a/src/App/AuthenticationForm.purs b/src/App/AuthenticationForm.purs index 0ae5231..2d463e1 100644 --- a/src/App/AuthenticationForm.purs +++ b/src/App/AuthenticationForm.purs @@ -223,45 +223,18 @@ render { , render_register_form ] - render_input password placeholder action value validity cond - = HH.input $ - [ HE.onValueInput action - , HP.value value - , HP.placeholder placeholder - , Bulma.input_classes validity - , cond - ] <> case password of - false -> [] - true -> [ HP.type_ HP.InputPassword ] - - box_input title placeholder action value validity cond - = HH.label [ ] - [ HH.label [HP.classes Bulma.class_label ] [ HH.text title ] - , HH.div [HP.classes Bulma.class_control ] [ render_input false placeholder action value validity cond ] - ] - - box_password title placeholder action value validity cond - = HH.label [ ] - [ HH.label [HP.classes Bulma.class_label ] [ HH.text title ] - , HH.div [HP.classes Bulma.class_control ] [ render_input true placeholder action value validity cond ] - ] - render_auth_form = HH.form [ HE.onSubmit AuthenticationAttempt ] - [ box_input - "Login" -- title - "login" -- placeholder - (HandleAuthenticationInput <<< AUTH_INP_login) -- action - authenticationForm.login -- value - true -- validity (TODO) - (maybe (HP.disabled true) (\_ -> HP.enabled true) wsConnection) -- condition - , box_password - "Password" -- title - "password" -- placeholder - (HandleAuthenticationInput <<< AUTH_INP_pass) -- action - authenticationForm.pass -- value - true -- validity (TODO) - (maybe (HP.disabled true) (\_ -> HP.enabled true) wsConnection) -- condition + [ Bulma.box_input "Login" "login" -- title, placeholder + (HandleAuthenticationInput <<< AUTH_INP_login) -- action + authenticationForm.login -- value + true -- validity (TODO) + (maybe (HP.disabled true) (\_ -> HP.enabled true) wsConnection) -- condition + , Bulma.box_password "Password" "password" -- title, placeholder + (HandleAuthenticationInput <<< AUTH_INP_pass) -- action + authenticationForm.pass -- value + true -- validity (TODO) + (maybe (HP.disabled true) (\_ -> HP.enabled true) wsConnection) -- condition , HH.button [ HP.style "padding: 0.5rem 1.25rem;" , HP.type_ HP.ButtonSubmit diff --git a/src/Bulma.purs b/src/Bulma.purs index 99198ae..409a3d3 100644 --- a/src/Bulma.purs +++ b/src/Bulma.purs @@ -285,7 +285,7 @@ box_input_password action password validity = HH.label [ ] -- _ -> HE.onClick \_ -> action2 -btn :: forall w i. i -> i -> Boolean -> HH.HTML w i +btn :: forall w i. String -> i -> i -> Boolean -> HH.HTML w i btn title action1 action2 validity = HH.button [ btn_add_action validity @@ -296,6 +296,27 @@ btn title action1 action2 validity true -> HE.onClick \_ -> action1 _ -> HE.onClick \_ -> action2 +render_input password placeholder action value validity cond + = HH.input $ + [ HE.onValueInput action + , HP.value value + , HP.placeholder placeholder + , input_classes validity + , cond + ] <> case password of + false -> [] + true -> [ HP.type_ HP.InputPassword ] + +box_inner ispassword title placeholder action value validity cond + = HH.label [ ] + [ HH.label [HP.classes class_label ] [ HH.text title ] + , HH.div [HP.classes class_control ] + [ render_input ispassword placeholder action value validity cond ] + ] + +box_input = box_inner false +box_password = box_inner true + p :: forall w i. String -> HH.HTML w i p str = HH.p_ [ HH.text str ]