,
pub on_click: Callback<(usize, usize)>,
}
#[function_component(PlacedTileView)]
pub fn placed_tile_view(
PlacedTileViewProps {
x,
y,
tile,
on_click,
}: &PlacedTileViewProps,
) -> Html {
let x = *x;
let y = *y;
let on_select = {
let on_click = on_click.clone();
Callback::from(move |_| on_click.emit((x, y)))
};
html! {
{ tile.map(|tile| {
html! { tile }
}).unwrap_or_else(|| {
html! { "" }
})} |
}
}
#[derive(Properties, PartialEq)]
pub struct TileViewProps {
pub tile: Tile,
pub on_select: Callback,
pub idx: usize,
}
#[function_component(TileView)]
pub fn tile_view(
TileViewProps {
tile,
on_select,
idx,
}: &TileViewProps,
) -> Html {
let on_select = on_select.clone();
let idx = *idx;
html! {
{ tile.to_string() }
}
}