From d5b9215efd814af64f422bb7b4ea70d6a1fa5168 Mon Sep 17 00:00:00 2001 From: Ross Bratton Date: Thu, 7 Mar 2024 15:40:46 +0000 Subject: =?UTF-8?q?=F0=9F=94=80=20Add=20form-related=20attributes.=20(#50)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add form-related attributes see: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#attributes_for_form_submission * snake_case for form_* attributes --- src/lustre/attribute.gleam | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'src') diff --git a/src/lustre/attribute.gleam b/src/lustre/attribute.gleam index 3889aa7..b99e241 100644 --- a/src/lustre/attribute.gleam +++ b/src/lustre/attribute.gleam @@ -287,3 +287,50 @@ pub fn controls(visible: Bool) -> Attribute(msg) { pub fn loop(should_loop: Bool) -> Attribute(msg) { property("loop", should_loop) } + +// FORMS ----------------------------------------------------------------------- + +/// +pub fn action(url: String) -> Attribute(msg) { + attribute("action", url) +} + +/// +pub fn enctype(value: String) -> Attribute(msg) { + attribute("enctype", value) +} + +/// +pub fn method(method: String) -> Attribute(msg) { + attribute("method", method) +} + +/// +pub fn novalidate(value: Bool) -> Attribute(msg) { + property("novalidate", value) +} + +/// +pub fn form_action(action: String) -> Attribute(msg) { + attribute("formaction", action) +} + +/// +pub fn form_enctype(value: String) -> Attribute(msg) { + attribute("formenctype", value) +} + +/// +pub fn form_method(method: String) -> Attribute(msg) { + attribute("formmethod", method) +} + +/// +pub fn form_novalidate(value: Bool) -> Attribute(msg) { + property("formnovalidate", value) +} + +/// +pub fn form_target(target: String) -> Attribute(msg) { + attribute("formtarget", target) +} -- cgit v1.2.3