chore: fmt
This commit is contained in:
@@ -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" } }
|
||||
|
||||
@@ -17,7 +17,7 @@ pub fn shell(options: LeptosOptions) -> impl IntoView {
|
||||
<HydrationScripts options />
|
||||
<MetaTags />
|
||||
</head>
|
||||
<body class="bg-slate-950 text-white">
|
||||
<body class="text-white bg-slate-950">
|
||||
<App />
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -22,7 +22,7 @@ pub fn Attempt(#[prop(into)] attempt: Signal<Option<models::Attempt>>) -> impl I
|
||||
};
|
||||
|
||||
view! {
|
||||
<div class="flex gap-2 items-center justify-center">
|
||||
<div class="flex gap-2 justify-center items-center">
|
||||
<span>{icon}</span>
|
||||
<span>{text}</span>
|
||||
</div>
|
||||
|
||||
@@ -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<I, I_IV, T, T_IV>(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! {
|
||||
<button
|
||||
on:click=onclick
|
||||
type="button"
|
||||
class="text-black bg-orange-300 hover:bg-orange-400 focus:ring-4 focus:ring-orange-500 font-medium rounded-lg text-sm px-5 py-2.5 me-2 mb-2 focus:outline-none"
|
||||
class="py-2.5 px-5 mb-2 text-sm font-medium text-black bg-orange-300 rounded-lg hover:bg-orange-400 focus:ring-4 focus:ring-orange-500 focus:outline-none me-2"
|
||||
>
|
||||
{text}
|
||||
{icon()}
|
||||
{text()}
|
||||
</button>
|
||||
}
|
||||
}
|
||||
|
||||
#[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! { <crate::components::icons::ForwardSolid /> };
|
||||
let text = || Some("foo".to_string());
|
||||
let onclick = |_| {};
|
||||
|
||||
view! { <Button icon text onclick /> };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ pub struct HeaderItem {
|
||||
#[component]
|
||||
pub fn StyledHeader(#[prop(into)] items: Signal<HeaderItems>) -> impl IntoView {
|
||||
view! {
|
||||
<div class="bg-orange-300 text-black border-b-2 border-b-orange-400">
|
||||
<div class="text-black bg-orange-300 border-b-2 border-b-orange-400">
|
||||
// <div class="container mx-auto" >
|
||||
<Header items />
|
||||
// </div>
|
||||
@@ -33,7 +33,7 @@ pub fn Header(#[prop(into)] items: Signal<HeaderItems>) -> impl IntoView {
|
||||
let right = move || items.read().right.clone();
|
||||
|
||||
view! {
|
||||
<div class="grid grid-cols-[1fr_3fr_1fr] text-xl font-semibold p-4">
|
||||
<div class="grid p-4 text-xl font-semibold grid-cols-[1fr_3fr_1fr]">
|
||||
// Left side of header
|
||||
<div class="justify-self-start">
|
||||
<Items items=Signal::derive(left) />
|
||||
|
||||
@@ -31,7 +31,7 @@ pub fn Problem(
|
||||
let grid_classes = move || format!("grid grid-rows-{} grid-cols-{} gap-3", dim.get().rows, dim.get().cols);
|
||||
|
||||
view! {
|
||||
<div class="grid grid-cols-[auto,1fr] gap-8">
|
||||
<div class="grid gap-8 grid-cols-[auto,1fr]">
|
||||
<div class=move || { grid_classes }>{holds}</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ pub fn ProblemInfo(problem: models::Problem) -> impl IntoView {
|
||||
let method = problem.method;
|
||||
|
||||
view! {
|
||||
<div class="grid grid-rows-none grid-cols-[auto,1fr] gap-0.5">
|
||||
<div class="grid grid-rows-none gap-0.5 grid-cols-[auto,1fr]">
|
||||
<NameValue name="Name:" value=name />
|
||||
<NameValue name="Method:" value=method.to_string() />
|
||||
<NameValue name="Set By:" value=set_by />
|
||||
@@ -23,7 +23,7 @@ pub fn ProblemInfo(problem: models::Problem) -> impl IntoView {
|
||||
#[tracing::instrument(skip_all)]
|
||||
fn NameValue(#[prop(into)] name: String, #[prop(into)] value: String) -> impl IntoView {
|
||||
view! {
|
||||
<p class="text-orange-300 mr-4 text-right">{name}</p>
|
||||
<p class="text-white font-semibold">{value}</p>
|
||||
<p class="mr-4 text-right text-orange-300">{name}</p>
|
||||
<p class="font-semibold text-white">{value}</p>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ pub mod pages {
|
||||
pub mod wall;
|
||||
}
|
||||
pub mod components {
|
||||
pub use attempt::Attempt;
|
||||
pub use button::Button;
|
||||
pub use header::StyledHeader;
|
||||
pub use problem::Problem;
|
||||
|
||||
@@ -49,7 +49,7 @@ pub fn EditWall() -> impl IntoView {
|
||||
};
|
||||
|
||||
leptos::view! {
|
||||
<div class="min-w-screen min-h-screen bg-slate-900">
|
||||
<div class="min-h-screen min-w-screen bg-slate-900">
|
||||
<StyledHeader items=Signal::derive(header_items) />
|
||||
|
||||
<div class="container mx-auto mt-2">
|
||||
@@ -155,7 +155,7 @@ fn Hold(wall_uid: models::WallUid, hold: models::Hold) -> impl IntoView {
|
||||
|
||||
view! {
|
||||
<button on:click=open_camera>
|
||||
<div class="bg-indigo-100 aspect-square rounded">{img}</div>
|
||||
<div class="bg-indigo-100 rounded aspect-square">{img}</div>
|
||||
</button>
|
||||
|
||||
<input
|
||||
|
||||
@@ -65,7 +65,7 @@ pub fn Routes() -> impl IntoView {
|
||||
children=move |problem: models::Problem| {
|
||||
view! {
|
||||
<Problem dim=wall_dimensions problem />
|
||||
<hr class="h-px my-8 border-0 bg-gray-700" />
|
||||
<hr class="my-8 h-px bg-gray-700 border-0" />
|
||||
}
|
||||
}
|
||||
/>
|
||||
@@ -78,7 +78,7 @@ pub fn Routes() -> impl IntoView {
|
||||
};
|
||||
|
||||
view! {
|
||||
<div class="min-w-screen min-h-screen bg-neutral-950">
|
||||
<div class="min-h-screen min-w-screen bg-neutral-950">
|
||||
<StyledHeader items=Signal::derive(header_items) />
|
||||
|
||||
<div class="container mx-auto mt-6">
|
||||
|
||||
@@ -20,11 +20,11 @@ pub fn Settings() -> impl IntoView {
|
||||
};
|
||||
|
||||
view! {
|
||||
<div class="min-w-screen min-h-screen bg-neutral-950">
|
||||
<div class="min-h-screen min-w-screen bg-neutral-950">
|
||||
<StyledHeader items=header_items />
|
||||
|
||||
// {move || view! { <Import wall_uid=wall_uid.get() /> }}
|
||||
<div class="container mx-auto mt-2"></div>
|
||||
<div class="container mx-auto mt-2" />
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ pub fn Wall() -> impl IntoView {
|
||||
};
|
||||
|
||||
leptos::view! {
|
||||
<div class="min-w-screen min-h-screen bg-neutral-950">
|
||||
<div class="min-h-screen min-w-screen bg-neutral-950">
|
||||
<StyledHeader items=Signal::derive(header_items) />
|
||||
|
||||
<div class="m-2">
|
||||
@@ -137,14 +137,14 @@ pub fn Wall() -> impl IntoView {
|
||||
}
|
||||
};
|
||||
let v = view! {
|
||||
<div class="grid grid-cols-1 md:grid-cols-[auto,1fr] gap-8">
|
||||
<div class="grid grid-cols-1 gap-8 md:grid-cols-[auto,1fr]">
|
||||
<div>{grid}</div>
|
||||
|
||||
<div>
|
||||
<Button
|
||||
icon=|| view! { <icons::ForwardSolid /> }
|
||||
text=|| Some("Next problem".to_string())
|
||||
onclick=move |_| fn_next_problem(&wall)
|
||||
// TODO: use forward icon
|
||||
text="➤ Next problem"
|
||||
/>
|
||||
|
||||
<div class="m-4" />
|
||||
@@ -162,7 +162,7 @@ pub fn Wall() -> impl IntoView {
|
||||
|
||||
<div class="m-4" />
|
||||
|
||||
<div class="relative inline-flex items-center justify-center p-0.5 mb-2 me-2 overflow-hidden text-sm font-medium rounded-lg group bg-gradient-to-br from-cyan-500 to-blue-500 text-white hover:brightness-125">
|
||||
<div class="inline-flex overflow-hidden relative justify-center items-center p-0.5 mb-2 text-sm font-medium text-white bg-gradient-to-br from-cyan-500 to-blue-500 rounded-lg me-2 group hover:brightness-125">
|
||||
<input
|
||||
type="checkbox"
|
||||
id="flash-option"
|
||||
@@ -173,10 +173,10 @@ pub fn Wall() -> impl IntoView {
|
||||
/>
|
||||
<label for="flash-option" class="cursor-pointer">
|
||||
<div
|
||||
class="flex items-center gap-2 relative px-5 py-3.5 transition-all ease-in duration-75 bg-gray-900 rounded-md"
|
||||
class="flex relative gap-2 items-center py-3.5 px-5 bg-gray-900 rounded-md transition-all duration-75 ease-in"
|
||||
class:bg-transparent=move || ui_is_flash.get()
|
||||
>
|
||||
<div class="aspect-square rounded-sm ring-offset-gray-700 bg-white border-gray-500 text-white">
|
||||
<div class="text-white bg-white rounded-sm border-gray-500 ring-offset-gray-700 aspect-square">
|
||||
<span class=("text-cyan-500", move || ui_is_flash.get())>
|
||||
<icons::Check />
|
||||
</span>
|
||||
@@ -187,7 +187,7 @@ pub fn Wall() -> impl IntoView {
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="relative inline-flex items-center justify-center p-0.5 mb-2 me-2 overflow-hidden text-sm font-medium rounded-lg group bg-gradient-to-br from-teal-300 to-lime-300 text-white hover:brightness-125">
|
||||
<div class="inline-flex overflow-hidden relative justify-center items-center p-0.5 mb-2 text-sm font-medium text-white bg-gradient-to-br from-teal-300 to-lime-300 rounded-lg me-2 group hover:brightness-125">
|
||||
<input
|
||||
type="checkbox"
|
||||
id="climbed-option"
|
||||
@@ -198,10 +198,10 @@ pub fn Wall() -> impl IntoView {
|
||||
/>
|
||||
<label for="climbed-option" class="cursor-pointer">
|
||||
<div
|
||||
class="flex items-center gap-2 relative px-5 py-3.5 transition-all ease-in duration-75 bg-gray-900 rounded-md text-white"
|
||||
class="flex relative gap-2 items-center py-3.5 px-5 text-white bg-gray-900 rounded-md transition-all duration-75 ease-in"
|
||||
class:bg-transparent=move || ui_is_climbed.get()
|
||||
>
|
||||
<div class="aspect-square rounded-sm ring-offset-gray-700 bg-white border-gray-500">
|
||||
<div class="bg-white rounded-sm border-gray-500 ring-offset-gray-700 aspect-square">
|
||||
<span class=("text-black", move || ui_is_climbed.get())>
|
||||
<icons::Check />
|
||||
</span>
|
||||
@@ -216,7 +216,7 @@ pub fn Wall() -> impl IntoView {
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="relative inline-flex items-center justify-center p-0.5 mb-2 me-2 overflow-hidden text-sm font-medium rounded-lg group bg-gradient-to-br from-pink-500 to-orange-400 text-white hover:brightness-125">
|
||||
<div class="inline-flex overflow-hidden relative justify-center items-center p-0.5 mb-2 text-sm font-medium text-white bg-gradient-to-br from-pink-500 to-orange-400 rounded-lg me-2 group hover:brightness-125">
|
||||
<input
|
||||
type="checkbox"
|
||||
id="favorite-option"
|
||||
@@ -227,10 +227,10 @@ pub fn Wall() -> impl IntoView {
|
||||
/>
|
||||
<label for="favorite-option" class="cursor-pointer">
|
||||
<div
|
||||
class="flex items-center gap-2 relative px-5 py-3.5 transition-all ease-in duration-75 bg-gray-900 rounded-md"
|
||||
class="flex relative gap-2 items-center py-3.5 px-5 bg-gray-900 rounded-md transition-all duration-75 ease-in"
|
||||
class:bg-transparent=move || ui_is_favorite.get()
|
||||
>
|
||||
<div class="aspect-square rounded-sm ring-offset-gray-700 border-gray-500 text-pink-500">
|
||||
<div class="text-pink-500 rounded-sm border-gray-500 ring-offset-gray-700 aspect-square">
|
||||
<span class=("text-white", move || ui_is_favorite.get())>
|
||||
<icons::HeartOutline />
|
||||
</span>
|
||||
|
||||
@@ -60,10 +60,11 @@ impl Database {
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub async fn set_version(&self, version: Version) -> Result<(), DatabaseOperationError> {
|
||||
self.write(|txn| {
|
||||
let mut table = txn.open_table(TABLE_VERSION)?;
|
||||
table.insert((), version)?;
|
||||
Ok(())
|
||||
}).await
|
||||
let mut table = txn.open_table(TABLE_VERSION)?;
|
||||
table.insert((), version)?;
|
||||
Ok(())
|
||||
})
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ pub async fn migrate_to_v3(db: &Database) -> Result<(), Box<dyn std::error::Erro
|
||||
})
|
||||
.await?;
|
||||
|
||||
db.set_version(db::Version {version: db::v3::VERSION}).await?;
|
||||
db.set_version(db::Version { version: db::v3::VERSION }).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
4
leptosfmt.toml
Normal file
4
leptosfmt.toml
Normal file
@@ -0,0 +1,4 @@
|
||||
closing_tag_style = "SelfClosing"
|
||||
|
||||
[attr_values]
|
||||
class = "Tailwind"
|
||||
@@ -1,4 +1,4 @@
|
||||
style_edition = "2024"
|
||||
edition = "2024"
|
||||
unstable_features = true
|
||||
imports_granularity = "Item"
|
||||
group_imports = "One"
|
||||
|
||||
Reference in New Issue
Block a user