savory 0.6.0

Core library for building user interface
//! Functions used to create HTML nodes

use seed::prelude::{El, Node, Tag, UpdateEl};
use std::borrow::Cow;

// TODO: support arguments in some functions, e.g. h1("title"),
// div(vec![child, child]), p("text")
macro_rules! create_html_elements {
    ( $( $fn_name:ident => $tag:stmt $(,)? )* ) => {
        $(
            pub fn $fn_name<Msg>() -> Node<Msg> {
                $tag
            }
        )*
    };
}

pub fn use_<Msg>() -> Node<Msg> {
    div!()
}

pub fn raw<Msg>(html: &str) -> Vec<Node<Msg>> {
    raw![html]
}

pub fn custom<Msg>(val: impl Into<Cow<'static, str>>) -> Node<Msg> {
    custom! {
        Tag::Custom(val.into())
    }
}

pub fn text<Msg>(val: impl Into<Cow<'static, str>>) -> Node<Msg> {
    Node::new_text(val)
}

create_html_elements! {
    address => address!(),
    article => article!(),
    aside => aside!(),
    footer => footer!(),
    header => header!(),
    h1 => h1!(),
    h2 => h2!(),
    h3 => h3!(),
    h4 => h4!(),
    h5 => h5!(),
    h6 => h6!(),
    hgroup => hgroup!(),
    main => main!(),
    nav => nav!(),
    section => section!(),
    blockquote => blockquote!(),
    dd => dd!(),
    dir => dir!(),
    div => div!(),
    dl => dl!(),
    dt => dt!(),
    figcaption => figcaption!(),
    figure => figure!(),
    hr => hr!(),
    li => li!(),
    ol => ol!(),
    p => p!(),
    pre => pre!(),
    ul => ul!(),
    a => a!(),
    abbr => abbr!(),
    b => b!(),
    bdi => bdi!(),
    bdo => bdo!(),
    br => br!(),
    cite => cite!(),
    code => code!(),
    data => data!(),
    dfn => dfn!(),
    em => em!(),
    i => i!(),
    kbd => kbd!(),
    mark => mark!(),
    q => q!(),
    rb => rb!(),
    rp => rp!(),
    rt => rt!(),
    rtc => rtc!(),
    ruby => ruby!(),
    s => s!(),
    samp => samp!(),
    small => small!(),
    span => span!(),
    strong => strong!(),
    sub => sub!(),
    sup => sup!(),
    time => time!(),
    tt => tt!(),
    u => u!(),
    var => var!(),
    wbr => wbr!(),
    area => area!(),
    audio => audio!(),
    img => img!(),
    map => map!(),
    track => track!(),
    video => video!(),
    applet => applet!(),
    embed => embed!(),
    iframe => iframe!(),
    noembed => noembed!(),
    object => object!(),
    param => param!(),
    picture => picture!(),
    source => source!(),
    canvas => canvas!(),
    noscript => noscript!(),
    script => Script!(),
    del => del!(),
    ins => ins!(),
    caption => caption!(),
    col => col!(),
    colgroup => colgroup!(),
    table => table!(),
    tbody => tbody!(),
    td => td!(),
    tfoot => tfoot!(),
    th => th!(),
    thead => thead!(),
    tr => tr!(),
    button => button!(),
    datalist => datalist!(),
    fieldset => fieldset!(),
    form => form!(),
    input => input!(),
    label => label!(),
    legend => legend!(),
    meter => meter!(),
    optgroup => optgroup!(),
    option => option!(),
    output => output!(),
    progress => progress!(),
    select => select!(),
    textarea => textarea!(),
    details => details!(),
    dialog => dialog!(),
    menu => menu!(),
    menuitem => menuitem!(),
    summary => summary!(),
    content => content!(),
    element => element!(),
    shadow => shadow!(),
    slot => slot!(),
    template => template!(),
    animate => animate!(),
    animate_color => animateColor!(),
    animate_motion => animateMotion!(),
    animate_transform => animateTransform!(),
    discard => discard!(),
    mpath => mpath!(),
    set => set!(),
    circle => circle!(),
    // ellipse => ellipse!(),
    line => line_!(),
    polygon => polygon!(),
    polyline => polyline!(),
    rect => rect!(),
    mesh => mesh!(),
    path => path!(),
    defs => defs!(),
    g => g!(),
    marker => marker!(),
    mask => mask!(),
    // missingglyph => missingglyph!(),
    pattern => pattern!(),
    svg => svg!(),
    switch => switch!(),
    symbol => symbol!(),
    unknown => unknown!(),
    desc => desc!(),
    metadata => metadata!(),
    title => title!(),
    fe_blend => feBlend!(),
    fe_color_matrix => feColorMatrix!(),
    fe_component_transfer => feComponentTransfer!(),
    fe_composite => feComposite!(),
    fe_convolve_matrix => feConvolveMatrix!(),
    fe_diffuse_lighting => feDiffuseLighting!(),
    fe_displacement_map => feDisplacementMap!(),
    fe_drop_shadow => feDropShadow!(),
    fe_flood => feFlood!(),
    fe_func_a => feFuncA!(),
    fe_func_b => feFuncB!(),
    fe_func_g => feFuncG!(),
    fe_func_r => feFuncR!(),
    fe_gaussian_blur => feGaussianBlur!(),
    fe_image => feImage!(),
    fe_merge => feMerge!(),
    fe_merge_node => feMergeNode!(),
    fe_morphology => feMorphology!(),
    fe_offset => feOffset!(),
    fe_specular_lighting => feSpecularLighting!(),
    fe_tile => feTile!(),
    fe_turbulence => feTurbulence!(),
    // fe_distant_light => feDistantLight!(),
    // fe_point_light => fePointLight!(),
    // fe_spot_light => feSpotLight!(),
    font => font!(),
    // font_face => fontFace!(),
    // font_face_format => fontFaceFormat!(),
    // font_faceName => fontFaceName!(),
    // font_face_src => fontFaceSrc!(),
    // font_face_uri => fontFaceUri!(),
    hkern => hkern!(),
    vkern => vkern!(),
    linear_gradient => linearGradient!(),
    mesh_gradient => meshGradient!(),
    radial_gradient => radialGradient!(),
    stop => stop!(),
    image => image!(),
    hatch => hatch!(),
    solid_color => solidcolor!(),
    alt_glyph => altGlyph!(),
    alt_glyph_def => altGlyphDef!(),
    alt_glyph_item => altGlyphItem!(),
    glyph => glyph!(),
    glyph_ref => glyphRef!(),
    text_path => textPath!(),
    // text => text!(),
    t_ref => tref!(),
    t_span => tspan!(),
    clip_path => clipPath!(),
    // color_profile => colorprofile!(),
    cursor => cursor!(),
    filter => filter!(),
    foreign_object => foreignObject!(),
    hatch_path => hatchpath!(),
    mesh_patch => meshPatch!(),
    mesh_row => meshrow!(),
    // style => style!(),
    view => view!(),
    // placeholder => placeholder!(),
}