diff --git a/CHANGELOG.md b/CHANGELOG.md index 1db16c57f..b49e8d043 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,20 @@ # Changelog +## v0.3.2 +- Top level view functions can now return `Vec>`, `El`, or something else implementing +the new ElContainer trait + ## v0.3.1 -- `Top level view functions now return `Vec>` instead of `El`, mounted directly to +- Top level view functions now return `Vec>` instead of `El`, mounted directly to the mount point. (Breaking) -- `push_route()` can now accept a `Vec<&str>`, depreciating `push_path()`. +- `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) - Async, etc events are now handled through messages, instead of passing `App` -through the view func. (breaking) +through the view func. (Breaking) - Fixed some bugs with empty elements - Internal code cleanup - Added commented-out release command to example build files @@ -44,9 +48,9 @@ them in a single span. ## v0.2.5 - Attributes and Events now can use `At` and `Ev` enums -- Routing overhauled; modelled after react-reason. Cleaner syntax, and more flexible. +- Routing overhauled; modelled after react-reason. Cleaner syntax, and more flexible - Input, Textarea, and Select elements are now "controlled" - they always -stay in sync with the model. +stay in sync with the model - index.html file updated in examples and quickstart to use relative paths, which fixes landing-page routing @@ -57,7 +61,7 @@ which fixes landing-page routing - Routing refactored; now works dynamically - Update function now returns an enum that returns Render or Skip, to allow conditional rendering (Breaking) -- Elements can now store more than 1 text node. +- Elements can now store more than 1 text node ## V0.2.3 - Fixed a bug where initially-empty text won't update diff --git a/Cargo.toml b/Cargo.toml index b913dc939..429440038 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "seed" -version = "0.3.1" +version = "0.3.2" description = "A Rust framework for creating web apps, using WebAssembly" authors = ["DavidOConnor "] license = "MIT" @@ -16,24 +16,23 @@ edition = "2018" crate-type = ["cdylib", "rlib"] [dev-dependencies] -wasm-bindgen-test = "^0.2.40" # NOTE: keep in sync with wasm-bindgen version +wasm-bindgen-test = "^0.2.42" # NOTE: keep in sync with wasm-bindgen version [dependencies] # NOTE: keep in sync with wasm-bindgen-test version -wasm-bindgen = {version = "^0.2.40", features = ["serde-serialize"]} +wasm-bindgen = {version = "^0.2.42", features = ["serde-serialize"]} js-sys = "0.3.6" console_error_panic_hook = "^0.1.5" serde = { version = "^1.0.85", features = ['derive'] } serde_json = "^1.0.36" futures = "^0.1.20" -wasm-bindgen-futures = "^0.3.6" -#either = "^1.5.1" +wasm-bindgen-futures = "^0.3.19" # Markdown conversion pulldown-cmark = "^0.2.0" [dependencies.web-sys] -version = "0.3.10" +version = "^0.3.19" features = [ "AbortController", "AbortSignal", diff --git a/README.md b/README.md index f7c7b709f..1704b3564 100644 --- a/README.md +++ b/README.md @@ -145,7 +145,7 @@ fn success_level(clicks: i32) -> El { } /// The top-level component we pass to the virtual dom. -fn view(model: &Model) -> Vec> { +fn view(model: &Model) -> El { let plural = if model.count == 1 {""} else {"s"}; // Attrs, Style, Events, and children may be defined separately. @@ -155,29 +155,27 @@ fn view(model: &Model) -> Vec> { "text-align" => "center" }; - 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) ] - ] + 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) ] ] } @@ -214,6 +212,9 @@ For development, you can view your app using a shimmed Python dev server, as des (Set up [this mime-type shim](https://github.com/David-OConnor/seed-quickstart/blob/master/serve.py) from the quickstart repo, and run `python serve.py`). +For a more robust quickstart repo, check out Martin Kavik's [seed-quickstart-webpack repo] +(https://github.com/MartinKavik/seed-quickstart-webpack). + In the future, the build script and commands above may be replaced by [wasm-pack](https://github.com/rustwasm/wasm-pack). You may use it now if you wish, but may run into issues running the examples, enabling no-modules mode, and syntax-highlighting in the compile logs. diff --git a/examples/counter/Cargo.toml b/examples/counter/Cargo.toml index b13ed11e3..c465946cc 100644 --- a/examples/counter/Cargo.toml +++ b/examples/counter/Cargo.toml @@ -9,5 +9,5 @@ crate-type = ["cdylib"] [dependencies] seed = {path = "../../"} -wasm-bindgen = "^0.2.40" -web-sys = "^0.3.17" +wasm-bindgen = "0.2.42" +web-sys = "^0.3.19" diff --git a/examples/counter/src/lib.rs b/examples/counter/src/lib.rs index 348aae6da..14a55b123 100644 --- a/examples/counter/src/lib.rs +++ b/examples/counter/src/lib.rs @@ -55,7 +55,7 @@ fn success_level(clicks: i32) -> El { /// The top-level component we pass to the virtual dom. Must accept the model as its /// only argument, and output has to implement trait ElContainer. -fn view(model: &Model) -> impl ElContainer { +fn view(model: &Model) -> El { let plural = if model.count == 1 { "" } else { "s" }; let text = format!("{} {}{} so far", model.count, model.what_we_count, plural); diff --git a/examples/window_events/Cargo.toml b/examples/window_events/Cargo.toml index 1e0976c70..a46cf1937 100644 --- a/examples/window_events/Cargo.toml +++ b/examples/window_events/Cargo.toml @@ -10,5 +10,5 @@ crate-type = ["cdylib"] [dependencies] seed = {path = "../../"} -wasm-bindgen = "^0.2.37" +wasm-bindgen = "^0.2.40" web-sys = "^0.3.6" diff --git a/src/lib.rs b/src/lib.rs index e14b745d1..210a55365 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -81,7 +81,7 @@ pub mod prelude { pub use crate::{ dom_types::{ did_mount, did_update, input_ev, keyboard_ev, mouse_ev, pointer_ev, raw_ev, simple_ev, - will_unmount, At, El, Ev, Optimize::Key, Tag, UpdateEl, ElContainer, + will_unmount, At, El, ElContainer, Ev, Optimize::Key, Tag, UpdateEl, }, shortcuts::*, // appears not to work. vdom::{ShouldRender, ShouldRender::*, Update}, diff --git a/src/routing.rs b/src/routing.rs index c51c0ff7d..370a4f0e7 100644 --- a/src/routing.rs +++ b/src/routing.rs @@ -177,8 +177,8 @@ fn clean_url(mut url: Url) -> Url { /// /// # Refenences /// * [MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/History_API) -pub fn push_route>(url3: U) { - let mut url = url3.into(); +pub fn push_route>(url: U) { + let mut url = url.into(); // Purge leading / from each part, if it exists, eg passed by user. url = clean_url(url); diff --git a/src/vdom.rs b/src/vdom.rs index 3f4db411b..45491b5d4 100644 --- a/src/vdom.rs +++ b/src/vdom.rs @@ -197,7 +197,9 @@ pub struct App> { pub data: Rc>, } -impl> ::std::fmt::Debug for App { +impl> ::std::fmt::Debug + for App +{ fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { write!(f, "App") } diff --git a/src/websys_bridge.rs b/src/websys_bridge.rs index 28ad51544..02da2c72c 100644 --- a/src/websys_bridge.rs +++ b/src/websys_bridge.rs @@ -155,7 +155,10 @@ pub fn make_websys_el( } /// Similar to attach_el_and_children, but assumes we've already attached the parent. -pub fn attach_children>(el_vdom: &mut El, app: &App) { +pub fn attach_children>( + el_vdom: &mut El, + app: &App, +) { let el_ws = el_vdom .el_ws .take()