summaryrefslogtreecommitdiff
path: root/webapp/src/components/card.rs
blob: 6fbe7e707adb0cb173aae0454093365265b41f92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use yew::prelude::*;
use crate::card::{self, Suit, Rank};
use crate::components::suit_css_class;

#[function_component(Card)]
pub fn ccard(props: &CardProps) -> Html {
    html! {
        <div class="card">
            <div class={ suit_css_class(props.suit) }>
                { props.rank }
            </div>
        </div>
    }
}

#[derive(PartialEq, Properties, Clone)]
pub struct CardProps {
    pub suit: Suit,
    pub rank: Rank,
}

impl From<card::Card> for CardProps {
    fn from(card::Card(suit, rank): card::Card) -> Self {
        CardProps { suit, rank }
    }
}