Skip to content

Commit

Permalink
v0.3.2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
David-OConnor committed Apr 21, 2019
1 parent 3360a62 commit ece4ca5
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 45 deletions.
16 changes: 10 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
# Changelog

## v0.3.2
- Top level view functions can now return `Vec<El<Ms>>`, `El<Ms>`, or something else implementing
the new ElContainer trait

## v0.3.1
- `Top level view functions now return `Vec<El<Ms>>` instead of `El<Ms>`, mounted directly to
- 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()`.
- `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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
11 changes: 5 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
license = "MIT"
Expand All @@ -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",
Expand Down
49 changes: 25 additions & 24 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) -> Vec<El<Msg>> {
fn view(model: &Model) -> El<Msg> {
let plural = if model.count == 1 {""} else {"s"};

// Attrs, Style, Events, and children may be defined separately.
Expand All @@ -155,29 +155,27 @@ fn view(model: &Model) -> Vec<El<Msg>> {
"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) ]
]
}

Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions examples/counter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion examples/counter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn success_level(clicks: i32) -> El<Msg> {

/// 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<Msg> {
fn view(model: &Model) -> El<Msg> {
let plural = if model.count == 1 { "" } else { "s" };
let text = format!("{} {}{} so far", model.count, model.what_we_count, plural);

Expand Down
2 changes: 1 addition & 1 deletion examples/window_events/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
4 changes: 2 additions & 2 deletions src/routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<U: Into<Url>>(url3: U) {
let mut url = url3.into();
pub fn push_route<U: Into<Url>>(url: U) {
let mut url = url.into();
// Purge leading / from each part, if it exists, eg passed by user.
url = clean_url(url);

Expand Down
4 changes: 3 additions & 1 deletion src/vdom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ pub struct App<Ms: Clone + 'static, Mdl: 'static, ElC: ElContainer<Ms>> {
pub data: Rc<AppData<Ms, Mdl>>,
}

impl<Ms: Clone + 'static, Mdl: 'static, ElC: ElContainer<Ms>> ::std::fmt::Debug for App<Ms, Mdl, ElC> {
impl<Ms: Clone + 'static, Mdl: 'static, ElC: ElContainer<Ms>> ::std::fmt::Debug
for App<Ms, Mdl, ElC>
{
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
write!(f, "App")
}
Expand Down
5 changes: 4 additions & 1 deletion src/websys_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ pub fn make_websys_el<Ms: Clone>(
}

/// Similar to attach_el_and_children, but assumes we've already attached the parent.
pub fn attach_children<Ms: Clone, Mdl, ElC: ElContainer<Ms>>(el_vdom: &mut El<Ms>, app: &App<Ms, Mdl, ElC>) {
pub fn attach_children<Ms: Clone, Mdl, ElC: ElContainer<Ms>>(
el_vdom: &mut El<Ms>,
app: &App<Ms, Mdl, ElC>,
) {
let el_ws = el_vdom
.el_ws
.take()
Expand Down

0 comments on commit ece4ca5

Please sign in to comment.