macro_rules! with_dollar_sign {
($($body:tt)*) => {
macro_rules! __with_dollar_sign { $($body)* }
__with_dollar_sign!($);
}
}
macro_rules! element {
($($Tag:ident => $Tag_camel:ident);+) => {
with_dollar_sign! {
($d:tt) => {
$(
#[macro_export]
macro_rules! $Tag {
( $d($d part:expr),* $d(,)* ) => {
{
let mut el = El::empty(seed::dom_types::Tag::$Tag_camel);
$d ( $d part.update(&mut el); )*
el
}
};
}
)+
}
}
}
}
macro_rules! element_svg {
($($Tag:ident => $Tag_camel:ident);+) => {
with_dollar_sign! {
($d:tt) => {
$(
#[macro_export]
macro_rules! $Tag {
( $d($d part:expr),* $d(,)* ) => {
{
let mut el = El::empty_svg(seed::dom_types::Tag::$Tag_camel);
$d ( $d part.update(&mut el); )*
el
}
};
}
)+
}
}
}
}
element! {
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
}
element_svg! {
line_ => Line;
rect => Rect; circle => Circle; ellipse => Elipse; polygon => Polygon; polyline => Polyline;
mesh => Mesh; path => Path; defs => Defs; marker => Marker; mask => Mask;
svg => Svg; g => G;
linear_gradient => LinearGradient; radial_gradient => RadialGradient; mesh_gradient => MeshGradient;
stop => Stop;
image => Image;
r#use => Use;
text => Text; tref => TRef; tspan => TSpan
}
#[macro_export]
macro_rules! custom {
( $($part:expr),* $(,)* ) => {
{
let mut el = El::empty(seed::dom_types::Tag::Custom("missingtagname".into()));
$ ( $part.update(&mut el); )*
el
}
};
}
#[macro_export]
macro_rules! attrs {
{ $($key:expr => $value:expr);* $(;)* } => {
{
let mut vals = std::collections::HashMap::new();
$(
vals.insert($key.into(), $value.to_string());
)*
seed::dom_types::Attrs::new(vals)
}
};
}
#[macro_export]
macro_rules! class {
{ $($class:expr),* $(,)* } => {
{
let mut result = seed::dom_types::Attrs::empty();
let mut classes = Vec::new();
$(
classes.push($class);
)*
result.add_multiple("class".into(), classes);
result
}
};
}
#[macro_export]
macro_rules! id {
{ $id:expr } => {
{
seed::dom_types::Attrs::from_id($id)
}
};
}
#[macro_export]
macro_rules! style {
{ $($key:expr => $value:expr);* $(;)* } => {
{
let mut vals = std::collections::HashMap::new();
$(
vals.insert(String::from($key), $value.to_string());
)*
seed::dom_types::Style::new(vals)
}
};
}
#[macro_export]
macro_rules! log {
{ $($expr:expr),* $(,)* } => {
{
let mut text = String::new();
$(
text += &$expr.to_string();
text += " ";
)*
web_sys::console::log_1(&text.into());
}
};
}
#[macro_export]
macro_rules! hashmap_string {
{ $($key:expr => $value:expr),* $(,)* } => {
{
let mut result = std::collections::HashMap::new();
$(
result.insert($key.to_string(), $value.to_string());
)*
result
}
};
}