Skip to content

Latest commit

 

History

History
95 lines (77 loc) · 2.01 KB

README.md

File metadata and controls

95 lines (77 loc) · 2.01 KB

JSS Rust

Build Status

Implementation of JSS for Rust. Use css styles without css with identical properties. Part of Rise-UI project.

Usage

Add to your Cargo.toml.

[dependencies]
jss = { git = "https://github.com/rise-ui/jss-rs" }
extern crate jss;

Examples

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(())
}

Roadmap

  • 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 collect appearance 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