From b5cd23ae50834eaf8a8f5504bb83d29549eaf82b Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Thu, 24 Nov 2022 14:43:42 -0500 Subject: Separate Table controller and view; display player hand from server --- webapp/src/components/table.rs | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'webapp/src/components') diff --git a/webapp/src/components/table.rs b/webapp/src/components/table.rs index 6d861d0..92302b2 100644 --- a/webapp/src/components/table.rs +++ b/webapp/src/components/table.rs @@ -2,11 +2,11 @@ use gloo_net::http::Request; use log::info; use protocol::bridge_engine::TableView; use yew::prelude::*; - use crate::use_app_context; +use crate::components::Hand; -#[function_component(Table)] -pub fn table(props: &TableProps) -> Html { +#[function_component(OnlineTable)] +pub fn online_table(props: &OnlineTableProps) -> Html { let ctx = use_app_context(); let table_state: UseStateHandle> = use_state(|| None); @@ -44,12 +44,37 @@ pub fn table(props: &TableProps) -> Html { -
{ format!("Table view: {:?}", *table_state) }
+ if let Some(table_state) = &*table_state { + + } } } #[derive(PartialEq, Properties, Clone)] -pub struct TableProps { +pub struct OnlineTableProps { pub table: protocol::Table, } + +#[function_component(Table)] +pub fn table(props: &TableProps) -> Html { + let on_card_clicked = { + Callback::from(move |card| { + info!("Card clicked: {}", card); + }) + }; + html! { + <> +
+ +
+

{ "Table view" }

+
{ format!("{:#?}", props.table) }
+ + } +} + +#[derive(PartialEq, Properties, Clone)] +pub struct TableProps { + pub table: TableView, +} -- cgit v1.2.3