From c2569bc959d13c0952dc5db3e09ef60eac7bc89e Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Tue, 4 Jul 2023 04:50:07 +0200 Subject: [PATCH] Small code reduction. --- src/App/AuthenticationForm.purs | 52 +++++++++++++++++---------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/src/App/AuthenticationForm.purs b/src/App/AuthenticationForm.purs index 6d76c75..5c59d68 100644 --- a/src/App/AuthenticationForm.purs +++ b/src/App/AuthenticationForm.purs @@ -112,18 +112,20 @@ render { wsUp, , render_register_form ] + should_be_disabled = (if wsUp then (HP.enabled true) else (HP.disabled true)) + render_auth_form = HH.form [ HE.onSubmit AuthenticationAttempt ] - [ Bulma.box_input "Login" "login" -- title, placeholder - (HandleAuthenticationInput <<< AUTH_INP_login) -- action - authenticationForm.login -- value - true -- validity (TODO) - (if wsUp then (HP.enabled true) else (HP.disabled true)) -- condition - , Bulma.box_password "Password" "password" -- title, placeholder - (HandleAuthenticationInput <<< AUTH_INP_pass) -- action - authenticationForm.pass -- value - true -- validity (TODO) - (if wsUp then (HP.enabled true) else (HP.disabled true)) -- condition + [ Bulma.box_input "Login" "login" -- title, placeholder + (HandleAuthenticationInput <<< AUTH_INP_login) -- action + authenticationForm.login -- value + true -- validity (TODO) + should_be_disabled -- condition + , Bulma.box_password "Password" "password" -- title, placeholder + (HandleAuthenticationInput <<< AUTH_INP_pass) -- action + authenticationForm.pass -- value + true -- validity (TODO) + should_be_disabled -- condition , HH.button [ HP.style "padding: 0.5rem 1.25rem;" , HP.type_ HP.ButtonSubmit @@ -134,21 +136,21 @@ render { wsUp, render_register_form = HH.form [ HE.onSubmit RegisterAttempt ] - [ Bulma.box_input "Login" "login" -- title, placeholder - (HandleRegisterInput <<< REG_INP_login) -- action - registrationForm.login -- value - true -- validity (TODO) - (if wsUp then (HP.enabled true) else (HP.disabled true)) -- condition - , Bulma.box_input "Email" "email@example.com" -- title, placeholder - (HandleRegisterInput <<< REG_INP_email) -- action - registrationForm.email -- value - true -- validity (TODO) - (if wsUp then (HP.enabled true) else (HP.disabled true)) -- condition - , Bulma.box_password "Password" "password" -- title, placeholder - (HandleRegisterInput <<< REG_INP_pass) -- action - registrationForm.pass -- value - true -- validity (TODO) - (if wsUp then (HP.enabled true) else (HP.disabled true)) -- condition + [ Bulma.box_input "Login" "login" -- title, placeholder + (HandleRegisterInput <<< REG_INP_login) -- action + registrationForm.login -- value + true -- validity (TODO) + should_be_disabled -- condition + , Bulma.box_input "Email" "email@example.com" -- title, placeholder + (HandleRegisterInput <<< REG_INP_email) -- action + registrationForm.email -- value + true -- validity (TODO) + should_be_disabled -- condition + , Bulma.box_password "Password" "password" -- title, placeholder + (HandleRegisterInput <<< REG_INP_pass) -- action + registrationForm.pass -- value + true -- validity (TODO) + should_be_disabled -- condition , HH.div_ [ HH.button [ HP.style "padding: 0.5rem 1.25rem;"