From c9db5b3dd46aaf00c0b22d0c38b5e718070b7210 Mon Sep 17 00:00:00 2001
From: luoxiaozero <48741584+luoxiaozero@users.noreply.github.com>
Date: Mon, 25 Dec 2023 21:28:52 +0800
Subject: [PATCH] feat: add class param to layout component (#60)
---
demo/src/pages/layout/mod.rs | 60 ++++++++++++++++++++++++++++++------
src/layout/layout_header.rs | 4 ++-
src/layout/layout_sider.rs | 5 +--
src/layout/mod.rs | 14 +++++++--
4 files changed, 67 insertions(+), 16 deletions(-)
diff --git a/demo/src/pages/layout/mod.rs b/demo/src/pages/layout/mod.rs
index b0bb3ba..198f9c4 100644
--- a/demo/src/pages/layout/mod.rs
+++ b/demo/src/pages/layout/mod.rs
@@ -74,27 +74,51 @@ pub fn LayoutPage() -> impl IntoView {
"style" |
- "MaybeSignal" |
- "Default::default()" |
+
+ "MaybeSignal"
+ |
+
+ "Default::default()"
+ |
"Layout's style." |
"position" |
- "LayoutPosition" |
- "LayoutPosition::Static" |
+
+ "LayoutPosition"
+ |
+
+ "LayoutPosition::Static"
+ |
"static position will make it css position set to static. absolute position will make it css position set to absolute and left, right, top, bottom to 0. absolute position is very useful when you want to make content scroll in a fixed container or make the whole page's layout in a fixed position. You may need to change the style of the component to make it display as you expect."
|
"has_sider" |
- "MaybeSignal" |
- "false" |
+
+ "MaybeSignal"
+ |
+
+ "false"
+ |
"Whether the component has sider inside. If so it must be true." |
+
+ "class" |
+
+ "MaybeSignal"
+ |
+
+ "Default::default()"
+ |
+ "Addtional classes for the layout element." |
+
"children" |
- "Children" |
+
+ "Children"
+ |
|
"Layout's content." |
@@ -113,13 +137,29 @@ pub fn LayoutPage() -> impl IntoView {
"style" |
- "MaybeSignal" |
- "Default::default()" |
+
+ "MaybeSignal"
+ |
+
+ "Default::default()"
+ |
"LayoutHeader's style." |
+
+ "class" |
+
+ "MaybeSignal"
+ |
+
+ "Default::default()"
+ |
+ "Addtional classes for the layout header element." |
+
"children" |
- "Children" |
+
+ "Children"
+ |
|
"LayoutHeader's content." |
diff --git a/src/layout/layout_header.rs b/src/layout/layout_header.rs
index 3815abc..04ff82e 100644
--- a/src/layout/layout_header.rs
+++ b/src/layout/layout_header.rs
@@ -1,12 +1,14 @@
+use crate::utils::class_list::class_list;
use leptos::*;
#[component]
pub fn LayoutHeader(
+ #[prop(optional, into)] class: MaybeSignal,
#[prop(optional, into)] style: MaybeSignal,
children: Children,
) -> impl IntoView {
view! {
-