2 unstable releases

✓ Uses Rust 2018 edition

0.1.0 Jan 27, 2019
0.0.1 Nov 27, 2018

#85 in WebAssembly

Download history 8/week @ 2018-11-20 18/week @ 2018-11-27 11/week @ 2018-12-04 1/week @ 2018-12-11 32/week @ 2018-12-18 2/week @ 2018-12-25 6/week @ 2019-01-01 5/week @ 2019-01-08 7/week @ 2019-01-15

25 downloads per month
Used in 1 crate

MIT/Apache

16KB
246 lines

Percy Build Status

A modular toolkit for building isomorphic web apps with Rust + WebAssembly

The Percy Book

The Percy book

Live Demo

View the isomorphic web app example live with a query string! 😉


What is an isomorphic web app?

An isomorphic web application allows the same application code (in our case Rust code) to be run on both the server-side and the client-side (usually a web browser).

In a browser our application renders to an HtmlElement, and on the server our application renders to a String.

API Documentation

Getting Started

For an example of an isomorphic web app in Rust check out the isomorphic example or view the isomorphic web app example live.

For more on the html! macro see html macro

#![feature(proc_macro_hygiene)]

#[macro_use]
extern crate virtual_dom_rs;

extern crate css_rs_macro;
use css_rs_macro::css;

static SOME_COMPONENT_CSS: &'static str = css! {"
:host {
    font-size: 30px;
    font-weight: bold;
}

:host > span {
    color: blue;
}
"};

fn main () {
  let count = Rc::new(Cell::new(0));

  let count_clone = Rc::clone(count);

  let html = html! {
    <div id="hello-world", class=*SOME_COMPONENT_CSS,>
      <span>{ "Hey :)" }</span>
      <button
        !onclick=|_event| { count_clone.set(count_clone.get() + 1); },
        // CSS in Rust isn't required. You can use regular old
        /* classes just fine! */
        class="btn-bs4 btn-bs4-success",
      >
        { "Click Me!" }
      </button>
    </div>
  };

  println!("{}", html.to_string());
}

Examples

Contributing

Please open issues / PRs explaining your intended use case and let's see if we should or shouldn't make percy support it!

Also feel free to open issues and PRs with any questions / thoughts that you have!

To Test

To run all of the unit, integration and browser tests, grab the dependencies then :

./test.sh

See Also

License

MIT

Dependencies

~2MB
~33K SLoC

  • js-sys 0.3
  • lazy_static 1.0
  • wasm-bindgen 0.2.33+default+nightly
  • web-sys 0.3+Comment+Document+Element+HtmlElement+EventTarget+HtmlCollection+Node+NodeList+Text+Window+Event+MouseEvent+InputEvent