Implementation of JSS for Rust. Use css styles without css with identical properties. Part of Rise-UI project.
Add to your Cargo.toml.
[dependencies]
jss = { git = "https://github.com/rise-ui/jss-rs" }
extern crate jss;
Simple JSON element parsing example
extern crate failure;
extern crate jss;
use jss::traits::*;
use jss::types::*;
fn main() -> Result<(), failure::Error> {
let source = r#"
{
"borderTopRightRadius": 10,
"borderTopStyle": "solid",
"alignContent": "center",
"borderTopWidth": 10,
"filter": [
"blur(20)"
],
"transform": [
"translate(10px,10%)",
"rotate(40deg,15rad)"
]
}
"#;
let style = StyleBuilder::default().source(source).parse()?;
println!("{:#?}", style);
Ok(())
}
Or if you need YAML...
extern crate failure;
extern crate jss;
use jss::traits::*;
use jss::types::*;
fn main() -> Result<(), failure::Error> {
let source = r#"
---
borderTopRightRadius: 10
borderTopStyle: solid
alignContent: center
borderTopWidth: 10
filter:
- blur(20)
transform:
- translate(10px,10%)
- rotate(40deg,15rad)
"#;
let style = StyleBuilder::default().source(source).source_type(SourceFormat::Yaml).parse()?;
println!("{:#?}", style);
Ok(())
}
- Parsing
filters
,color
,unit
and other properties from CSS3 - Stylesheet with selectors by status aka "name:hover", "name:active" etc.
- Get formatted props for
yoga-rs
and collectappearance
styles - Convert to
webrender
types & layers as optional target (partially implemented) - Middlewares
- Parsing Middleware
- Runtime Middleware (WIP)
- Runtime calculator like as
calc()
function in css3 - Parsing
transform
property - Parsing
media-query
property