diff --git a/crates/ascend/Cargo.toml b/crates/ascend/Cargo.toml index 0eb68d5..6bb08a4 100644 --- a/crates/ascend/Cargo.toml +++ b/crates/ascend/Cargo.toml @@ -52,7 +52,7 @@ error_reporter = { version = "1" } getrandom = { version = "0.3.1" } [dev-dependencies] -test-try= "0.1" +test-try = "0.1" [dev-dependencies.serde_json] version = "1" diff --git a/crates/ascend/src/components.rs b/crates/ascend/src/components.rs index 677de3f..a56b78e 100644 --- a/crates/ascend/src/components.rs +++ b/crates/ascend/src/components.rs @@ -19,9 +19,9 @@ use leptos::prelude::*; #[component] pub fn OnHoverRed(children: Children) -> impl IntoView { view! { -
+
{children()}
-
+
} } diff --git a/crates/ascend/src/components/checkbox.rs b/crates/ascend/src/components/checkbox.rs index b85e03d..2a8cff0 100644 --- a/crates/ascend/src/components/checkbox.rs +++ b/crates/ascend/src/components/checkbox.rs @@ -8,7 +8,7 @@ pub fn Checkbox(checked: RwSignal, #[prop(into)] text: Signal, #[p let unique_id = Oco::from(format!("checkbox-{}", uuid::Uuid::new_v4())); let checkbox_view = view! { -
+
@@ -25,7 +25,7 @@ pub fn Checkbox(checked: RwSignal, #[prop(into)] text: Signal, #[p }; let text_view = view! { -
+
{move || text.get()}
}; diff --git a/crates/ascend/src/components/problem_info.rs b/crates/ascend/src/components/problem_info.rs index 3aeb7dc..86110d4 100644 --- a/crates/ascend/src/components/problem_info.rs +++ b/crates/ascend/src/components/problem_info.rs @@ -11,7 +11,7 @@ pub fn ProblemInfo(#[prop(into)] problem: Signal) -> impl IntoV // let set_by = Signal::derive(move || problem.read().set_by.clone()); view! { -
+
// // @@ -23,7 +23,7 @@ pub fn ProblemInfo(#[prop(into)] problem: Signal) -> impl IntoV #[tracing::instrument(skip_all)] fn NameValue(#[prop(into)] name: Signal, #[prop(into)] value: Signal) -> impl IntoView { view! { -

{name.get()}

+

{name.get()}

{value.get()}

} } diff --git a/crates/ascend/src/models.rs b/crates/ascend/src/models.rs index 6189ce5..3879ce4 100644 --- a/crates/ascend/src/models.rs +++ b/crates/ascend/src/models.rs @@ -27,8 +27,6 @@ pub mod v4 { use super::v3; use chrono::DateTime; use chrono::Utc; - use derive_more::Display; - use derive_more::FromStr; use serde::Deserialize; use serde::Serialize; use std::collections::BTreeMap; diff --git a/crates/ascend/src/models/semantics.rs b/crates/ascend/src/models/semantics.rs index 840c521..56e8746 100644 --- a/crates/ascend/src/models/semantics.rs +++ b/crates/ascend/src/models/semantics.rs @@ -132,9 +132,11 @@ impl WallUid { pub(crate) fn create() -> Self { Self(uuid::Uuid::new_v4()) } + #[expect(dead_code)] pub(crate) fn min() -> Self { Self(uuid::Uuid::nil()) } + #[expect(dead_code)] pub(crate) fn max() -> Self { Self(uuid::Uuid::max()) } diff --git a/crates/ascend/src/pages/wall.rs b/crates/ascend/src/pages/wall.rs index 2f6a5ff..03a8f71 100644 --- a/crates/ascend/src/pages/wall.rs +++ b/crates/ascend/src/pages/wall.rs @@ -68,6 +68,7 @@ struct Context { cb_click_hold: Callback, cb_remove_hold_from_filter: Callback, cb_next_problem: Callback<()>, + cb_set_problem: Callback, cb_upsert_todays_attempt: Callback, } @@ -91,7 +92,6 @@ fn Controller( }); // Derive signals - let wall_uid = signals::wall_uid(wall); let user_interaction = signals::user_interaction(user_interactions.into(), problem.into()); let filtered_problems = signals::filtered_problems(wall, filter_holds.into()); let todays_attempt = signals::todays_attempt(user_interaction); @@ -103,6 +103,11 @@ fn Controller( upsert_todays_attempt.dispatch(RonEncoded(attempt)); }); + // Callback: Set specific problem + let cb_set_problem: Callback = Callback::new(move |problem| { + set_problem.set(Some(problem)); + }); + // Callback: Set next problem to a random problem let cb_set_random_problem: Callback<()> = Callback::new(move |_| { // TODO: remove current problem from population @@ -152,6 +157,7 @@ fn Controller( cb_upsert_todays_attempt, cb_remove_hold_from_filter, cb_next_problem: cb_set_random_problem, + cb_set_problem, todays_attempt, filter_holds: filter_holds.into(), filtered_problems: filtered_problems.into(), @@ -194,7 +200,7 @@ fn View() -> impl IntoView {
-
+
@@ -209,17 +215,21 @@ fn Transformations() -> impl IntoView { let ctx = use_context::().unwrap(); let on_left = Callback::new(move |()| { - tracing::info!("left"); + tracing::debug!("left"); }); let on_mirror = Callback::new(move |()| { - tracing::info!("mirror"); + tracing::debug!("mirror"); + if let Some(mut problem) = ctx.problem.get() { + problem.pattern = problem.pattern.mirror(); + ctx.cb_set_problem.run(problem); + } }); let on_right = Callback::new(move |()| { - tracing::info!("right"); + tracing::debug!("right"); }); view! { -
+