From 52b841d98a35c6a97d04f64bf54e14537ead80d1 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Thu, 3 Mar 2022 14:08:35 +0900 Subject: [PATCH] Replace slot "ref" with "id" --- front_end/src/state.rs | 60 ---------------- front_end/src/yew_components.rs | 118 ++++++++++++++++---------------- 2 files changed, 58 insertions(+), 120 deletions(-) diff --git a/front_end/src/state.rs b/front_end/src/state.rs index 7d3cdfa..9ec04d2 100644 --- a/front_end/src/state.rs +++ b/front_end/src/state.rs @@ -46,7 +46,6 @@ pub struct SharedState { pub board: [Rc>; 56], pub turn: Rc>, pub info_text_ref: [NodeRef; 2], - pub slot_refs: [NodeRef; 56], } impl Default for SharedState { @@ -114,65 +113,6 @@ impl Default for SharedState { turn: Rc::new(Cell::new(Turn::CyanPlayer)), // NodeRef array needs to have unique values info_text_ref: [NodeRef::default(), NodeRef::default()], - // slot_refs array needs to have unique values - slot_refs: [ - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - NodeRef::default(), - ], } } } diff --git a/front_end/src/yew_components.rs b/front_end/src/yew_components.rs index 41f8025..06ff311 100644 --- a/front_end/src/yew_components.rs +++ b/front_end/src/yew_components.rs @@ -32,7 +32,7 @@ impl Component for Slot { let col = idx % COLS; let row = idx / COLS; html! { - } @@ -74,62 +74,62 @@ impl Component for Wrapper { .expect("state to be set"); html! {
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
@@ -177,9 +177,7 @@ impl Component for Wrapper { }); // get handle to slot - if let Some(slot) = - shared.slot_refs[bottom_idx as usize].cast::() - { + if let Some(slot) = document.get_element_by_id(&format!("slot{bottom_idx}")) { // set slot info slot.set_class_name(&format!( "slot {} r{} c{}",