summaryrefslogtreecommitdiff
path: root/webapp/src/components/hand.rs
diff options
context:
space:
mode:
authorKjetil Orbekk <kj@orbekk.com>2022-09-11 13:03:36 -0400
committerKjetil Orbekk <kj@orbekk.com>2022-09-11 13:03:36 -0400
commit435272c941d6cb8e7e18312cac16e319b16e8f50 (patch)
tree3da95e1e2e2d90c883d07b3185d49654fdd590de /webapp/src/components/hand.rs
parent9656f8ce14360dc0eb83e2b65ed25eef79c02e42 (diff)
Add card callbacks
Diffstat (limited to 'webapp/src/components/hand.rs')
-rw-r--r--webapp/src/components/hand.rs30
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>,
}