From 08e742f8bb544fca40150a1bb6c02af3cde9935a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asger=20Juul=20Brunsh=C3=B8j?= Date: Thu, 6 Feb 2025 22:48:45 +0100 Subject: [PATCH] wip --- crates/ascend/src/components/header.rs | 20 ++++++++++++-------- crates/ascend/src/pages/wall.rs | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/crates/ascend/src/components/header.rs b/crates/ascend/src/components/header.rs index ff5a9ab..7ef2d58 100644 --- a/crates/ascend/src/components/header.rs +++ b/crates/ascend/src/components/header.rs @@ -1,11 +1,13 @@ use leptos::prelude::*; +#[derive(Debug, Clone)] pub struct HeaderItems { pub left: Vec, pub middle: Vec, pub right: Vec, } +#[derive(Debug, Clone)] pub struct HeaderItem { pub text: String, pub link: Option, @@ -13,7 +15,7 @@ pub struct HeaderItem { /// Header with background color etc. #[component] -pub fn StyledHeader(items: HeaderItems) -> impl IntoView { +pub fn StyledHeader(#[prop(into)] items: Signal) -> impl IntoView { view! {
//
@@ -25,32 +27,34 @@ pub fn StyledHeader(items: HeaderItems) -> impl IntoView { /// Function header without styling #[component] -pub fn Header(items: HeaderItems) -> impl IntoView { - let HeaderItems { left, middle, right } = items; +pub fn Header(#[prop(into)] items: Signal) -> impl IntoView { + let left = move || items.read().left.clone(); + let middle = move || items.read().middle.clone(); + let right = move || items.read().right.clone(); view! {
// Left side of header
- +
// Expanding space in the middle
- +
// Right side of header
- +
} } #[component] -fn Items(items: Vec) -> impl IntoView { - let items = items.into_iter().map(|item| view! { }).collect_view(); +fn Items(#[prop(into)] items: Signal>) -> impl IntoView { + let items = move || items.get().into_iter().map(|item| view! { }).collect_view(); view! {
{items}
} } diff --git a/crates/ascend/src/pages/wall.rs b/crates/ascend/src/pages/wall.rs index 57ca411..5094b9f 100644 --- a/crates/ascend/src/pages/wall.rs +++ b/crates/ascend/src/pages/wall.rs @@ -58,7 +58,7 @@ pub fn Wall() -> impl leptos::IntoView { leptos::view! {
- +