✨ Add new components for page layout
This commit is contained in:
parent
b6b7d9687b
commit
36c931486d
9 changed files with 126 additions and 96 deletions
58
src/base/component/layout.rs
Normal file
58
src/base/component/layout.rs
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
#[derive(AutoDefault)]
|
||||
pub struct Layout;
|
||||
|
||||
impl ComponentTrait for Layout {
|
||||
fn new() -> Self {
|
||||
Layout
|
||||
}
|
||||
|
||||
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
|
||||
PrepareMarkup::With(match cx.layout() {
|
||||
"default" => Self::default_layout(cx),
|
||||
"admin" => Self::admin_layout(cx),
|
||||
_ => Self::default_layout(cx),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Layout {
|
||||
fn default_layout(cx: &mut Context) -> Markup {
|
||||
flex::Container::new()
|
||||
.with_id("body__wrapper")
|
||||
.with_direction(flex::Direction::Column(BreakPoint::None))
|
||||
.with_items_align(flex::ItemAlign::Center)
|
||||
.add_item(flex::Item::full(Region::named("header")).with_id("header"))
|
||||
.add_item(flex::Item::full(Region::named("pagetop")).with_id("pagetop"))
|
||||
.add_item(flex::Item::full(
|
||||
flex::Container::new()
|
||||
.with_id("content__wrapper")
|
||||
.with_direction(flex::Direction::Row(BreakPoint::None))
|
||||
.add_item(
|
||||
flex::Item::with(Region::named("sidebar_left"))
|
||||
.with_id("sidebar_left")
|
||||
.with_grow(flex::ItemGrow::Is1),
|
||||
)
|
||||
.add_item(
|
||||
flex::Item::with(Region::named("content"))
|
||||
.with_id("content")
|
||||
.with_grow(flex::ItemGrow::Is3),
|
||||
)
|
||||
.add_item(
|
||||
flex::Item::with(Region::named("sidebar_right"))
|
||||
.with_id("sidebar_right")
|
||||
.with_grow(flex::ItemGrow::Is1),
|
||||
),
|
||||
))
|
||||
.add_item(flex::Item::full(Region::named("footer")).with_id("footer"))
|
||||
.render(cx)
|
||||
}
|
||||
|
||||
fn admin_layout(cx: &mut Context) -> Markup {
|
||||
Html::with(html! {
|
||||
("admin")
|
||||
})
|
||||
.render(cx)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue