diff --git a/.helix/languages.toml b/.helix/languages.toml index 710e116..a9719ff 100644 --- a/.helix/languages.toml +++ b/.helix/languages.toml @@ -6,7 +6,11 @@ language-servers = ["rust-analyzer", "tailwindcss-ls"] # procMacro = { ignored = { leptos_macro = ["server"] } } cargo = { features = ["ssr", "hydrate"] } check = { command = "clippy" } -rustfmt = { overrideCommand = ["leptosfmt", "--stdin", "--rustfmt"] } +rustfmt = { overrideCommand = [ + "sh", + "-c", + "rustfmt --emit stdout --edition 2024 | leptosfmt --stdin", +] } [language-server.tailwindcss-ls] config = { userLanguages = { rust = "html", "*.rs" = "html" } } diff --git a/crates/ascend/src/components/icons.rs b/crates/ascend/src/components/icons.rs index a8bc37d..0069c38 100644 --- a/crates/ascend/src/components/icons.rs +++ b/crates/ascend/src/components/icons.rs @@ -67,3 +67,23 @@ pub fn Check() -> impl IntoView { } } + +#[component] +pub fn Heart() -> impl IntoView { + view! { + + + + } +} diff --git a/crates/ascend/src/lib.rs b/crates/ascend/src/lib.rs index cb3f5f1..8baa318 100644 --- a/crates/ascend/src/lib.rs +++ b/crates/ascend/src/lib.rs @@ -18,45 +18,8 @@ pub mod components { pub mod problem_info; } -pub mod resources { - use crate::codec::ron::Ron; - use crate::codec::ron::RonEncoded; - use crate::models::{self}; - use leptos::prelude::Get; - use leptos::prelude::Signal; - use leptos::server::Resource; - use server_fn::ServerFnError; +pub mod resources; - type RonResource = Resource, Ron>; - - pub fn wall_by_uid(wall_uid: Signal) -> RonResource { - Resource::new_with_options( - move || wall_uid.get(), - move |wall_uid| async move { crate::server_functions::get_wall(wall_uid).await.map(RonEncoded::into_inner) }, - false, - ) - } - - pub fn problem_by_uid(wall_uid: Signal, problem_uid: Signal) -> RonResource { - Resource::new_with_options( - move || (wall_uid.get(), problem_uid.get()), - move |(wall_uid, problem_uid)| async move { - crate::server_functions::get_problem(wall_uid, problem_uid) - .await - .map(RonEncoded::into_inner) - }, - false, - ) - } - - pub fn problems_for_wall(wall_uid: Signal) -> RonResource> { - Resource::new_with_options( - move || wall_uid.get(), - move |wall_uid| async move { crate::server_functions::get_problems_for_wall(wall_uid).await.map(RonEncoded::into_inner) }, - false, - ) - } -} pub mod codec; pub mod models; pub mod server_functions; diff --git a/crates/ascend/src/models.rs b/crates/ascend/src/models.rs index f497118..50d1c1c 100644 --- a/crates/ascend/src/models.rs +++ b/crates/ascend/src/models.rs @@ -14,11 +14,14 @@ pub use v2::Root; pub use v2::Wall; pub use v2::WallDimensions; pub use v2::WallUid; +pub use v3::UserInteraction; pub mod v3 { use super::v2; + use chrono::NaiveDate; use serde::Deserialize; use serde::Serialize; + use std::collections::BTreeSet; /// Registers user interaction with a problem #[derive(Serialize, Deserialize, Debug, Clone)] @@ -27,26 +30,26 @@ pub mod v3 { pub problem_uid: v2::ProblemUid, /// Climbed problem - pub is_completed: bool, + pub completed_on: BTreeSet, /// Flashed problem - pub is_flashed: bool, + pub flashed_on: BTreeSet, /// Is among favorite problems pub is_favorite: bool, /// Added to personal challenges - pub is_challenge: bool, + pub is_saved: bool, } impl UserInteraction { pub fn new(wall_uid: v2::WallUid, problem_uid: v2::ProblemUid) -> Self { Self { wall_uid, problem_uid, - is_completed: false, - is_flashed: false, is_favorite: false, - is_challenge: false, + completed_on: BTreeSet::new(), + flashed_on: BTreeSet::new(), + is_saved: false, } } } diff --git a/crates/ascend/src/pages/wall.rs b/crates/ascend/src/pages/wall.rs index ba3b69d..3b408c5 100644 --- a/crates/ascend/src/pages/wall.rs +++ b/crates/ascend/src/pages/wall.rs @@ -78,6 +78,8 @@ pub fn Wall() -> impl IntoView { } }); + let user_interaction = crate::resources::user_interaction(wall_uid, problem_uid.into()); + let header_items = move || HeaderItems { left: vec![], middle: vec![HeaderItem { @@ -98,6 +100,7 @@ pub fn Wall() -> impl IntoView { let foo = RwSignal::new(false); let bar = RwSignal::new(false); + let baz = RwSignal::new(false); leptos::view! {
@@ -153,7 +156,7 @@ pub fn Wall() -> impl IntoView {
// -
Flash!
+
Flash
@@ -169,18 +172,48 @@ pub fn Wall() -> impl IntoView { />