Crate rcss_layers
source ·Expand description
Layered CSS representation
Uses information from ScopeChain
or one that user provide to build a layered representation of styles.
Example:
use crate::*;
let mut chain = LayeredCss::new();
chain.add_style_from_parts("root", 0, "root", "style1{color:red}");
chain.add_style_from_parts("root", 1, "layer2", "style2{color:blue}");
chain.add_style_from_parts("root", 2, "layer3", "style3{color:green}");
let representation = chain
.styles
.get("root")
.unwrap()
.render(false, "root")
.unwrap();
let mut expectation = String::from("@layer root,layer2,layer3;");
expectation.push_str("@layer root{style1{color:red}}");
expectation.push_str("@layer layer2{style2{color:blue}}");
expectation.push_str("@layer layer3{style3{color:green}}");
assert_eq!(representation, expectation);
Structs§
- Store chain of extensions.
Type Aliases§
- Order of layers is determined by how far a layer is from root.
- Identifier of scoped style. rcss uses
&'static str
as scope_id but we useCow<'static, str>
to support dynamic extension. - Style representation. rcss uses
&'static str
as style representation but we useCow<'static, str>
to support dynamic extension.