Skip to content

Commit

Permalink
Fixed a bug in window events. Top-level children now mount direclty t…
Browse files Browse the repository at this point in the history
…o the mount point instead of an intermediate element
  • Loading branch information
David-OConnor committed Apr 8, 2019
1 parent 5476109 commit 61a64aa
Show file tree
Hide file tree
Showing 17 changed files with 96 additions and 327 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v0.3.1
- `Top level view functions now return `Vec<El<Ms>>` instead of `El<Ms>`, mounted directly to
the mount point. (Breaking)
- `push_route()` can now accept a `Vec<&str>`, depreciating `push_path()`.
- Fixed a bug where window events couldn't be enabled on initialization

## v0.3.0
- `update` function now takes a mutable ref of the model. (Breaking)
- `Update` (update's return type) is now a struct. (Breaking)
Expand Down
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "seed"
version = "0.3.0"
version = "0.3.1"
description = "A Rust framework for creating web apps, using WebAssembly"
authors = ["DavidOConnor <david.alan.oconnor@gmail.com>"]
license = "MIT"
Expand Down Expand Up @@ -79,7 +79,6 @@ members = [
"examples/todomvc",
"examples/window_events",
"examples/websocket",
"proc_macros",
]

exclude = [
Expand Down
46 changes: 24 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ fn success_level(clicks: i32) -> El<Msg> {
}

/// The top-level component we pass to the virtual dom.
fn view(model: &Model) -> El<Msg> {
fn view(model: &Model) -> Vec<El<Msg>> {
let plural = if model.count == 1 {""} else {"s"};

// Attrs, Style, Events, and children may be defined separately.
Expand All @@ -155,27 +155,29 @@ fn view(model: &Model) -> El<Msg> {
"text-align" => "center"
};

div![ outer_style,
h1![ "The Grand Total" ],
div![
style!{
// Example of conditional logic in a style.
"color" => if model.count > 4 {"purple"} else {"gray"};
// When passing numerical values to style!, "px" is implied.
"border" => "2px solid #004422"; "padding" => 20
},
// We can use normal Rust code and comments in the view.
h3![ format!("{} {}{} so far", model.count, model.what_we_count, plural) ],
button![ simple_ev(Ev::Click, Msg::Increment), "+" ],
button![ simple_ev(Ev::Click, Msg::Decrement), "-" ],

// Optionally-displaying an element
if model.count >= 10 { h2![ style!{"padding" => 50}, "Nice!" ] } else { seed::empty() }
],
success_level(model.count), // Incorporating a separate component

h3![ "What precisely is it we're counting?" ],
input![ attrs!{At::Value => model.what_we_count}, input_ev(Ev::Input, Msg::ChangeWWC) ]
vec![
div![ outer_style,
h1![ "The Grand Total" ],
div![
style!{
// Example of conditional logic in a style.
"color" => if model.count > 4 {"purple"} else {"gray"};
// When passing numerical values to style!, "px" is implied.
"border" => "2px solid #004422"; "padding" => 20
},
// We can use normal Rust code and comments in the view.
h3![ format!("{} {}{} so far", model.count, model.what_we_count, plural) ],
button![ simple_ev(Ev::Click, Msg::Increment), "+" ],
button![ simple_ev(Ev::Click, Msg::Decrement), "-" ],

// Optionally-displaying an element
if model.count >= 10 { h2![ style!{"padding" => 50}, "Nice!" ] } else { seed::empty() }
],
success_level(model.count), // Incorporating a separate component

h3![ "What precisely is it we're counting?" ],
input![ attrs!{At::Value => model.what_we_count}, input_ev(Ev::Input, Msg::ChangeWWC) ]
]
]
}

Expand Down
13 changes: 0 additions & 13 deletions examples/layered_structure/Cargo.toml

This file was deleted.

3 changes: 0 additions & 3 deletions examples/layered_structure/README.md

This file was deleted.

5 changes: 0 additions & 5 deletions examples/layered_structure/build.ps1

This file was deleted.

7 changes: 0 additions & 7 deletions examples/layered_structure/build.sh

This file was deleted.

36 changes: 0 additions & 36 deletions examples/layered_structure/index.html

This file was deleted.

Empty file.
32 changes: 0 additions & 32 deletions examples/layered_structure/serve.py

This file was deleted.

99 changes: 0 additions & 99 deletions examples/layered_structure/src/lib.rs

This file was deleted.

6 changes: 2 additions & 4 deletions examples/todomvc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,7 @@ fn view(model: &Model) -> Vec<El<Msg>> {
ul![class!["todo-list"], todo_els]
]
} else {
// seed::empty()
span![]
seed::empty()
};

vec![
Expand All @@ -335,8 +334,7 @@ fn view(model: &Model) -> Vec<El<Msg>> {
if model.active_count() > 0 || model.completed_count() > 0 {
footer(&model)
} else {
// seed::empty()
span![]
seed::empty()
},
]
}
Expand Down
10 changes: 0 additions & 10 deletions proc_macros/Cargo.toml

This file was deleted.

11 changes: 0 additions & 11 deletions proc_macros/src/lib.rs

This file was deleted.

4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ pub mod tests {
}
}

fn view(_model: &Model) -> El<Msg> {
div!["Hello world"]
fn view(_model: &Model) -> Vec<El<Msg>> {
vec![div!["Hello world"]]
}

fn window_events(_model: &Model) -> Vec<seed::dom_types::Listener<Msg>> {
Expand Down
Loading

0 comments on commit 61a64aa

Please # to comment.