nicompte / percy

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

Home Page:https://chinedufn.github.io/percy/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

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

https://chinedufn.github.io/percy/

License:Apache License 2.0


Languages

Language:Rust 97.9%Language:Dockerfile 1.9%Language:Shell 0.2%