diff --git a/Cargo.lock b/Cargo.lock
index 4cbdbca..be6f70f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -108,6 +108,7 @@ dependencies = [
"leptos_meta",
"leptos_router",
"moonboard-parser",
+ "rand",
"ron",
"serde",
"serde_json",
diff --git a/crates/ascend/Cargo.toml b/crates/ascend/Cargo.toml
index e270c63..1e35fec 100644
--- a/crates/ascend/Cargo.toml
+++ b/crates/ascend/Cargo.toml
@@ -32,6 +32,7 @@ tracing-subscriber = { version = "0.3.18", features = [
"env-filter",
], optional = true }
ron = { version = "0.8" }
+rand = { version = "0.8", optional = true }
[dev-dependencies.serde_json]
version = "1"
@@ -41,6 +42,7 @@ hydrate = ["leptos/hydrate"]
ssr = [
"dep:axum",
"dep:tokio",
+ "dep:rand",
"dep:tower",
"dep:tower-http",
"dep:leptos_axum",
diff --git a/crates/ascend/src/app.rs b/crates/ascend/src/app.rs
index 48f290f..7266370 100644
--- a/crates/ascend/src/app.rs
+++ b/crates/ascend/src/app.rs
@@ -1,4 +1,8 @@
+use crate::pages::edit_wall::EditWall;
+use crate::pages::wall::Wall;
use leptos::prelude::*;
+use leptos_router::components::*;
+use leptos_router::path;
pub fn shell(options: LeptosOptions) -> impl IntoView {
use leptos_meta::MetaTags;
@@ -13,7 +17,7 @@ pub fn shell(options: LeptosOptions) -> impl IntoView {
-
+
@@ -35,18 +39,20 @@ pub fn App() -> impl leptos::IntoView {
leptos::view! {
- // sets the document title
-
-
-
+
+ //
+
+
+
+
+
+
+
}
}
-
-#[component]
-fn Ascend() -> impl leptos::IntoView {
- use crate::pages::wall::Wall;
-
- leptos::view! { }
-}
diff --git a/crates/ascend/src/components/header.rs b/crates/ascend/src/components/header.rs
new file mode 100644
index 0000000..ef7d7fd
--- /dev/null
+++ b/crates/ascend/src/components/header.rs
@@ -0,0 +1,6 @@
+use leptos::prelude::*;
+
+#[component]
+pub fn Header() -> impl leptos::IntoView {
+ leptos::view! { "header"
}
+}
diff --git a/crates/ascend/src/lib.rs b/crates/ascend/src/lib.rs
index 0b8f363..57573fb 100644
--- a/crates/ascend/src/lib.rs
+++ b/crates/ascend/src/lib.rs
@@ -1,8 +1,11 @@
pub mod app;
pub mod pages {
+ pub mod edit_wall;
pub mod wall;
}
-pub mod components {}
+pub mod components {
+ pub mod header;
+}
pub mod codec;
diff --git a/crates/ascend/src/pages/edit_wall.rs b/crates/ascend/src/pages/edit_wall.rs
new file mode 100644
index 0000000..0407cc1
--- /dev/null
+++ b/crates/ascend/src/pages/edit_wall.rs
@@ -0,0 +1,69 @@
+use crate::components::header::Header;
+use crate::models::HoldPosition;
+use crate::models::HoldRole;
+use crate::models::Wall;
+use leptos::prelude::*;
+use serde::Deserialize;
+use serde::Serialize;
+
+#[component]
+pub fn EditWall() -> impl leptos::IntoView {
+ let load = async move {
+ // TODO: What to do about this unwrap?
+ load_initial_data().await.unwrap()
+ };
+
+ leptos::view! {
+
+ }
+}
+
+#[component]
+fn Ready(data: InitialData) -> impl leptos::IntoView {
+ leptos::logging::log!("ready");
+ let mut hold_positions = vec![];
+ for row in 0..(data.wall.rows) {
+ for col in 0..(data.wall.cols) {
+ hold_positions.push(HoldPosition { row, col });
+ }
+ }
+
+ let mut cells = vec![];
+ for &_hold_position in &hold_positions {
+ let cell = view! { };
+ cells.push(cell);
+ }
+
+ let grid_classes = format!("grid grid-rows-{} grid-cols-{} gap-4", data.wall.rows, data.wall.cols);
+
+ view! {
+ {cells}
+ }
+}
+
+#[component]
+fn Hold() -> impl leptos::IntoView {
+ view! { }
+}
+
+#[derive(Serialize, Deserialize, Clone)]
+pub struct InitialData {
+ wall: Wall,
+}
+
+#[server]
+async fn load_initial_data() -> Result {
+ use crate::server::state::State;
+
+ let state = expect_context::();
+
+ let wall = state.persistent.with(|s| s.wall.clone()).await;
+ Ok(InitialData { wall })
+}
diff --git a/crates/ascend/src/pages/wall.rs b/crates/ascend/src/pages/wall.rs
index 3db1d3f..cfed857 100644
--- a/crates/ascend/src/pages/wall.rs
+++ b/crates/ascend/src/pages/wall.rs
@@ -1,8 +1,10 @@
use crate::codec::ron::RonCodec;
+use crate::components::header::Header;
use crate::models;
use crate::models::HoldPosition;
use crate::models::HoldRole;
use leptos::prelude::*;
+use leptos::reactive::graph::ReactiveNode;
use serde::Deserialize;
use serde::Serialize;
@@ -14,14 +16,19 @@ pub fn Wall() -> impl leptos::IntoView {
};
leptos::view! {
-
-
-
+
}
}
#[component]
-fn WallReady(data: InitialData) -> impl leptos::IntoView {
+fn Ready(data: InitialData) -> impl leptos::IntoView {
let mut hold_positions = vec![];
for row in 0..(data.wall.rows) {
for col in 0..(data.wall.cols) {
@@ -30,7 +37,7 @@ fn WallReady(data: InitialData) -> impl leptos::IntoView {
}
let (current_problem, current_problem_writer) = signal(None::);
- LocalResource::new(move || async move {
+ let problem_fetcher = LocalResource::new(move || async move {
leptos::logging::log!("Loading random problem");
let problem = get_random_problem().await.expect("cannot get random problem");
current_problem_writer.set(Some(problem.into_inner()));
@@ -38,40 +45,32 @@ fn WallReady(data: InitialData) -> impl leptos::IntoView {
let mut cells = vec![];
for &hold_position in &hold_positions {
- let role = move || {
- let x = current_problem
- .get()
- .map(|problem| {
- let role = problem.holds.get(&hold_position)?;
- // leptos::logging::log!("{hold_position:?}: {role:?}");
- Some(*role)
- })
- .flatten();
- x
- };
+ let role = move || current_problem.get().map(|problem| problem.holds.get(&hold_position).copied()).flatten();
let role = Signal::derive(role);
- let cell = view! { | };
+ let cell = view! { };
cells.push(cell);
}
+ let grid_classes = format!("grid grid-rows-{} grid-cols-{} gap-4", data.wall.rows, data.wall.cols);
+
view! {
-
+ {cells}
+
}
}
#[component]
-fn Cell(#[prop(into)] role: Signal