Skip to content
This repository has been archived by the owner on Jul 19, 2020. It is now read-only.

Commit

Permalink
Fix breaking changes in Yew (#217)
Browse files Browse the repository at this point in the history
* initial work - held up by broken generic components

* fix guide example
  • Loading branch information
hgzimmerman authored Jan 9, 2020
1 parent c322c51 commit fbf88e3
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 19 deletions.
6 changes: 3 additions & 3 deletions examples/guide/src/guide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub struct Guide {
props: GuideProps,
}

#[derive(Properties)]
#[derive(Properties, Clone)]
pub struct GuideProps {
children: ChildrenWithProps<Page>,
}
Expand Down Expand Up @@ -100,13 +100,13 @@ fn render_page_list_item(props: PageProps, route: &Route) -> Html {
log::debug!("Found an active");
return html! {
<li style="padding-left: 4px; padding-right: 4px; padding-top: 6px; padding-bottom: 6px; background-color: lightgray;">
<RouterAnchor<String> route=props.page_url.clone()> {&props.title} </RouterLink>
<RouterAnchor<String> route=props.page_url.clone()> {&props.title} </RouterAnchor<String>>
</li>
};
} else {
return html! {
<li style="padding-left: 4px; padding-right: 4px; padding-top: 6px; padding-bottom: 6px; background-color: white;">
<RouterAnchor<String> route=props.page_url.clone()> {&props.title} </RouterLink>
<RouterAnchor<String> route=props.page_url.clone()> {&props.title} </RouterAnchor<String>>
</li>
};
}
Expand Down
2 changes: 1 addition & 1 deletion examples/guide/src/markdown_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct MarkdownWindow {
link: ComponentLink<Self>,
}

#[derive(Properties, Debug)]
#[derive(Properties, Debug, Clone)]
pub struct MdProps {
pub uri: Option<String>,
}
Expand Down
2 changes: 1 addition & 1 deletion examples/guide/src/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use yew::{prelude::*, virtual_dom::VNode};

pub struct Page;

#[derive(Properties)]
#[derive(Properties, Clone)]
pub struct PageProps {
#[props(required)]
pub uri: String,
Expand Down
6 changes: 3 additions & 3 deletions examples/minimal/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ impl Component for Model {
<div>
{
match AppRoute::switch(self.route.clone()) {
Some(AppRoute::A(thing)) => html!{thing},
Some(AppRoute::A(thing)) => VNode::from(thing.as_str()),
Some(AppRoute::B{anything, number}) => html!{<div> {anything} {number} </div>},
Some(AppRoute::C) => html!{"C"},
None => html!{"404"}
Some(AppRoute::C) => VNode::from("C"),
None => VNode::from("404")
}
}
</div>
Expand Down
13 changes: 6 additions & 7 deletions examples/router_component/src/a_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub struct AModel {
props: Props,
}

#[derive(PartialEq, Properties)]
#[derive(Clone, PartialEq, Properties)]
pub struct Props {
#[props(required)]
pub route: Option<ARoute>,
Expand Down Expand Up @@ -36,12 +36,11 @@ impl Component for AModel {
<div>
{ "I am the A component"}
<div>
<RouterButton<AppRoute> route=AppRoute::A(AllowMissing(Some(ARoute)))>
{"Go to a/c"}
</RouterButton>
// <RouterButton route="/a/d">
// {"Go to a/d (route does not exist)"}
// </RouterButton>
<RouterButton<AppRoute>
route=AppRoute::A(AllowMissing(Some(ARoute)))
/>
// {"Go to a/c"}
// </RouterButton<AppRoute>>
</div>
<div>
{
Expand Down
2 changes: 1 addition & 1 deletion examples/router_component/src/b_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct BModel {
update_subpath: Callback<InputData>,
}

#[derive(PartialEq, Properties)]
#[derive(Clone, PartialEq, Properties)]
pub struct Props {
#[props(required)]
pub number: Option<usize>,
Expand Down
2 changes: 1 addition & 1 deletion examples/router_component/src/c_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use yew::{prelude::*, virtual_dom::VNode, Properties};

pub struct CModel;

#[derive(PartialEq, Properties)]
#[derive(Clone, PartialEq, Properties)]
pub struct Props {}

pub enum Msg {}
Expand Down
4 changes: 2 additions & 2 deletions src/components/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ use crate::Switch;
// TODO This should also be PartialEq and Clone. Its blocked on Children not supporting that.
// TODO This should no longer take link & String, and instead take a route: SW implementing Switch
/// Properties for `RouterButton` and `RouterLink`.
#[derive(Properties, Default, Debug)]
#[derive(Properties, Clone, Default, Debug)]
pub struct Props<SW>
where
SW: Switch,
SW: Switch + Clone,
{
/// The Switched item representing the route.
#[props(required)]
Expand Down

0 comments on commit fbf88e3

Please sign in to comment.