From 24fd30af8bf4fd345c0dde5a3c3fefd54c7175ac Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Tue, 28 Jun 2022 20:29:09 -0400 Subject: [PATCH] Basic page structure no routing --- web/src/app_state.rs | 1 + web/src/pages/mod.rs | 2 ++ web/src/pages/recipe.rs | 34 ++++++++++++++++++++++++++++++++++ web/src/web.rs | 3 +++ 4 files changed, 40 insertions(+) create mode 100644 web/src/pages/recipe.rs diff --git a/web/src/app_state.rs b/web/src/app_state.rs index 0277446..94d3886 100644 --- a/web/src/app_state.rs +++ b/web/src/app_state.rs @@ -17,4 +17,5 @@ pub enum AppRoutes { Plan, Inventory, Cook, + Recipe(usize), } diff --git a/web/src/pages/mod.rs b/web/src/pages/mod.rs index d8f49f1..e65eb54 100644 --- a/web/src/pages/mod.rs +++ b/web/src/pages/mod.rs @@ -18,10 +18,12 @@ use crate::app_state::AppRoutes; mod cook; mod inventory; mod plan; +mod recipe; pub use cook::*; pub use inventory::*; pub use plan::*; +pub use recipe::*; #[derive(Clone)] pub struct PageState { diff --git a/web/src/pages/recipe.rs b/web/src/pages/recipe.rs new file mode 100644 index 0000000..4db9511 --- /dev/null +++ b/web/src/pages/recipe.rs @@ -0,0 +1,34 @@ +// Copyright 2022 Jeremy Wall (jeremy@marzhillstudios.com) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +use crate::components::{recipe::Recipe, tabs::*}; +use crate::pages::PageState; + +use sycamore::prelude::*; + +pub struct RecipePageProps { + pub page_state: PageState, + pub recipe: Signal, +} + +#[component(RecipePage)] +pub fn recipe_page(props: RecipePageProps) -> View { + view! { + TabbedView(TabState { + route: props.page_state.route.clone(), + inner: view! { + Recipe(props.recipe.handle()) + } + }) + } +} diff --git a/web/src/web.rs b/web/src/web.rs index cf13435..c761d1e 100644 --- a/web/src/web.rs +++ b/web/src/web.rs @@ -35,6 +35,9 @@ fn route_switch(page_state: PageState) -> View { AppRoutes::Cook => view! { CookPage(CookPageProps { page_state: page_state.clone() }) }, + AppRoutes::Recipe(idx) => view! { + RecipePage(RecipePageProps { page_state: page_state.clone(), recipe: Signal::new(*idx) }) + } }) }) }