Skip to content

jesskfullwood/fig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fig

A Rust/WASM frontend framework inspired by The Elm Architecture.

Features:

  • Fast rendering
  • Typesafe event handlers
  • HTML-as-code
  • Push- and PopState support
  • fetch requests
  • Timers
  • WebSockets

Built on top of wasm_bindgen.

Minimal Example

use fig::*;
use wasm_bindgen::prelude::*;

struct Model {
    click_count: usize,
}

enum Msg {
    ButtonClicked,
}

impl fig::Model for Model {
    type Msg = Msg;

    fn update(&mut self, msg: Self::Msg) -> Cmd<Self::Msg> {
        match msg {
            Msg::ButtonClicked => {
                self.click_count += 1;
                Cmd::none()
            }
        }
    }

    fn view(&self) -> Html<Self> {
            style!("font-family" => "Arial", "text-align" => "center"),
            h1!("Hello from fig!"),
            button!("Click me!", on_click((), |()| Msg::ButtonClicked)),
            p!(format!("Click count: {}", self.click_count))
        ]
    }
}

#[wasm_bindgen]
pub fn render() {
    fig::run(Model { click_count: 0 }, "app").expect("Failed to start app")
}

Renders as:

hello fig

See the quickstart demo and the more fully-featured demo for more.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages