better element structure
This commit is contained in:
+48
-6
@@ -9,9 +9,9 @@ macro_rules! __css {
|
||||
$crate::__css!($_style, $($($other)*)?);
|
||||
}};
|
||||
(
|
||||
$_style:expr, ($name:ident): $value:literal% $(, $($other:tt)*)?
|
||||
$_style:expr, $name:literal: $value:literal% $(, $($other:tt)*)?
|
||||
) => {{
|
||||
$_style.other.insert(stringify!($name).to_string(), Box::new(
|
||||
$_style.other.insert($name.to_string(), Box::new(
|
||||
Number::Pe($value)
|
||||
));
|
||||
$crate::__css!($_style, $($($other)*)?);
|
||||
@@ -42,9 +42,9 @@ macro_rules! __css {
|
||||
}};
|
||||
|
||||
(
|
||||
$_style:expr, ($name:ident): $value:expr $(, $($other:tt)*)?
|
||||
$_style:expr, $name:literal: $value:expr $(, $($other:tt)*)?
|
||||
) => {{
|
||||
$_style.other.insert(stringify!($name).to_string(), Box::new($value));
|
||||
$_style.other.insert($name.to_string(), Box::new($value));
|
||||
$crate::__css!($_style, $($($other)*)?);
|
||||
}};
|
||||
}
|
||||
@@ -176,6 +176,48 @@ macro_rules! _css {
|
||||
}
|
||||
$crate::_css!($hm, $($rest)*);
|
||||
}};
|
||||
|
||||
|
||||
(
|
||||
$hm:expr, $name:literal { $($inner:tt)* } $($rest:tt)*
|
||||
) => {{
|
||||
let name = $crate::ui::StyleName::Class(String::from($name));
|
||||
if let Some(_style) = $hm.get_mut(&name) {
|
||||
$crate::__css!(_style.0, $($inner)*);
|
||||
} else {
|
||||
let mut _style = $crate::ui::Style::default();
|
||||
|
||||
$crate::__css!(_style.0, $($inner)*);
|
||||
|
||||
$hm.insert(
|
||||
name,
|
||||
_style,
|
||||
);
|
||||
}
|
||||
$crate::_css!($hm, $($rest)*);
|
||||
}};
|
||||
(
|
||||
$hm:expr, $name:literal:$kind:ident { $($inner:tt)* } $($rest:tt)*
|
||||
) => {{
|
||||
let name = $crate::ui::StyleName::Class(String::from($name));
|
||||
if let Some(_style) = $hm.get_mut(&name) {
|
||||
let mut style_elem = $crate::ui::StyleElement::default();
|
||||
$crate::__css!(style_elem, $($inner)*);
|
||||
_style.1.insert(stringify!($kind).to_string(), style_elem);
|
||||
} else {
|
||||
let mut _style = $crate::ui::Style::default();
|
||||
|
||||
let mut style_elem = $crate::ui::StyleElement::default();
|
||||
$crate::__css!(style_elem, $($inner)*);
|
||||
_style.1.insert(stringify!($kind).to_string(), style_elem);
|
||||
|
||||
$hm.insert(
|
||||
name,
|
||||
_style,
|
||||
);
|
||||
}
|
||||
$crate::_css!($hm, $($rest)*);
|
||||
}};
|
||||
}
|
||||
|
||||
/// Creates a styling map `Css`
|
||||
@@ -224,10 +266,10 @@ macro_rules! style {
|
||||
$crate::style!{ _style; $($($rest)*)? }
|
||||
}};
|
||||
(
|
||||
$style:expr; ($key:ident): $value:expr $(, $($rest:tt)*)?
|
||||
$style:expr; $key:literal: $value:expr $(, $($rest:tt)*)?
|
||||
) => {{
|
||||
let mut style_elem = $crate::ui::StyleElement::default();
|
||||
$crate::__css!($style.0, ($key): $value);
|
||||
$crate::__css!($style.0, $key: $value);
|
||||
$crate::style!{ $style; $($($rest)*)? }
|
||||
}};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user