use alloc::{borrow::Cow, string::String};
use crate::{Attribute, Element, ElementInner};
pub fn none() -> Element {
Element(ElementInner::None)
}
pub fn div(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("div", attributes, children)
}
pub fn head(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("head", attributes, children)
}
pub fn meta(attributes: impl IntoIterator<Item = Attribute>) -> Element {
Element::new_void("meta", attributes)
}
pub fn meta_viewport() -> Element {
raw("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">")
}
pub fn link(attributes: impl IntoIterator<Item = Attribute>) -> Element {
Element::new_void("link", attributes)
}
pub fn script(attributes: impl IntoIterator<Item = Attribute>, content: &'static str) -> Element {
Element::new(
"script",
attributes,
[Element(ElementInner::Script(content.into()))],
)
}
pub fn script_empty(attributes: impl IntoIterator<Item = Attribute>) -> Element {
Element::new("script", attributes, [])
}
pub fn title(
attributes: impl IntoIterator<Item = Attribute>,
text: impl Into<Cow<'static, str>>,
) -> Element {
Element::new("title", attributes, [text.into().into()])
}
pub fn body(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("body", attributes, children)
}
pub fn h1(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("h1", attributes, children)
}
pub fn h2(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("h2", attributes, children)
}
pub fn h3(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("h3", attributes, children)
}
pub fn h4(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("h4", attributes, children)
}
pub fn h5(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("h5", attributes, children)
}
pub fn h6(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("h6", attributes, children)
}
pub fn p(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("p", attributes, children)
}
pub fn br(attributes: impl IntoIterator<Item = Attribute>) -> Element {
Element::new_void("br", attributes)
}
pub fn small(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("small", attributes, children)
}
pub fn span(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("span", attributes, children)
}
pub fn table(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("table", attributes, children)
}
pub fn tr(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("tr", attributes, children)
}
pub fn td(
attdibutes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("td", attdibutes, children)
}
pub fn th(
attdibutes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("th", attdibutes, children)
}
pub fn thead(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("thead", attributes, children)
}
pub fn tbody(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("tbody", attributes, children)
}
pub fn tfoot(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("tfoot", attributes, children)
}
pub fn section(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("section", attributes, children)
}
pub fn article(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("article", attributes, children)
}
pub fn header(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("header", attributes, children)
}
pub fn main(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("main", attributes, children)
}
pub fn footer(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("footer", attributes, children)
}
pub fn a(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("a", attributes, children)
}
pub fn img(attributes: impl IntoIterator<Item = Attribute>) -> Element {
Element::new_void("img", attributes)
}
pub fn ul(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("ul", attributes, children)
}
pub fn ol(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("ol", attributes, children)
}
pub fn li(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("li", attributes, children)
}
pub fn form(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("form", attributes, children)
}
pub fn fieldset(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("fieldset", attributes, children)
}
pub fn input(attributes: impl IntoIterator<Item = Attribute>) -> Element {
Element::new_void("input", attributes)
}
pub fn textarea(
attributes: impl IntoIterator<Item = Attribute>,
text: impl Into<Cow<'static, str>>,
) -> Element {
Element::new("textarea", attributes, [text.into().into()])
}
pub fn select(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("select", attributes, children)
}
pub fn option(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("option", attributes, children)
}
pub fn button(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("button", attributes, children)
}
pub fn label(
attributes: impl IntoIterator<Item = Attribute>,
children: impl IntoIterator<Item = Element>,
) -> Element {
Element::new("label", attributes, children)
}
pub fn text(value: impl Into<Cow<'static, str>>) -> Element {
ElementInner::Text(value.into()).into()
}
pub fn raw(html: &'static str) -> Element {
ElementInner::Raw(html.into()).into()
}
pub fn raw_unsafe(html: String) -> Element {
ElementInner::Raw(html.into()).into()
}
impl From<Cow<'static, str>> for Element {
fn from(value: Cow<'static, str>) -> Self {
text(value)
}
}
impl From<&'static str> for Element {
fn from(value: &'static str) -> Self {
text(value)
}
}
impl From<String> for Element {
fn from(value: String) -> Self {
text(value)
}
}