diff options
Diffstat (limited to 'webapp/src/components/hand.rs')
-rw-r--r-- | webapp/src/components/hand.rs | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/webapp/src/components/hand.rs b/webapp/src/components/hand.rs index bb6e372..9e1f993 100644 --- a/webapp/src/components/hand.rs +++ b/webapp/src/components/hand.rs @@ -1,16 +1,14 @@ -use yew::prelude::*; use crate::components::card::{Card, CardProps}; +use crate::card; +use yew::prelude::*; #[function_component(Hand)] pub fn hand(props: &HandProps) -> Html { - let cards = props - .cards - .iter() - .map(|c| { - html! { - <Card ..c.clone() /> - } - }); + let cards = props.cards.iter().map(|card| { + html! { + <Card card={ card.clone() } onclick={ props.on_card_clicked.clone() } /> + } + }); html! { { for cards } @@ -20,16 +18,6 @@ pub fn hand(props: &HandProps) -> Html { #[derive(Clone, Default, PartialEq, Properties)] pub struct HandProps { #[prop_or_default] - pub cards: Vec<CardProps>, -} - -impl<C: Into<CardProps>> FromIterator<C> for HandProps { - fn from_iter<Cards>(cards: Cards) -> Self - where - Cards: std::iter::IntoIterator<Item = C>, - { - HandProps { - cards: cards.into_iter().map(Into::into).collect(), - } - } + pub cards: Vec<card::Card>, + pub on_card_clicked: Callback<card::Card>, } |