This commit is contained in:
30
src/components/layout.rs
Normal file
30
src/components/layout.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
use sycamore::prelude::*;
|
||||
|
||||
#[component]
|
||||
pub fn Layout<'a, G: Html>(
|
||||
cx: Scope<'a>,
|
||||
LayoutProps { title, children }: LayoutProps<'a, G>,
|
||||
) -> View<G> {
|
||||
let children = children.call(cx);
|
||||
|
||||
view! { cx,
|
||||
// These elements are styled with bright colors for demonstration purposes
|
||||
header(style = "background-color: red; color: white; padding: 1rem") {
|
||||
p { (title.to_string()) }
|
||||
}
|
||||
main(style = "padding: 1rem") {
|
||||
(children)
|
||||
}
|
||||
footer(style = "background-color: black; color: white; padding: 1rem") {
|
||||
p { "Hey there, I'm a footer!" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Prop)]
|
||||
pub struct LayoutProps<'a, G: Html> {
|
||||
/// The title of the page, which will be displayed in the header.
|
||||
pub title: &'a str,
|
||||
/// The content to put inside the layout.
|
||||
pub children: Children<'a, G>,
|
||||
}
|
||||
1
src/components/mod.rs
Normal file
1
src/components/mod.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub mod layout;
|
||||
Reference in New Issue
Block a user