From 6abd592aa558665bbc9483839a72ecf90ff4f774 Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Thu, 15 Feb 2024 23:23:24 +0100 Subject: [PATCH] input_with_side_text --- src/App/ZoneInterface.purs | 26 +++++++++++++++----------- src/Bulma.purs | 22 ++++++++++++++++++++++ src/CSSClasses.purs | 2 ++ 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/App/ZoneInterface.purs b/src/App/ZoneInterface.purs index 81d1aaf..feac6ba 100644 --- a/src/App/ZoneInterface.purs +++ b/src/App/ZoneInterface.purs @@ -303,10 +303,14 @@ render state content_simple :: Array (HH.HTML w Action) content_simple = [ render_errors - , Bulma.box_input ("domain" <> state._currentRR.rrtype) "Name" "www" -- id, title, placeholder + --, Bulma.box_input ("domain" <> state._currentRR.rrtype) "Name" "www" -- id, title, placeholder + -- (updateForm Field_Domain) -- action + -- state._currentRR.name -- value + -- should_be_disabled -- condition + , Bulma.input_with_side_text ("domain" <> state._currentRR.rrtype) "Name" "www" -- id, title, placeholder (updateForm Field_Domain) -- action - state._currentRR.name -- value - should_be_disabled -- condition + state._currentRR.name -- value + ("." <> state._domain) -- sidetext , Bulma.box_input ("ttl" <> state._currentRR.rrtype) "TTL" "600" (updateForm Field_TTL) (show state._currentRR.ttl) @@ -319,10 +323,10 @@ render state content_mx :: Array (HH.HTML w Action) content_mx = [ render_errors - , Bulma.box_input ("domainMX") "Name" "mail" -- id, title, placeholder - (updateForm Field_Domain) -- action - state._currentRR.name -- value - should_be_disabled -- condition + , Bulma.input_with_side_text "domainMX" "Name" "www" -- id, title, placeholder + (updateForm Field_Domain) -- action + state._currentRR.name -- value + ("." <> state._domain) -- sidetext , Bulma.box_input ("ttlMX") "TTL" "600" (updateForm Field_TTL) (show state._currentRR.ttl) @@ -339,10 +343,10 @@ render state content_srv :: Array (HH.HTML w Action) content_srv = [ render_errors - , Bulma.box_input ("domainSRV") "Name" "_sip._tcp" -- id, title, placeholder - (updateForm Field_Domain) -- action - state._currentRR.name -- value - should_be_disabled -- condition + , Bulma.input_with_side_text "domainSRV" "Name" "www" -- id, title, placeholder + (updateForm Field_Domain) -- action + state._currentRR.name -- value + ("." <> state._domain) -- sidetext , Bulma.box_input ("ttlSRV") "TTL" "600" (updateForm Field_TTL) (show state._currentRR.ttl) diff --git a/src/Bulma.purs b/src/Bulma.purs index 602fb00..481c107 100644 --- a/src/Bulma.purs +++ b/src/Bulma.purs @@ -389,3 +389,25 @@ article head body = article_ [] head body error_message :: forall w i. HH.HTML w i -> HH.HTML w i -> HH.HTML w i error_message head body = article_ C.is_danger head body + +input_with_side_text :: forall w i. + String -> String -> String -> (String -> i) -> String -> String -> HH.HTML w i +input_with_side_text id title placeholder action value sidetext + = HH.div [HP.classes $ C.has_addons <> C.field <> C.is_horizontal] + [ HH.div [ HP.classes (C.field_label <> C.normal) ] + [HH.label [ HP.classes C.label, HP.for id ] [ HH.text title ]] + , HH.div [ HP.classes C.field_body ] + [ HH.p [HP.classes C.control] + [ HH.input $ + [ HE.onValueInput action + , HP.value value + , HP.placeholder placeholder + , HP.classes $ input_classes + , HP.id id + ] + ] + , HH.p [HP.classes C.control] + [ HH.a [HP.classes $ C.button <> C.is_small <> C.is_static] + [HH.text sidetext] ] + ] + ] diff --git a/src/CSSClasses.purs b/src/CSSClasses.purs index 5658870..22c9bcf 100644 --- a/src/CSSClasses.purs +++ b/src/CSSClasses.purs @@ -92,6 +92,8 @@ is_small :: Array HH.ClassName is_small = [HH.ClassName "is-small"] is_success :: Array HH.ClassName is_success = [HH.ClassName "is-success"] +is_static :: Array HH.ClassName +is_static = [HH.ClassName "is-static"] label :: Array HH.ClassName label = [HH.ClassName "label"] level :: Array HH.ClassName