-module(sketch@lustre@element). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/sketch/lustre/element.gleam"). -export([element_/3, namespaced_/4, class_name/1, element/4, namespaced/5]). -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( " This module is a drop-in replacement for `lustre/element`. Just\n" " use the new functions, and everything will automagically be styled.\n" ). -file("src/sketch/lustre/element.gleam", 40). ?DOC(" [Lustre Documentation](https://hexdocs.pm/lustre/lustre/element.html#element)\n"). -spec element_( binary(), list(lustre@vdom@vattr:attribute(OPK)), list(lustre@vdom@vnode:element(OPK)) ) -> lustre@vdom@vnode:element(OPK). element_(Tag, Attributes, Children) -> lustre@element:element(Tag, Attributes, Children). -file("src/sketch/lustre/element.gleam", 62). ?DOC(" [Lustre Documentation](https://hexdocs.pm/lustre/lustre/element.html#namespaced)\n"). -spec namespaced_( binary(), binary(), list(lustre@vdom@vattr:attribute(OPW)), list(lustre@vdom@vnode:element(OPW)) ) -> lustre@vdom@vnode:element(OPW). namespaced_(Tag, Namespace, Attributes, Children) -> lustre@element:namespaced(Tag, Namespace, Attributes, Children). -file("src/sketch/lustre/element.gleam", 75). ?DOC( " Generate a class name from a `Class`, using the `StyleSheet` injected\n" " in the environment.\n" ). -spec class_name(sketch@internals@cache@cache:class()) -> binary(). class_name(Class) -> case sketch_global_ffi:get_stylesheet() of {error, _} -> erlang:error(#{gleam_error => panic, message => <<"Stylesheet is not initialized in your application. Please, initialize a stylesheet before rendering some nodes."/utf8>>, file => <>, module => <<"sketch/lustre/element"/utf8>>, function => <<"class_name"/utf8>>, line => 77}); {ok, Stylesheet} -> {Stylesheet@1, Class_name} = sketch:class_name(Class, Stylesheet), _ = sketch_global_ffi:set_stylesheet(Stylesheet@1), Class_name end. -file("src/sketch/lustre/element.gleam", 28). ?DOC(" [Lustre Documentation](https://hexdocs.pm/lustre/lustre/element.html#element)\n"). -spec element( binary(), sketch@internals@cache@cache:class(), list(lustre@vdom@vattr:attribute(OPE)), list(lustre@vdom@vnode:element(OPE)) ) -> lustre@vdom@vnode:element(OPE). element(Tag, Class, Attributes, Children) -> Class_name = class_name(Class), Attributes@1 = [lustre@attribute:class(Class_name) | Attributes], lustre@element:element(Tag, Attributes@1, Children). -file("src/sketch/lustre/element.gleam", 49). ?DOC(" [Lustre Documentation](https://hexdocs.pm/lustre/lustre/element.html#namespaced)\n"). -spec namespaced( binary(), binary(), sketch@internals@cache@cache:class(), list(lustre@vdom@vattr:attribute(OPQ)), list(lustre@vdom@vnode:element(OPQ)) ) -> lustre@vdom@vnode:element(OPQ). namespaced(Tag, Namespace, Class, Attributes, Children) -> Class_name = class_name(Class), Attributes@1 = [lustre@attribute:class(Class_name) | Attributes], lustre@element:namespaced(Tag, Namespace, Attributes@1, Children).