From df90835aac2fb79f9f5e3047f93647e9e5536846 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asger=20Juul=20Brunsh=C3=B8j?= Date: Tue, 4 Mar 2025 11:08:19 +0100 Subject: [PATCH] chore: fmt --- .helix/languages.toml | 13 ++++--- crates/ascend/src/app.rs | 2 +- crates/ascend/src/components/attempt.rs | 2 +- crates/ascend/src/components/button.rs | 37 ++++++++++++++++++-- crates/ascend/src/components/header.rs | 4 +-- crates/ascend/src/components/problem.rs | 2 +- crates/ascend/src/components/problem_info.rs | 6 ++-- crates/ascend/src/lib.rs | 1 + crates/ascend/src/pages/edit_wall.rs | 4 +-- crates/ascend/src/pages/routes.rs | 4 +-- crates/ascend/src/pages/settings.rs | 4 +-- crates/ascend/src/pages/wall.rs | 26 +++++++------- crates/ascend/src/server/db.rs | 9 ++--- crates/ascend/src/server/migrations.rs | 2 +- leptosfmt.toml | 4 +++ rustfmt.toml | 2 +- 16 files changed, 81 insertions(+), 41 deletions(-) create mode 100644 leptosfmt.toml diff --git a/.helix/languages.toml b/.helix/languages.toml index 3ec7ed5..ba7a252 100644 --- a/.helix/languages.toml +++ b/.helix/languages.toml @@ -6,11 +6,14 @@ language-servers = ["rust-analyzer", "tailwindcss-ls"] # procMacro = { ignored = { leptos_macro = ["server"] } } cargo = { features = ["ssr", "hydrate"] } check = { command = "check" } -rustfmt = { overrideCommand = [ - "sh", - "-c", - "rustfmt --emit stdout --edition 2024 | leptosfmt --stdin", -] } + +rustfmt = { overrideCommand = ["leptosfmt", "--stdin", "--rustfmt"] } + +# rustfmt = { overrideCommand = [ +# "sh", +# "-c", +# "set -euo pipefail; rustfmt --emit stdout --edition 2024 | leptosfmt --stdin", +# ] } [language-server.tailwindcss-ls] config = { userLanguages = { rust = "html", "*.rs" = "html" } } diff --git a/crates/ascend/src/app.rs b/crates/ascend/src/app.rs index 8efd20c..bce9710 100644 --- a/crates/ascend/src/app.rs +++ b/crates/ascend/src/app.rs @@ -17,7 +17,7 @@ pub fn shell(options: LeptosOptions) -> impl IntoView { - + diff --git a/crates/ascend/src/components/attempt.rs b/crates/ascend/src/components/attempt.rs index 43d6e9f..5b35760 100644 --- a/crates/ascend/src/components/attempt.rs +++ b/crates/ascend/src/components/attempt.rs @@ -22,7 +22,7 @@ pub fn Attempt(#[prop(into)] attempt: Signal>) -> impl I }; view! { -
+
{icon} {text}
diff --git a/crates/ascend/src/components/button.rs b/crates/ascend/src/components/button.rs index ee2dd67..81844db 100644 --- a/crates/ascend/src/components/button.rs +++ b/crates/ascend/src/components/button.rs @@ -2,14 +2,45 @@ use leptos::prelude::*; use web_sys::MouseEvent; #[component] -pub fn Button(#[prop(into)] text: String, onclick: impl Fn(MouseEvent) + 'static) -> impl IntoView { +pub fn Button(icon: I, text: T, onclick: impl FnMut(MouseEvent) + 'static) -> impl IntoView +where + I: Fn() -> I_IV, + I_IV: IntoView, + T: Fn() -> T_IV, + T_IV: IntoView, +{ + // let icon = icon.map(|f| f()); view! { } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn baseline() { + let icon = || (); + let text = || (); + let onclick = |_| {}; + let props = ButtonProps { icon, text, onclick }; + Button(props); + } + + #[test] + fn simple() { + let icon = || view! { }; + let text = || Some("foo".to_string()); + let onclick = |_| {}; + + view! { impl IntoView { children=move |problem: models::Problem| { view! { -
+
} } /> @@ -78,7 +78,7 @@ pub fn Routes() -> impl IntoView { }; view! { -
+
diff --git a/crates/ascend/src/pages/settings.rs b/crates/ascend/src/pages/settings.rs index a1d7fdf..bc1344c 100644 --- a/crates/ascend/src/pages/settings.rs +++ b/crates/ascend/src/pages/settings.rs @@ -20,11 +20,11 @@ pub fn Settings() -> impl IntoView { }; view! { -
+
// {move || view! { }} -
+
} } diff --git a/crates/ascend/src/pages/wall.rs b/crates/ascend/src/pages/wall.rs index 10543b7..6af512b 100644 --- a/crates/ascend/src/pages/wall.rs +++ b/crates/ascend/src/pages/wall.rs @@ -107,7 +107,7 @@ pub fn Wall() -> impl IntoView { }; leptos::view! { -
+
@@ -137,14 +137,14 @@ pub fn Wall() -> impl IntoView { } }; let v = view! { -
+
{grid}