Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking change: add support for required props #525

Merged
merged 9 commits into from
Jul 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,27 @@ Components live in an Angular-like scopes with **parent-to-child** *(properties)
Properties are also pure Rust types with strict type-checking during the compilation.

```rust
// my_button.rs

#[derive(Properties, PartialEq)]
pub struct Properties {
pub hidden: bool,
#[props(required)]
pub color: Color,
#[props(required)]
pub onclick: Callback<()>,
}

```

```rust
// confirm_dialog.rs

html! {
<nav class="menu">
<MyButton color=Color::Red />
<MyButton onclick=|_| ParentMsg::DoIt />
</nav>
<div class="confirm-dialog">
<MyButton onclick=|_| DialogMsg::Cancel color=Color::Red hidden=true />
<MyButton onclick=|_| DialogMsg::Submit color=Color::Blue />
</div>
}
```

Expand Down
8 changes: 7 additions & 1 deletion ci/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@ cargo web test --features web_test --target=wasm32-unknown-emscripten
echo "Testing for wasm32-unknown-unknown..."
cargo test --target=wasm32-unknown-unknown

echo "Testing macro..."
echo "Testing html macro..."
cargo test --test macro_test

echo "Testing derive props macro..."
cargo test --test derive_props_test

echo "Testing macro docs..."
(cd crates/macro && cargo test)

check_example() {
echo "Checking example [$2]"
pushd $2 > /dev/null
Expand Down
3 changes: 3 additions & 0 deletions crates/macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ syn = { version = "^0.15.34", features = ["full"] }

[dev-dependencies]
yew = { path = "../.." }

[build-dependencies]
autocfg = "0.1.3"
7 changes: 7 additions & 0 deletions crates/macro/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extern crate autocfg;

pub fn main() {
if autocfg::new().probe_rustc_version(1, 36) {
println!("cargo:rustc-cfg=has_maybe_uninit");
}
}
Loading