From 976a4160810e38578e563e21f46fcb00306f4c18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asger=20Juul=20Brunsh=C3=B8j?= Date: Wed, 5 Mar 2025 01:25:02 +0100 Subject: [PATCH] radios --- Cargo.lock | 52 ++++++++++---------- crates/ascend/Cargo.toml | 2 +- crates/ascend/src/components/button.rs | 6 ++- crates/ascend/src/components/icons.rs | 44 +++++++++++++++++ crates/ascend/src/components/outlined_box.rs | 43 +++++++++++++--- crates/ascend/src/pages/wall.rs | 46 +++++++++++++---- 6 files changed, 147 insertions(+), 46 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c9e2bb9..11d6c2d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1760,9 +1760,9 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "leptos" -version = "0.7.5" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78329c12843d64766d8f00216aae665416d804327302ce8e0ab83884dfa91887" +checksum = "88613d81f70f4e267473b2ee107e1ee70cf765a3c3dfee945929c8e9c520b957" dependencies = [ "any_spawner", "base64 0.22.1", @@ -1823,9 +1823,9 @@ dependencies = [ [[package]] name = "leptos_config" -version = "0.7.5" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "132a18e8ffc4fbe2d624f3743d88a1b4989bff2d5e12be2b0d2749201d9dfb52" +checksum = "4172cfee12576224775ccfbb9d3e76625017a8b4207c4641a2f9b96a70e6d524" dependencies = [ "config", "regex", @@ -1836,9 +1836,9 @@ dependencies = [ [[package]] name = "leptos_dom" -version = "0.7.5" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468f638f2f13d70d99d9952be98d671a75366034472f3828e586ba62d770049" +checksum = "a41f6dc3ddaa09d876d7015f08f4f3905787da4ea5460cef130c365419483a89" dependencies = [ "js-sys", "or_poisoned", @@ -1852,9 +1852,9 @@ dependencies = [ [[package]] name = "leptos_hot_reload" -version = "0.7.5" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ba37d76693fc6228554e0bb06a9aa41c59e2b5180caf423c7913557b81d01dd" +checksum = "31f5c961e5d9b2aa6deab39d5d842272e8b1b165744b5caf674770d5cf0daa04" dependencies = [ "anyhow", "camino", @@ -1885,9 +1885,9 @@ dependencies = [ [[package]] name = "leptos_macro" -version = "0.7.5" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "064d0c8b144b93f8d7e84b30c16d1da0e64a63c7e91b9a872f7be63601c5868b" +checksum = "2b9165909eabb02188a4b33b0ab6acff408bdf440018bf65b30bba0d38d61b19" dependencies = [ "attribute-derive", "cfg-if", @@ -1961,9 +1961,9 @@ dependencies = [ [[package]] name = "leptos_server" -version = "0.7.5" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb1779f1f0570915066c132fb11f999add8b13d02ca5221735193eb02b3fa69a" +checksum = "4fee9ed4526484b17561bc8ce1532c613e37be2c01788fed3d1c4104db674dd9" dependencies = [ "any_spawner", "base64 0.22.1", @@ -2663,9 +2663,9 @@ dependencies = [ [[package]] name = "reactive_graph" -version = "0.1.5" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "059aede5acae8f5c25b1d34b6df34700006418b3c493db3698b7ebcd4a8a6287" +checksum = "9996b4c0f501d64a755ff3dfbe9276e9f834d105d7d45059ad4bd6d2a56477d0" dependencies = [ "any_spawner", "async-lock", @@ -2685,9 +2685,9 @@ dependencies = [ [[package]] name = "reactive_stores" -version = "0.1.5" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7edacf4298579a5772285b8e2dc0b9953c8fbaa9c3f56c3dd69d56e5af7a48" +checksum = "74c3d2a20d8edd8ac6628718209f743da86349d7f10a4458304666c2ddfc082e" dependencies = [ "guardian", "itertools 0.13.0", @@ -2700,9 +2700,9 @@ dependencies = [ [[package]] name = "reactive_stores_macro" -version = "0.1.5" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "178b1cd8b2871a45bfc8e13ff8076049b6e9a5132e72414e5cab3894c4a6adb3" +checksum = "6d4d8e40112b8ee1424e5ec636fcbc9764c1a099e81f8fa818f6762b43cc10cd" dependencies = [ "convert_case", "proc-macro-error2", @@ -2941,9 +2941,9 @@ dependencies = [ [[package]] name = "server_fn" -version = "0.7.5" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c183c31152fd00e994a3ea0ca43e6017056ccf7812160b0ae008acc3de8241c" +checksum = "055476c2a42c9a98a69e3f0ce29b86aa3acbdef19a84e0523330f095097defcf" dependencies = [ "axum", "bytes", @@ -2978,9 +2978,9 @@ dependencies = [ [[package]] name = "server_fn_macro" -version = "0.7.5" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c43b2266308c118be1a1cc60602f8efb07a64e72deed8d317704d5cfda092ca1" +checksum = "e65737414a9583ce3b43dddd4e5dfb33fe385a6933ed79a9b539b8eb0767cd07" dependencies = [ "const_format", "convert_case", @@ -2992,9 +2992,9 @@ dependencies = [ [[package]] name = "server_fn_macro_default" -version = "0.7.5" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "087eca61bc8f93d868b8c10ca058da358fd7aaeb7bc8415b572f9f3f27ce0b93" +checksum = "563909a43390341403ab76fbc33fde306712613da02244e692eabeae8ffde949" dependencies = [ "server_fn_macro", "syn", @@ -3148,9 +3148,9 @@ dependencies = [ [[package]] name = "tachys" -version = "0.1.5" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59a3bbcf8e3b52cad5f0aa860837d4d1796c7c4873b083c9520a1bbba4747973" +checksum = "4c05fed41ed4e334257090500510df21bb1611680c0cfd3be14acec7ffdf3d95" dependencies = [ "any_spawner", "async-trait", diff --git a/crates/ascend/Cargo.toml b/crates/ascend/Cargo.toml index e7673a6..bf4bcb6 100644 --- a/crates/ascend/Cargo.toml +++ b/crates/ascend/Cargo.toml @@ -23,7 +23,7 @@ derive_more = { version = "2", features = [ ] } http = "1" image = { version = "0.25", optional = true } -leptos = { version = "0.7.4", features = ["tracing"] } +leptos = { version = "0.7.7", features = ["tracing"] } leptos_axum = { version = "0.7", optional = true } leptos_meta = { version = "0.7" } leptos_router = { version = "0.7.0" } diff --git a/crates/ascend/src/components/button.rs b/crates/ascend/src/components/button.rs index e69ffc2..3b0569b 100644 --- a/crates/ascend/src/components/button.rs +++ b/crates/ascend/src/components/button.rs @@ -12,11 +12,13 @@ pub fn Button( #[prop(optional)] color: Gradient, + #[prop(into, optional)] highlight: MaybeProp, + onclick: impl FnMut(MouseEvent) + 'static, ) -> impl IntoView { let icon_view = icon.get().map(|i| { let icon_view = i.into_view(); - let mut classes = "self-center mx-5 my-2.5 text-pink-500 rounded-sm".to_string(); + let mut classes = "self-center mx-5 my-2.5 rounded-sm".to_string(); classes.push(' '); classes.push_str(color.class_text()); @@ -41,7 +43,7 @@ pub fn Button( type="button" class="mb-2 me-2 hover:brightness-125 active:brightness-90" > - +
{icon_view} {separator} {text_view}
diff --git a/crates/ascend/src/components/icons.rs b/crates/ascend/src/components/icons.rs index 698bb9b..68b5b9f 100644 --- a/crates/ascend/src/components/icons.rs +++ b/crates/ascend/src/components/icons.rs @@ -11,6 +11,8 @@ pub enum Icon { ArrowPath, PaperAirplaneSolid, NoSymbol, + Trophy, + ArrowTrendingUp, } impl Icon { // TODO: Actually impl IntoView for Icon instead @@ -25,6 +27,8 @@ impl Icon { Icon::ArrowPath => view! { }.into_any(), Icon::PaperAirplaneSolid => view! { }.into_any(), Icon::NoSymbol => view! { }.into_any(), + Icon::Trophy => view! { }.into_any(), + Icon::ArrowTrendingUp => view! { }.into_any(), } } } @@ -182,3 +186,43 @@ pub fn NoSymbol() -> impl IntoView { } } + +#[component] +pub fn Trophy() -> impl IntoView { + view! { + + + + } +} + +#[component] +pub fn ArrowTrendingUp() -> impl IntoView { + view! { + + + + } +} diff --git a/crates/ascend/src/components/outlined_box.rs b/crates/ascend/src/components/outlined_box.rs index e6602c0..d78a731 100644 --- a/crates/ascend/src/components/outlined_box.rs +++ b/crates/ascend/src/components/outlined_box.rs @@ -2,16 +2,43 @@ use crate::gradient::Gradient; use leptos::prelude::*; #[component] -pub fn OutlinedBox(children: Children, color: Gradient) -> impl IntoView { - let mut classes = "p-0.5 bg-gradient-to-br rounded-lg".to_string(); - classes.push(' '); - classes.push_str(color.class_from()); - classes.push(' '); - classes.push_str(color.class_to()); +pub fn OutlinedBox(children: Children, color: Gradient, #[prop(optional)] highlight: MaybeProp) -> impl IntoView { + let highlight = move || highlight.get().unwrap_or(false); + + let outer_classes = move || { + let mut c = "p-0.5 bg-gradient-to-br rounded-lg".to_string(); + c.push(' '); + c.push_str(color.class_from()); + c.push(' '); + c.push_str(color.class_to()); + if highlight() { + c.push(' '); + c.push_str("brightness-110"); + } + c + }; + + let inner_classes = move || { + let mut c = "py-1.5 rounded-md".to_string(); + if highlight() { + let bg = match color { + Gradient::PinkOrange => "bg-pink-900", + Gradient::CyanBlue => "bg-cyan-900", + Gradient::TealLime => "bg-teal-900", + }; + + c.push(' '); + c.push_str(bg); + } else { + c.push(' '); + c.push_str("bg-gray-900"); + } + c + }; view! { -
-
{children()}
+
+
{children()}
} } diff --git a/crates/ascend/src/pages/wall.rs b/crates/ascend/src/pages/wall.rs index 67e027b..8db3f78 100644 --- a/crates/ascend/src/pages/wall.rs +++ b/crates/ascend/src/pages/wall.rs @@ -21,9 +21,9 @@ // | | // +--------------------------------------+ -// + ------- + + ------ -+ +---------+ -// | Flash | | Top | | Attempt | -// + ------- + + ------ -+ +---------+ +// +---------+ +---------+ +---------+ +// | Flash | | Send | | Attempt | +// +---------+ +---------+ +---------+ // +---------- ----------+ // | Today: | @@ -94,6 +94,7 @@ pub fn Wall() -> impl IntoView { let ui_is_flash = RwSignal::new(false); let ui_is_climbed = RwSignal::new(false); + let ui_is_attempt = RwSignal::new(false); let ui_is_favorite = RwSignal::new(false); // On reception of user interaction state, set UI signals @@ -163,17 +164,44 @@ pub fn Wall() -> impl IntoView {
- - + +