Skip to content
/ percy Public
forked from chinedufn/percy

Libraries for building interactive frontend browser apps with Rust + WebAssembly. Supports server side rendering.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

sshyran/percy

Repository files navigation

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)]

use virtual_dom_rs::prelude::*;
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 there!</span>
        <button
          onclick=|_event: web_sys::MouseEvent| { 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>
    };

    // Used for server side rendering
    println!("{}", html.to_string());

    // Check out the DomUpdater for client side rendering
}

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

Libraries for building interactive frontend browser apps with Rust + WebAssembly. Supports server side rendering.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 99.9%
  • Shell 0.1%