[−][src]Crate sauron
Sauron is an html web framework for building web-apps. It is heavily inspired by elm.
Sauron doesn't use macro to provide the view, instead it is using rust syntax to construct the html view.
Example
use sauron::html::attributes::*; use sauron::html::events::*; use sauron::html::*; use sauron::Component; use sauron::Node; use sauron::Program; use wasm_bindgen::prelude::*; #[derive(Debug, Clone)] pub enum Msg { Click, } pub struct App { click_count: u32, } impl App { pub fn new() -> Self { App { click_count: 0 } } } impl Component<Msg> for App { fn view(&self) -> Node<Msg> { div( [class("some-class"), id("some-id"), attr("data-id", 1)], [ input( [ class("client"), r#type("button"), value("Click me!"), onclick(|_| { sauron::log("Button is clicked"); Msg::Click }), ], [], ), text(format!("Clicked: {}", self.click_count)), ], ) } fn update(&mut self, msg: Msg) { sauron::log!("App is updating from msg: {:?}", msg); match msg { Msg::Click => self.click_count += 1, } } } #[wasm_bindgen(start)] pub fn main() { Program::new_append_to_mount(App::new(), &sauron::body()); }
Look at the examples code and the build script for the details.
This project is based on the existing projects:
Re-exports
pub use dom::DomUpdater; |
Modules
dom | |
html | |
svg | |
test_fixtures | This is useful only for testing This is a simple component which just barely comply to being a component use for doing component tests |
Macros
log |
Structs
Program | Holds the app and the dom updater This is passed into the event listener and the dispatch program will be called after the event is triggered. |
Text |
Enums
Event | A container for generic event and the common values needed for the user. This events are derived from their corresponding backend source ie: html events from mouse, keypresses and input changes. This events should also be recreatable from gtk-rs, libui-rs, orbtk, ncurses, etc. |
Traits
Component | The app should implement this trait for it to be handled by the Program |
Functions
body | |
diff | Given two Node's generate Patch's that would turn the old virtual node's real DOM node equivalent into the new Node's real DOM node equivalent. |
document | |
log | |
performance | |
request_animation_frame | |
window |
Type Definitions
Attribute | |
Element | |
Node | A simplified version of saurdon_vdom node, where we supplied the type for the tag which is a &'static str. The missing type is now only MSG which will be supplied by the users App code. |
Patch |