From ecbc5617a3820feae4651bcab5d520d26d904d8a Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Mon, 6 Jan 2025 01:05:57 +0100 Subject: [PATCH] Bulma module rewrite: WIP. --- src/App/Style.purs | 462 +++++++++++++++++++++++++++++++++++++++ src/Bulma.purs | 530 ++++----------------------------------------- 2 files changed, 502 insertions(+), 490 deletions(-) create mode 100644 src/App/Style.purs diff --git a/src/App/Style.purs b/src/App/Style.purs new file mode 100644 index 0000000..4882533 --- /dev/null +++ b/src/App/Style.purs @@ -0,0 +1,462 @@ +module App.Style where + +import Bulma +import CSSClasses as C + +import Data.Maybe (Maybe, fromMaybe) +import Data.Tuple (Tuple, fst, snd) +import Halogen.HTML as HH +import DOM.HTML.Indexed as DHI +import Halogen.HTML.Properties as HP +import Halogen.HTML.Events as HE + +btn_abbr_ :: forall w action. + Array HH.ClassName -- button classes + -> Array HH.ClassName -- inner div classes + -> String + -> String + -> action + -> HH.HTML w action +btn_abbr_ btnclasses divclasses explanation_ title action + = HH.button + [ HE.onClick \_ -> action + , HP.classes $ [C.button] <> btnclasses + ] [ HH.abbr [ HP.title explanation_ ] [ HH.div [ HP.classes divclasses ] [ HH.text title ] ] ] + +btn_abbr :: forall w action. String -> String -> action -> HH.HTML w action +btn_abbr explanation_ title action = btn_abbr_ [] [] explanation_ title action + +alert_btn_abbr :: forall w action. String -> String -> action -> HH.HTML w action +alert_btn_abbr explanation_ title action = btn_abbr_ [C.is_danger] [] explanation_ title action + +btn_modify :: forall w i. i -> HH.HTML w i +btn_modify action = btn_abbr_ [C.is_small, C.is_info] [C.is_size 4] "Edit" "⚒" action + +btn_save :: forall w i. i -> HH.HTML w i +btn_save action = btn_ [C.is_info] "Save" action + +btn_add :: forall w i. i -> HH.HTML w i +btn_add action = btn_ [C.is_info] "Add" action + +btn_delete :: forall w i. i -> HH.HTML w i +btn_delete action = btn_abbr_ [C.is_small, C.is_danger] [C.is_size 4] "Delete" "✖" action + +btn_ro :: forall w i. Array HH.ClassName -> String -> HH.HTML w i +btn_ro classes title + = HH.button + [ HP.classes $ [C.button] <> classes + ] [ HH.text title ] + +btn_modify_ro :: forall w i. HH.HTML w i +btn_modify_ro = btn_ro [C.is_small, C.is_warning] "modify" + +btn_readonly :: forall w i. HH.HTML w i +btn_readonly = btn_ro [C.is_small, C.is_warning] "read only" + +btn_delete_ro :: forall w i. HH.HTML w i +btn_delete_ro = btn_ro [C.is_small, C.is_warning] "remove" + +username_input :: forall w i. String -> String -> (String -> i) -> HH.HTML w i +username_input title value action + = div_field [] + [ div_field_label "username" title + , div_field_content $ HH.input + [ HE.onValueInput action + , HP.type_ HP.InputText + , HP.value value + , HP.name "username" + , HP.autocomplete AutocompleteUsername + , HP.placeholder "Username" + , HP.id "username" + , HP.classes input_classes + ] + ] + +email_input :: forall w i. String -> String -> (String -> i) -> HH.HTML w i +email_input title value action + = div_field [] + [ div_field_label "email" title + , div_field_content $ HH.input + [ HE.onValueInput action + , HP.type_ HP.InputEmail + , HP.value value + , HP.name "email" + , HP.autocomplete AutocompleteEmail + , HP.placeholder "email@example.com" + , HP.id "email" + , HP.classes input_classes + ] + ] + +password_input :: forall w i. String -> String -> (String -> i) -> HH.HTML w i +password_input title value action + = div_field [] + [ div_field_label "password" title + , div_field_content $ HH.input + [ HE.onValueInput action + , HP.type_ HP.InputPassword + , HP.value value + , HP.name "password" + , HP.autocomplete AutocompleteCurrentPassword + , HP.placeholder "" + , HP.id "password" + , HP.classes input_classes + ] + ] + +password_input_new :: forall w i. String -> String -> (String -> i) -> HH.HTML w i +password_input_new title value action + = div_field [] + [ div_field_label "password" title + , div_field_content $ HH.input + [ HE.onValueInput action + , HP.type_ HP.InputPassword + , HP.value value + , HP.name "password" + , HP.autocomplete AutocompleteNewPassword + , HP.placeholder "" + , HP.id "password" + , HP.classes input_classes + ] + ] + +password_input_confirmation :: forall w i. String -> String -> (String -> i) -> HH.HTML w i +password_input_confirmation title value action + = div_field [] + [ div_field_label "password_confirmation" title + , div_field_content $ HH.input + [ HE.onValueInput action + , HP.type_ HP.InputPassword + , HP.value value + , HP.name "password_confirmation" + , HP.autocomplete AutocompleteOff + , HP.placeholder "" + , HP.id "password_confirmation" + , HP.classes input_classes + ] + ] + +token_input :: forall w i. String -> String -> (String -> i) -> HH.HTML w i +token_input title value action + = div_field [] + [ div_field_label "token" title + , div_field_content $ HH.input + [ HE.onValueInput action + , HP.type_ HP.InputText + , HP.value value + , HP.name "token" + , HP.autocomplete AutocompleteOff + , HP.placeholder "" + , HP.id "token" + , HP.classes input_classes + ] + ] + +txt_name :: forall w i. String -> HH.HTML w i +txt_name t + = HH.td [ rr_name_style ] [ rr_name_text ] + where + rr_name_style = HP.style "width: 80px;" + rr_name_text = HH.text t + +table_header_owned_domains :: forall w i. HH.HTML w i +table_header_owned_domains + = HH.thead_ [ HH.tr_ [ HH.th_ [ HH.text "Name" ] + , HH.th_ [ HH.text "" ] + , HH.th_ [ HH.text "" ] + , HH.th_ [ HH.text "" ] + ] + ] + +table_header_shared_domains :: forall w i. HH.HTML w i +table_header_shared_domains + = HH.thead_ [ HH.tr_ [ HH.th_ [ HH.text "Name" ] + , HH.th_ [ HH.text "Share key" ] + , HH.th_ [ HH.text "" ] + , HH.th_ [ HH.text "" ] + ] + ] + +mechanism_table_header :: forall w i. HH.HTML w i +mechanism_table_header + = HH.thead_ [ HH.tr_ [ HH.th_ [ HH.text "Policy" ] + , HH.th_ [ HH.text "Type" ] + , HH.th_ [ HH.text "Value" ] + , HH.th_ [ HH.text "" ] + ] + ] + +modifier_table_header :: forall w i. HH.HTML w i +modifier_table_header + = HH.thead_ [ HH.tr_ [ HH.th_ [ HH.text "Type" ] + , HH.th_ [ HH.text "Value" ] + , HH.th_ [ HH.text "" ] + ] + ] + +dmarc_dmarcuri_table_header :: forall w i. HH.HTML w i +dmarc_dmarcuri_table_header + = HH.thead_ [ HH.tr_ [ HH.th_ [ HH.text "Email address" ] + , HH.th_ [ HH.text "Report size limit" ] + , HH.th_ [ HH.text "" ] + ] + ] + +name_header :: forall w i. HH.HTML w i +name_header = HH.abbr + [ HP.title "Name of the DNS entry, the fully-qualified-domain-name is .." ] + [ HH.text "Name" ] + +ttl_header :: forall w i. HH.HTML w i +ttl_header = HH.abbr + [ HP.title "Time-to-Live, nb seconds before being considered invalid" ] + [ HH.text "TTL" ] + +target_header :: forall w i. HH.HTML w i +target_header = HH.abbr + [ HP.title "In the DNS jargon, the target means the most important value associated with the entry, for an A entry it would be an IPv4 address, for example" ] + [ HH.text "Target" ] + +token_header :: forall w i. HH.HTML w i +token_header = HH.abbr + [ HP.title "Tokens are used to update the entry, see the tab: \"Tokens? 🤨\"" ] + [ HH.text "Token" ] + +priority_header :: forall w i. HH.HTML w i +priority_header = HH.abbr + [ HP.title "A numeric value that indicates the preference of the server (lower values indicate higher priority)" ] + [ HH.text "Priority" ] + +weight_header :: forall w i. HH.HTML w i +weight_header = HH.abbr + [ HP.title "A relative weight used when multiple servers have the same priority, determining how often they should be used" ] + [ HH.text "Weight" ] + +srv_mechanisms_header :: forall w i. HH.HTML w i +srv_mechanisms_header = HH.abbr + [ HP.title "Mechanisms specify which mail servers are allowed to send mail for the domain and how to evaluate the sending mail server’s IP address" ] + [ HH.text "Mechanisms" ] + +srv_modifiers_header :: forall w i. HH.HTML w i +srv_modifiers_header = HH.abbr + [ HP.title "Modifiers provide additional instructions, such as explanations for SPF failures or redirecting SPF checks to another domain" ] + [ HH.text "Modifiers" ] + +srv_default_policy_header :: forall w i. HH.HTML w i +srv_default_policy_header = HH.abbr + [ HP.title "" ] + [ HH.text "Default Policy" ] + +protocol_header :: forall w i. HH.HTML w i +protocol_header = HH.abbr + [ HP.title "The related communication protocol, either TCP or UDP (want more? Just ask me)" ] + [ HH.text "Protocol" ] + +port_header :: forall w i. HH.HTML w i +port_header = HH.abbr + [ HP.title "Related connection port" ] + [ HH.text "Port" ] + +dkim_notes_header :: forall w i. HH.HTML w i +dkim_notes_header = HH.abbr + [ HP.title "Arbitrary string related to this cryptographic material" ] + [ HH.text "Notes" ] + +dmarc_policy_header :: forall w i. HH.HTML w i +dmarc_policy_header = HH.abbr + [ HP.title "How to handle email when SPF and DKIM aren't valid?" ] + [ HH.text "Policy" ] + +dmarc_subdom_policy_header :: forall w i. HH.HTML w i +dmarc_subdom_policy_header = HH.abbr + [ HP.title "How to handle email when SPF and DKIM aren't valid?" ] + [ HH.text "Subdomain Policy" ] + +dmarc_dkim_policy_header :: forall w i. HH.HTML w i +dmarc_dkim_policy_header = HH.abbr + [ HP.title "What should be considered acceptable to do with an email not conforming with DKIM" ] + [ HH.text "DKIM Policy" ] + +dmarc_spf_policy_header :: forall w i. HH.HTML w i +dmarc_spf_policy_header = HH.abbr + [ HP.title "What should be considered acceptable to do with an email not conforming with SPF" ] + [ HH.text "SPF Policy" ] + +dmarc_sample_rate_header :: forall w i. HH.HTML w i +dmarc_sample_rate_header = HH.abbr + [ HP.title "Percentage of messages subjected to the requested policy [0-100]" ] + [ HH.text "Sample Rate" ] + +dmarc_report_on_header :: forall w i. HH.HTML w i +dmarc_report_on_header = HH.abbr + [ HP.title "What error should be reported? DKIM, SPF, Both, Any or None?" ] + [ HH.text "Report on" ] + +dmarc_report_interval_header :: forall w i. HH.HTML w i +dmarc_report_interval_header = HH.abbr + [ HP.title "Minimal duration between two DMARC reports (in seconds)" ] + [ HH.text "Report interval" ] + +simple_table_header :: forall w i. HH.HTML w i +simple_table_header + = HH.thead_ [ HH.tr_ [ HH.th_ [ HH.text "Type" ] + , HH.th_ [ name_header ] + , HH.th_ [ ttl_header ] + , HH.th_ [ target_header ] + , HH.th_ [ HH.text "" ] + , HH.th_ [ token_header ] + ] + ] + +simple_table_header_ro :: forall w i. HH.HTML w i +simple_table_header_ro + = HH.thead_ [ HH.tr [ HP.classes [C.has_background_warning_light] ] + [ HH.th [ HP.style "width: 50px;" ] [ HH.text "Type" ] + , HH.th_ [ name_header ] + , HH.th_ [ ttl_header ] + , HH.th_ [ target_header ] + , HH.th_ [ HH.text "" ] + ] + ] + +mx_table_header :: forall w i. HH.HTML w i +mx_table_header + = HH.thead_ [ HH.tr_ [ HH.th_ [ name_header ] + , HH.th_ [ ttl_header ] + , HH.th_ [ priority_header ] + , HH.th_ [ target_header ] + , HH.th_ [ HH.text "" ] + ] + ] + +caa_table_header :: forall w i. HH.HTML w i +caa_table_header + = HH.thead_ [ HH.tr_ [ HH.th_ [ name_header ] + , HH.th_ [ ttl_header ] + , HH.th_ [ HH.text "Flag" ] + , HH.th_ [ HH.text "Tag" ] + , HH.th_ [ HH.text "Value" ] + , HH.th_ [ HH.text "" ] + ] + ] + +srv_table_header :: forall w i. HH.HTML w i +srv_table_header + = HH.thead_ [ HH.tr_ [ HH.th_ [ name_header ] + , HH.th_ [ protocol_header ] + , HH.th_ [ target_header ] + , HH.th_ [ port_header ] + , HH.th_ [ ttl_header ] + , HH.th_ [ priority_header ] + , HH.th_ [ weight_header ] + , HH.th_ [ HH.text "" ] + ] + ] + +spf_table_header :: forall w i. HH.HTML w i +spf_table_header + = HH.thead_ [ HH.tr_ [ HH.th_ [ name_header ] + , HH.th_ [ ttl_header ] + -- , HH.th_ [ HH.text "Version" ] -- For now, version isn't displayed. + , HH.th_ [ srv_mechanisms_header ] + , HH.th_ [ srv_modifiers_header ] + , HH.th_ [ srv_default_policy_header ] + , HH.th_ [ HH.text "" ] + ] + ] + +dkim_table_header :: forall w i. HH.HTML w i +dkim_table_header + = HH.thead_ [ HH.tr_ [ HH.th_ [ name_header ] + , HH.th_ [ ttl_header ] + -- , HH.th_ [ HH.text "Version" ] -- For now, version isn't displayed. Assume DKIM1. + , HH.th_ [ HH.text "Hash algo" ] + , HH.th_ [ HH.text "Signature algo" ] + , HH.th_ [ HH.text "Public Key" ] + , HH.th_ [ dkim_notes_header ] + , HH.th_ [ HH.text "" ] + ] + ] + +dmarc_table_header :: forall w i. HH.HTML w i +dmarc_table_header + = HH.thead_ [ HH.tr_ [ HH.th_ [ name_header ] + , HH.th_ [ ttl_header ] + -- , HH.th_ [ HH.text "Version" ] -- For now, version isn't displayed. Assume DMARC1. + , HH.th_ [ dmarc_policy_header ] -- p + , HH.th_ [ dmarc_subdom_policy_header ] -- sp + , HH.th_ [ dmarc_dkim_policy_header ] -- adkim + , HH.th_ [ dmarc_spf_policy_header ] -- aspf + , HH.th_ [ dmarc_sample_rate_header ] -- pct + , HH.th_ [ dmarc_report_on_header ] -- fo + , HH.th_ [ dmarc_report_interval_header ] -- ri + -- TODO? rua & ruf + -- , HH.th_ [ HH.text "Accepted report formats" ] -- For now, assume AFRF. + , HH.th_ [ HH.text "" ] + ] + ] + +name_soa_header :: forall w i. HH.HTML w i +name_soa_header = HH.abbr + [ HP.title "Your actual domain name (technical term: \"fully qualified domain name\")." ] + [ HH.text "Name" ] + +mname_soa_header :: forall w i. HH.HTML w i +mname_soa_header = HH.abbr + [ HP.title "Domain name of the primary authoritative DNS server for the zone (SOA \"MNAME\" field)." ] + [ HH.text "Primary NS" ] + +rname_soa_header :: forall w i. HH.HTML w i +rname_soa_header = HH.abbr + [ HP.title "The email address of the person responsible for managing the zone (the \"@\" is replaced by \".\" for some reason). This is the SOA \"RNAME\" field." ] + [ HH.text "Contact" ] + +serial_soa_header :: forall w i. HH.HTML w i +serial_soa_header = HH.abbr + [ HP.title "A number that is incremented every time the zone is updated. Secondary DNS servers use this number to check for updates." ] + [ HH.text "Serial" ] + +refresh_soa_header :: forall w i. HH.HTML w i +refresh_soa_header = HH.abbr + [ HP.title "The interval (in seconds) at which secondary DNS servers should check the primary server for changes to the zone." ] + [ HH.text "Refresh" ] + +retry_soa_header :: forall w i. HH.HTML w i +retry_soa_header = HH.abbr + [ HP.title "The time in seconds that secondary servers should wait before retrying a failed attempt to contact the primary DNS server." ] + [ HH.text "Retry" ] + +expire_soa_header :: forall w i. HH.HTML w i +expire_soa_header = HH.abbr + [ HP.title "The time in seconds that secondary DNS servers will keep the zone data before discarding it if they cannot contact the primary server." ] + [ HH.text "Expire" ] + +minttl_soa_header :: forall w i. HH.HTML w i +minttl_soa_header = HH.abbr + [ HP.title "The minimum time (in seconds) that other DNS servers should cache negative responses (e.g., for non-existent domain names)." ] + [ HH.text "Minimum TTL" ] + +soa_table_header :: forall w i. HH.HTML w i +soa_table_header + = HH.thead_ [ HH.tr [ HP.classes [C.has_background_warning_light] ] + [ HH.th_ [ name_soa_header ] + , HH.th_ [ ttl_header ] + , HH.th_ [ mname_soa_header ] + , HH.th_ [ rname_soa_header ] + , HH.th_ [ serial_soa_header ] + , HH.th_ [ refresh_soa_header ] + , HH.th_ [ retry_soa_header ] + , HH.th_ [ expire_soa_header ] + , HH.th_ [ minttl_soa_header ] + ] + +btn_validation_ :: forall w i. String -> HH.HTML w i +btn_validation_ str = HH.button + -- [ HP.style "padding: 0.5rem 1.25rem;" + [ HP.type_ HP.ButtonSubmit + , HP.classes [C.button, C.is_primary] + ] + [ HH.text str ] + +btn_validation :: forall w i. HH.HTML w i +btn_validation = btn_validation_ "Validate" diff --git a/src/Bulma.purs b/src/Bulma.purs index ca196b1..0620fc6 100644 --- a/src/Bulma.purs +++ b/src/Bulma.purs @@ -46,14 +46,14 @@ h1 :: forall (w :: Type) (a :: Type). String -> HH.HTML w a h1 title = HH.h1 [ HP.classes [C.title] ] [ HH.text title ] h3 :: forall (w :: Type) (a :: Type). String -> HH.HTML w a -h3 title = HH.h3 [ HP.classes [C.title, C.is5] ] [ HH.text title ] +h3 title = HH.h3 [ HP.classes [C.title] ] [ HH.text title ] h4 :: forall (w :: Type) (a :: Type). String -> HH.HTML w a -h4 title = HH.h4 [ HP.classes [C.title, C.is5] ] [ HH.text title ] +h4 title = HH.h4 [ HP.classes [C.title] ] [ HH.text title ] zone_rr_title :: forall (w :: Type) (a :: Type). String -> HH.HTML w a zone_rr_title title - = HH.h3 [ HP.classes [C.title, C.is5, C.has_text_light, C.has_background_dark] ] + = HH.h3 [ HP.classes [C.title, C.has_text_light, C.has_background_dark] ] [ HH.text title ] subtitle :: forall (w :: Type) (a :: Type). String -> HH.HTML w a @@ -77,305 +77,6 @@ table prop xs = HH.table ([ HP.classes [C.table] ] <> prop) xs table_ :: forall w i. Array HH.ClassName -> HH.Node DHI.HTMLtable w i table_ classes prop xs = HH.table ([ HP.classes $ [C.table] <> classes] <> prop) xs -table_header_owned_domains :: forall w i. HH.HTML w i -table_header_owned_domains - = HH.thead_ [ HH.tr_ [ HH.th_ [ HH.text "Name" ] - , HH.th_ [ HH.text "" ] - , HH.th_ [ HH.text "" ] - , HH.th_ [ HH.text "" ] - ] - ] - -table_header_shared_domains :: forall w i. HH.HTML w i -table_header_shared_domains - = HH.thead_ [ HH.tr_ [ HH.th_ [ HH.text "Name" ] - , HH.th_ [ HH.text "Share key" ] - , HH.th_ [ HH.text "" ] - , HH.th_ [ HH.text "" ] - ] - ] - -mechanism_table_header :: forall w i. HH.HTML w i -mechanism_table_header - = HH.thead_ [ HH.tr_ [ HH.th_ [ HH.text "Policy" ] - , HH.th_ [ HH.text "Type" ] - , HH.th_ [ HH.text "Value" ] - , HH.th_ [ HH.text "" ] - ] - ] - -modifier_table_header :: forall w i. HH.HTML w i -modifier_table_header - = HH.thead_ [ HH.tr_ [ HH.th_ [ HH.text "Type" ] - , HH.th_ [ HH.text "Value" ] - , HH.th_ [ HH.text "" ] - ] - ] - -dmarc_dmarcuri_table_header :: forall w i. HH.HTML w i -dmarc_dmarcuri_table_header - = HH.thead_ [ HH.tr_ [ HH.th_ [ HH.text "Email address" ] - , HH.th_ [ HH.text "Report size limit" ] - , HH.th_ [ HH.text "" ] - ] - ] - -name_header :: forall w i. HH.HTML w i -name_header = HH.abbr - [ HP.title "Name of the DNS entry, the fully-qualified-domain-name is .." ] - [ HH.text "Name" ] - -ttl_header :: forall w i. HH.HTML w i -ttl_header = HH.abbr - [ HP.title "Time-to-Live, nb seconds before being considered invalid" ] - [ HH.text "TTL" ] - -target_header :: forall w i. HH.HTML w i -target_header = HH.abbr - [ HP.title "In the DNS jargon, the target means the most important value associated with the entry, for an A entry it would be an IPv4 address, for example" ] - [ HH.text "Target" ] - -token_header :: forall w i. HH.HTML w i -token_header = HH.abbr - [ HP.title "Tokens are used to update the entry, see the tab: \"Tokens? 🤨\"" ] - [ HH.text "Token" ] - -priority_header :: forall w i. HH.HTML w i -priority_header = HH.abbr - [ HP.title "A numeric value that indicates the preference of the server (lower values indicate higher priority)" ] - [ HH.text "Priority" ] - -weight_header :: forall w i. HH.HTML w i -weight_header = HH.abbr - [ HP.title "A relative weight used when multiple servers have the same priority, determining how often they should be used" ] - [ HH.text "Weight" ] - -srv_mechanisms_header :: forall w i. HH.HTML w i -srv_mechanisms_header = HH.abbr - [ HP.title "Mechanisms specify which mail servers are allowed to send mail for the domain and how to evaluate the sending mail server’s IP address" ] - [ HH.text "Mechanisms" ] - -srv_modifiers_header :: forall w i. HH.HTML w i -srv_modifiers_header = HH.abbr - [ HP.title "Modifiers provide additional instructions, such as explanations for SPF failures or redirecting SPF checks to another domain" ] - [ HH.text "Modifiers" ] - -srv_default_policy_header :: forall w i. HH.HTML w i -srv_default_policy_header = HH.abbr - [ HP.title "" ] - [ HH.text "Default Policy" ] - -protocol_header :: forall w i. HH.HTML w i -protocol_header = HH.abbr - [ HP.title "The related communication protocol, either TCP or UDP (want more? Just ask me)" ] - [ HH.text "Protocol" ] - -port_header :: forall w i. HH.HTML w i -port_header = HH.abbr - [ HP.title "Related connection port" ] - [ HH.text "Port" ] - -dkim_notes_header :: forall w i. HH.HTML w i -dkim_notes_header = HH.abbr - [ HP.title "Arbitrary string related to this cryptographic material" ] - [ HH.text "Notes" ] - -dmarc_policy_header :: forall w i. HH.HTML w i -dmarc_policy_header = HH.abbr - [ HP.title "How to handle email when SPF and DKIM aren't valid?" ] - [ HH.text "Policy" ] - -dmarc_subdom_policy_header :: forall w i. HH.HTML w i -dmarc_subdom_policy_header = HH.abbr - [ HP.title "How to handle email when SPF and DKIM aren't valid?" ] - [ HH.text "Subdomain Policy" ] - -dmarc_dkim_policy_header :: forall w i. HH.HTML w i -dmarc_dkim_policy_header = HH.abbr - [ HP.title "What should be considered acceptable to do with an email not conforming with DKIM" ] - [ HH.text "DKIM Policy" ] - -dmarc_spf_policy_header :: forall w i. HH.HTML w i -dmarc_spf_policy_header = HH.abbr - [ HP.title "What should be considered acceptable to do with an email not conforming with SPF" ] - [ HH.text "SPF Policy" ] - -dmarc_sample_rate_header :: forall w i. HH.HTML w i -dmarc_sample_rate_header = HH.abbr - [ HP.title "Percentage of messages subjected to the requested policy [0-100]" ] - [ HH.text "Sample Rate" ] - -dmarc_report_on_header :: forall w i. HH.HTML w i -dmarc_report_on_header = HH.abbr - [ HP.title "What error should be reported? DKIM, SPF, Both, Any or None?" ] - [ HH.text "Report on" ] - -dmarc_report_interval_header :: forall w i. HH.HTML w i -dmarc_report_interval_header = HH.abbr - [ HP.title "Minimal duration between two DMARC reports (in seconds)" ] - [ HH.text "Report interval" ] - -simple_table_header :: forall w i. HH.HTML w i -simple_table_header - = HH.thead_ [ HH.tr_ [ HH.th_ [ HH.text "Type" ] - , HH.th_ [ name_header ] - , HH.th_ [ ttl_header ] - , HH.th_ [ target_header ] - , HH.th_ [ HH.text "" ] - , HH.th_ [ token_header ] - ] - ] - -simple_table_header_ro :: forall w i. HH.HTML w i -simple_table_header_ro - = HH.thead_ [ HH.tr [ HP.classes [C.has_background_warning_light] ] - [ HH.th [ HP.style "width: 50px;" ] [ HH.text "Type" ] - , HH.th_ [ name_header ] - , HH.th_ [ ttl_header ] - , HH.th_ [ target_header ] - , HH.th_ [ HH.text "" ] - ] - ] - -mx_table_header :: forall w i. HH.HTML w i -mx_table_header - = HH.thead_ [ HH.tr_ [ HH.th_ [ name_header ] - , HH.th_ [ ttl_header ] - , HH.th_ [ priority_header ] - , HH.th_ [ target_header ] - , HH.th_ [ HH.text "" ] - ] - ] - -caa_table_header :: forall w i. HH.HTML w i -caa_table_header - = HH.thead_ [ HH.tr_ [ HH.th_ [ name_header ] - , HH.th_ [ ttl_header ] - , HH.th_ [ HH.text "Flag" ] - , HH.th_ [ HH.text "Tag" ] - , HH.th_ [ HH.text "Value" ] - , HH.th_ [ HH.text "" ] - ] - ] - -srv_table_header :: forall w i. HH.HTML w i -srv_table_header - = HH.thead_ [ HH.tr_ [ HH.th_ [ name_header ] - , HH.th_ [ protocol_header ] - , HH.th_ [ target_header ] - , HH.th_ [ port_header ] - , HH.th_ [ ttl_header ] - , HH.th_ [ priority_header ] - , HH.th_ [ weight_header ] - , HH.th_ [ HH.text "" ] - ] - ] - -spf_table_header :: forall w i. HH.HTML w i -spf_table_header - = HH.thead_ [ HH.tr_ [ HH.th_ [ name_header ] - , HH.th_ [ ttl_header ] - -- , HH.th_ [ HH.text "Version" ] -- For now, version isn't displayed. - , HH.th_ [ srv_mechanisms_header ] - , HH.th_ [ srv_modifiers_header ] - , HH.th_ [ srv_default_policy_header ] - , HH.th_ [ HH.text "" ] - ] - ] - -dkim_table_header :: forall w i. HH.HTML w i -dkim_table_header - = HH.thead_ [ HH.tr_ [ HH.th_ [ name_header ] - , HH.th_ [ ttl_header ] - -- , HH.th_ [ HH.text "Version" ] -- For now, version isn't displayed. Assume DKIM1. - , HH.th_ [ HH.text "Hash algo" ] - , HH.th_ [ HH.text "Signature algo" ] - , HH.th_ [ HH.text "Public Key" ] - , HH.th_ [ dkim_notes_header ] - , HH.th_ [ HH.text "" ] - ] - ] - -dmarc_table_header :: forall w i. HH.HTML w i -dmarc_table_header - = HH.thead_ [ HH.tr_ [ HH.th_ [ name_header ] - , HH.th_ [ ttl_header ] - -- , HH.th_ [ HH.text "Version" ] -- For now, version isn't displayed. Assume DMARC1. - , HH.th_ [ dmarc_policy_header ] -- p - , HH.th_ [ dmarc_subdom_policy_header ] -- sp - , HH.th_ [ dmarc_dkim_policy_header ] -- adkim - , HH.th_ [ dmarc_spf_policy_header ] -- aspf - , HH.th_ [ dmarc_sample_rate_header ] -- pct - , HH.th_ [ dmarc_report_on_header ] -- fo - , HH.th_ [ dmarc_report_interval_header ] -- ri - -- TODO? rua & ruf - -- , HH.th_ [ HH.text "Accepted report formats" ] -- For now, assume AFRF. - , HH.th_ [ HH.text "" ] - ] - ] - -name_soa_header :: forall w i. HH.HTML w i -name_soa_header = HH.abbr - [ HP.title "Your actual domain name (technical term: \"fully qualified domain name\")." ] - [ HH.text "Name" ] - -mname_soa_header :: forall w i. HH.HTML w i -mname_soa_header = HH.abbr - [ HP.title "Domain name of the primary authoritative DNS server for the zone (SOA \"MNAME\" field)." ] - [ HH.text "Primary NS" ] - -rname_soa_header :: forall w i. HH.HTML w i -rname_soa_header = HH.abbr - [ HP.title "The email address of the person responsible for managing the zone (the \"@\" is replaced by \".\" for some reason). This is the SOA \"RNAME\" field." ] - [ HH.text "Contact" ] - -serial_soa_header :: forall w i. HH.HTML w i -serial_soa_header = HH.abbr - [ HP.title "A number that is incremented every time the zone is updated. Secondary DNS servers use this number to check for updates." ] - [ HH.text "Serial" ] - -refresh_soa_header :: forall w i. HH.HTML w i -refresh_soa_header = HH.abbr - [ HP.title "The interval (in seconds) at which secondary DNS servers should check the primary server for changes to the zone." ] - [ HH.text "Refresh" ] - -retry_soa_header :: forall w i. HH.HTML w i -retry_soa_header = HH.abbr - [ HP.title "The time in seconds that secondary servers should wait before retrying a failed attempt to contact the primary DNS server." ] - [ HH.text "Retry" ] - -expire_soa_header :: forall w i. HH.HTML w i -expire_soa_header = HH.abbr - [ HP.title "The time in seconds that secondary DNS servers will keep the zone data before discarding it if they cannot contact the primary server." ] - [ HH.text "Expire" ] - -minttl_soa_header :: forall w i. HH.HTML w i -minttl_soa_header = HH.abbr - [ HP.title "The minimum time (in seconds) that other DNS servers should cache negative responses (e.g., for non-existent domain names)." ] - [ HH.text "Minimum TTL" ] - -soa_table_header :: forall w i. HH.HTML w i -soa_table_header - = HH.thead_ [ HH.tr [ HP.classes [C.has_background_warning_light] ] - [ HH.th_ [ name_soa_header ] - , HH.th_ [ ttl_header ] - , HH.th_ [ mname_soa_header ] - , HH.th_ [ rname_soa_header ] - , HH.th_ [ serial_soa_header ] - , HH.th_ [ refresh_soa_header ] - , HH.th_ [ retry_soa_header ] - , HH.th_ [ expire_soa_header ] - , HH.th_ [ minttl_soa_header ] - ] - ] - -txt_name :: forall w i. String -> HH.HTML w i -txt_name t - = HH.td [ rr_name_style ] [ rr_name_text ] - where - rr_name_style = HP.style "width: 80px;" - rr_name_text = HH.text t - textarea_ :: forall w i. Array HH.ClassName -> String -> String -> (String -> i) -> HH.HTML w i textarea_ classes placeholder value action = HH.textarea @@ -388,52 +89,6 @@ textarea_ classes placeholder value action textarea :: forall w i. String -> String -> (String -> i) -> HH.HTML w i textarea placeholder value action = textarea_ [] placeholder value action -btn_abbr_ :: forall w action. - Array HH.ClassName -- button classes - -> Array HH.ClassName -- inner div classes - -> String - -> String - -> action - -> HH.HTML w action -btn_abbr_ btnclasses divclasses explanation_ title action - = HH.button - [ HE.onClick \_ -> action - , HP.classes $ [C.button] <> btnclasses - ] [ HH.abbr [ HP.title explanation_ ] [ HH.div [ HP.classes divclasses ] [ HH.text title ] ] ] - -btn_abbr :: forall w action. String -> String -> action -> HH.HTML w action -btn_abbr explanation_ title action = btn_abbr_ [] [] explanation_ title action - -alert_btn_abbr :: forall w action. String -> String -> action -> HH.HTML w action -alert_btn_abbr explanation_ title action = btn_abbr_ [C.is_danger] [] explanation_ title action - -btn_modify :: forall w i. i -> HH.HTML w i -btn_modify action = btn_abbr_ [C.is_small, C.is_info] [C.is_size 4] "Edit" "⚒" action - -btn_save :: forall w i. i -> HH.HTML w i -btn_save action = btn_ [C.is_info] "Save" action - -btn_add :: forall w i. i -> HH.HTML w i -btn_add action = btn_ [C.is_info] "Add" action - -btn_delete :: forall w i. i -> HH.HTML w i -btn_delete action = btn_abbr_ [C.is_small, C.is_danger] [C.is_size 4] "Delete" "✖" action - -btn_modify_ro :: forall w i. HH.HTML w i -btn_modify_ro = btn_ro [C.is_small, C.is_warning] "modify" - -btn_readonly :: forall w i. HH.HTML w i -btn_readonly = btn_ro [C.is_small, C.is_warning] "read only" - -btn_delete_ro :: forall w i. HH.HTML w i -btn_delete_ro = btn_ro [C.is_small, C.is_warning] "remove" - -btn_ro :: forall w i. Array HH.ClassName -> String -> HH.HTML w i -btn_ro classes title - = HH.button - [ HP.classes $ [C.button] <> classes - ] [ HH.text title ] - -- | Create a `level`, different components that should appear on the same horizontal line. -- | First argument, elements that should appear on the left, second on the right. level :: forall w i. Array (HH.HTML w i) -> Array (HH.HTML w i) -> HH.HTML w i @@ -456,20 +111,6 @@ btn title action = btn_ [] title action alert_btn :: forall w action. String -> action -> HH.HTML w action alert_btn title action = btn_ [C.is_danger] title action -render_input :: forall w i. - Boolean -> String -> String -> (String -> i) -> String -> (HP.IProp DHI.HTMLinput i) -> HH.HTML w i -render_input password id placeholder action value cond - = HH.input $ - [ HE.onValueInput action - , HP.value value - , HP.placeholder placeholder - , HP.classes $ input_classes - , HP.id id - , cond - ] <> case password of - false -> [] - true -> [ HP.type_ HP.InputPassword ] - -- | Bulma's `field`, which contains an array of `Halogen.HTML` entries. -- | Two entries are expected: a field label (`div_field_label`) and a field content (`div_field_content`). div_field :: forall w i. Array HH.ClassName -> Array (HH.HTML w i) -> HH.HTML w i @@ -542,102 +183,6 @@ box_password_ = field_inner true box_input :: forall w i. String -> String -> String -> (String -> i) -> String -> HH.HTML w i box_input = box_input_ (HP.enabled true) -username_input :: forall w i. String -> String -> (String -> i) -> HH.HTML w i -username_input title value action - = div_field [] - [ div_field_label "username" title - , div_field_content $ HH.input - [ HE.onValueInput action - , HP.type_ HP.InputText - , HP.value value - , HP.name "username" - , HP.autocomplete AutocompleteUsername - , HP.placeholder "Username" - , HP.id "username" - , HP.classes input_classes - ] - ] - -email_input :: forall w i. String -> String -> (String -> i) -> HH.HTML w i -email_input title value action - = div_field [] - [ div_field_label "email" title - , div_field_content $ HH.input - [ HE.onValueInput action - , HP.type_ HP.InputEmail - , HP.value value - , HP.name "email" - , HP.autocomplete AutocompleteEmail - , HP.placeholder "email@example.com" - , HP.id "email" - , HP.classes input_classes - ] - ] - -password_input :: forall w i. String -> String -> (String -> i) -> HH.HTML w i -password_input title value action - = div_field [] - [ div_field_label "password" title - , div_field_content $ HH.input - [ HE.onValueInput action - , HP.type_ HP.InputPassword - , HP.value value - , HP.name "password" - , HP.autocomplete AutocompleteCurrentPassword - , HP.placeholder "" - , HP.id "password" - , HP.classes input_classes - ] - ] - -password_input_new :: forall w i. String -> String -> (String -> i) -> HH.HTML w i -password_input_new title value action - = div_field [] - [ div_field_label "password" title - , div_field_content $ HH.input - [ HE.onValueInput action - , HP.type_ HP.InputPassword - , HP.value value - , HP.name "password" - , HP.autocomplete AutocompleteNewPassword - , HP.placeholder "" - , HP.id "password" - , HP.classes input_classes - ] - ] - -password_input_confirmation :: forall w i. String -> String -> (String -> i) -> HH.HTML w i -password_input_confirmation title value action - = div_field [] - [ div_field_label "password_confirmation" title - , div_field_content $ HH.input - [ HE.onValueInput action - , HP.type_ HP.InputPassword - , HP.value value - , HP.name "password_confirmation" - , HP.autocomplete AutocompleteOff - , HP.placeholder "" - , HP.id "password_confirmation" - , HP.classes input_classes - ] - ] - -token_input :: forall w i. String -> String -> (String -> i) -> HH.HTML w i -token_input title value action - = div_field [] - [ div_field_label "token" title - , div_field_content $ HH.input - [ HE.onValueInput action - , HP.type_ HP.InputText - , HP.value value - , HP.name "token" - , HP.autocomplete AutocompleteOff - , HP.placeholder "" - , HP.id "token" - , HP.classes input_classes - ] - ] - box_password :: forall w i. String -> String -> String -> (String -> i) -> String -> HH.HTML w i box_password = box_password_ (HP.enabled true) @@ -666,27 +211,12 @@ new_domain_field inputaction text_ selectaction accepted_domains [ select selectaction $ map option accepted_domains ] ] -code :: forall w i. String -> HH.HTML w i -code str = HH.code_ [ HH.text str ] - -text :: forall w i. String -> HH.HTML w i -text = HH.text - -p :: forall w i. String -> HH.HTML w i -p str = HH.p_ [ HH.text str ] - -p_ :: forall w i. Array HH.ClassName -> String -> HH.HTML w i -p_ classes str = HH.p [HP.classes classes] [ HH.text str ] - box :: forall w i. Array (HH.HTML w i) -> HH.HTML w i box = HH.div [HP.classes [C.box]] box_ :: forall w i. Array HH.ClassName -> Array (HH.HTML w i) -> HH.HTML w i box_ classes = HH.div [HP.classes $ [C.box] <> classes] -option :: forall w i. String -> HH.HTML w i -option value = HH.option_ [HH.text value] - select :: forall w i. HH.Node DHI.HTMLselect w i select action options = HH.div [ HP.classes [C.select, C.is_primary] ] @@ -755,12 +285,6 @@ cancel_button action , HE.onClick \_ -> action ] [HH.text "Cancel"] -strong :: forall w i. String -> HH.HTML w i -strong str = HH.strong_ [ HH.text str ] - -hr :: forall w i. HH.HTML w i -hr = HH.hr_ - tile :: forall w i. Array HH.ClassName -> Array (HH.HTML w i) -> HH.HTML w i tile classes = HH.div [HP.classes ([C.tile] <> classes)] @@ -953,17 +477,6 @@ notification_danger' value = notification' [C.is_danger] value notification_danger_block' :: forall w i. Array (HH.HTML w i) -> HH.HTML w i notification_danger_block' content = notification_block' [C.is_danger] content -btn_validation_ :: forall w i. String -> HH.HTML w i -btn_validation_ str = HH.button - -- [ HP.style "padding: 0.5rem 1.25rem;" - [ HP.type_ HP.ButtonSubmit - , HP.classes [C.button, C.is_primary] - ] - [ HH.text str ] - -btn_validation :: forall w i. HH.HTML w i -btn_validation = btn_validation_ "Validate" - -- | Box with tags. -- |``` -- |box_with_tag [C.has_background_danger_light] some_tag [Bulma.p "Hello"] @@ -977,3 +490,40 @@ box_with_tag colors tag xs = box_ ([C.no_padding_left, C.no_padding_top] <> colors) [tag, HH.div [HP.classes [C.restore_padding_left, C.restore_padding_top]] xs] + +-- GENERIC HTML API + +render_input :: forall w i. + Boolean -> String -> String -> (String -> i) -> String -> (HP.IProp DHI.HTMLinput i) -> HH.HTML w i +render_input password id placeholder action value cond + = HH.input $ + [ HE.onValueInput action + , HP.value value + , HP.placeholder placeholder + , HP.classes $ input_classes + , HP.id id + , cond + ] <> case password of + false -> [] + true -> [ HP.type_ HP.InputPassword ] + +code :: forall w i. String -> HH.HTML w i +code str = HH.code_ [ HH.text str ] + +text :: forall w i. String -> HH.HTML w i +text = HH.text + +p :: forall w i. String -> HH.HTML w i +p str = HH.p_ [ HH.text str ] + +p_ :: forall w i. Array HH.ClassName -> String -> HH.HTML w i +p_ classes str = HH.p [HP.classes classes] [ HH.text str ] + +option :: forall w i. String -> HH.HTML w i +option value = HH.option_ [HH.text value] + +strong :: forall w i. String -> HH.HTML w i +strong str = HH.strong_ [ HH.text str ] + +hr :: forall w i. HH.HTML w i +hr = HH.hr_