-module(glaze_oat@switch). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/glaze_oat/switch.gleam"). -export([switch/1, label/2]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. ?MODULEDOC( " Oat documentation: \n" "\n" " Switch helpers for binary on/off controls.\n" "\n" " ## Anatomy\n" "\n" " A switch UI is usually a checkbox input rendered with `role=\"switch\"` and a\n" " nearby label.\n" "\n" " ## Recipe\n" "\n" " ```gleam\n" " import glaze_oat/switch\n" " import lustre/attribute\n" " import lustre/element/html\n" "\n" " switch.label([], [\n" " switch.switch([attribute.checked(True)]),\n" " html.text(\"Enable notifications\"),\n" " ])\n" " ```\n" "\n" " ## References\n" "\n" " - MDN ARIA `switch` role:\n" " \n" ). -file("src/glaze_oat/switch.gleam", 32). -spec switch(list(lustre@vdom@vattr:attribute(QPM))) -> lustre@vdom@vnode:element(QPM). switch(Attrs) -> lustre@element@html:input( [lustre@attribute:type_(<<"checkbox"/utf8>>), lustre@attribute:role(<<"switch"/utf8>>) | Attrs] ). -file("src/glaze_oat/switch.gleam", 36). -spec label( list(lustre@vdom@vattr:attribute(QPQ)), list(lustre@vdom@vnode:element(QPQ)) ) -> lustre@vdom@vnode:element(QPQ). label(Attrs, Children) -> lustre@element@html:label(Attrs, Children).