Skip to content

Commit

Permalink
Create web example
Browse files Browse the repository at this point in the history
  • Loading branch information
matthunz committed Jan 8, 2024
1 parent 6ac3f6f commit ac8d792
Show file tree
Hide file tree
Showing 11 changed files with 680 additions and 57 deletions.
134 changes: 99 additions & 35 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

[package]
name = "viewbuilder"
version = "0.9.4"
Expand All @@ -6,12 +7,18 @@ license = "MIT OR Apache-2.0"
description = "Cross-platform UI framework"
repository = "https://github.com/matthunz/viewbuilder"

[workspace]
members = [
".",
"web_examples/counter"
]

[features]
full = []

[dependencies]
concoct = { git = "https://github.com/concoct-rs/concoct" }
tokio = { version = "1.35.1", features = ["full"] }
tokio = { version = "1.35.1", features = ["full"], optional = true }
web-sys = { version = "0.3.66", features = ["Document", "HtmlElement", "Window"] }

[package.metadata.docs.rs]
features = ["full"]
Expand Down
13 changes: 10 additions & 3 deletions examples/app.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
use viewbuilder::{class, div, view::once, App, ControlFlow, Model, View, Web};
use viewbuilder::{
class, div,
view::{self, once},
App, ControlFlow, Model, View, Web,
};

struct AppModel;

Expand All @@ -9,10 +13,13 @@ impl Model<()> for AppModel {
}

fn app(_model: &AppModel) -> impl View<Web, ()> {
div(once(class("parent")), div(once(class("child")), ()))
div(
view::once(class("parent")),
div(view::once(class("child")), ()),
)
}

fn main() {
let mut app = App::new(AppModel, app, Web);
let mut app = App::new(AppModel, app, Web::default());
app.build();
}

0 comments on commit ac8d792

Please sign in to comment.