Skip to content

Commit

Permalink
Merge pull request #12 from spielrs/add-default-callback-navbar-item
Browse files Browse the repository at this point in the history
Add default callback navbar item
  • Loading branch information
dancespiele authored Mar 18, 2020
2 parents c0360fa + a429f39 commit cfb2edb
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
4 changes: 2 additions & 2 deletions crate/Cargo.lock

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

2 changes: 1 addition & 1 deletion crate/yew_styles/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "yew_styles"
version = "0.2.0"
version = "0.2.1"
description = "Framework styles for yew"
authors = ["spieljs <[email protected]>"]
edition = "2018"
Expand Down
10 changes: 4 additions & 6 deletions crate/yew_styles/src/components/item.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(any(feature = "web_sys", feature = "std_web"))]
use crate::utils::{create_style, DefaultCallback};
use crate::utils::create_style;
use yew::prelude::*;

#[derive(Clone)]
Expand Down Expand Up @@ -52,10 +52,8 @@ pub struct Props {
pub class_name: String,
#[prop_or_default]
pub index: i16,
#[prop_or(DefaultCallback {
callback: Callback::noop(),
})]
pub onsignal: DefaultCallback<Callback<()>>,
#[prop_or(Callback::noop())]
pub onsignal: Callback<()>,
pub children: Children,
}

Expand All @@ -76,7 +74,7 @@ impl Component for Item {
fn update(&mut self, msg: Self::Message) -> ShouldRender {
match msg {
Msg::Clicked => {
self.props.onsignal.callback.emit(());
self.props.onsignal.emit(());
}
};

Expand Down
1 change: 1 addition & 0 deletions crate/yew_styles/src/components/navbar/navbar_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub struct NavbarItemModel;
pub struct Props {
#[prop_or_default]
pub class_name: String,
#[prop_or(Callback::noop())]
pub onsignal: Callback<()>,
pub children: Children,
}
Expand Down
5 changes: 0 additions & 5 deletions crate/yew_styles/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,3 @@ pub fn create_style(style: String, value: String, wrap: String) {
element.style[@{style}] = @{value};
};
}

#[derive(Clone)]
pub struct DefaultCallback<T> {
pub callback: T,
}

0 comments on commit cfb2edb

Please sign in to comment.