macro_rules! named_style {
($css_name:expr, $css:expr $(, $arg:expr)*) => { ... };
}
Expand description
Create a Style
from css
with a css_name
, rendering it to the DOM as a <style>
in <head>
.
The css
is formatted, minfied, and small errors like invalid semi-colons can be
corrected, however invalid CSS itself is not handled by the parser.
Effects remain there order as defined, but their inner fields, as well as the Style’s fields will be ordered in a deterministic fashion to avoid duplication.
Note: Trailing semi-colons are required.
Returns error if missing access to: Head
, Crypto
(If generating a random ID),
Window
, Document
.
Example Usage:
let style: Style = named_style!(
".my_class",
"
font-size: {}px;
&:hover {
background-color: rgba(111, 111, 111, 0.1);
}
@media (max-width: 800px) {
font-size: {}px;
}
",
18, 12
)?;