🚧 Working on regions layout

This commit is contained in:
Manuel Cillero 2024-03-28 23:17:15 +01:00
parent 625d16c0f2
commit ee5742e0b2
11 changed files with 264 additions and 220 deletions

View file

@ -1,10 +1,10 @@
use crate::base::component::*;
use crate::core::component::{ComponentBase, ComponentClassesOp, ComponentTrait};
use crate::config;
use crate::core::component::{ComponentBase, ComponentTrait};
use crate::core::package::PackageTrait;
use crate::html::{html, ClassesOp, Favicon, Markup};
use crate::html::{html, Favicon, Markup};
use crate::locale::L10n;
use crate::response::page::Page;
use crate::{concat_string, config};
pub type ThemeRef = &'static dyn ThemeTrait;
@ -26,51 +26,38 @@ pub trait ThemeTrait: PackageTrait + Send + Sync {
fn before_prepare_body(&self, page: &mut Page) {}
fn prepare_body(&self, page: &mut Page) -> Markup {
let skip_to_id = concat_string!("#", page.skip_to().get().unwrap_or("content".to_owned()));
flex::Container::body()
.with_id(page.body_id().get().unwrap_or_default())
.with_classes(ClassesOp::Add, page.body_classes().get().unwrap_or_default())
.add_item(flex::Item::bundle()
.add_component(Html::with(html! {
@if let Some(skip) = L10n::l("skip_to_content").using(page.context().langid()) {
div class="skip__to_content" {
a href=(skip_to_id) { (skip) }
}
}
}))
.add_component(flex::Container::new()
.with_id("body__wrapper")
.with_direction(flex::Direction::Column(BreakPoint::None))
.with_align(flex::Align::Center)
.add_item(flex::Item::with(flex::Region::named("header")).with_id("header"))
.add_item(flex::Item::with(flex::Region::named("pagetop")).with_id("pagetop"))
.add_item(
flex::Item::with(
flex::Container::new()
.with_direction(flex::Direction::Row(BreakPoint::None))
.add_item(
flex::Item::with(flex::Region::named("sidebar_left"))
.with_id("sidebar_left")
.with_grow(flex::Grow::Is1),
)
.add_item(
flex::Item::with(flex::Region::named("content"))
.with_id("content")
.with_grow(flex::Grow::Is3),
)
.add_item(
flex::Item::with(flex::Region::named("sidebar_right"))
.with_id("sidebar_right")
.with_grow(flex::Grow::Is1),
),
)
.with_id("flex__wrapper"),
Body::with(
flex::Container::new()
.with_id("body__wrapper")
.with_direction(flex::Direction::Column(BreakPoint::None))
.with_align(flex::Align::Center)
.add_item(flex::Item::region().with_id("header"))
.add_item(flex::Item::region().with_id("pagetop"))
.add_item(
flex::Item::with(
flex::Container::new()
.with_direction(flex::Direction::Row(BreakPoint::None))
.add_item(
flex::Item::region()
.with_id("sidebar_left")
.with_grow(flex::Grow::Is1),
)
.add_item(
flex::Item::region()
.with_id("content")
.with_grow(flex::Grow::Is3),
)
.add_item(
flex::Item::region()
.with_id("sidebar_right")
.with_grow(flex::Grow::Is1),
),
)
.add_item(flex::Item::with(flex::Region::named("footer")).with_id("footer")),
.with_id("flex__wrapper"),
)
)
.render(page.context())
.add_item(flex::Item::region().with_id("footer")),
)
.render(page.context())
}
fn after_prepare_body(&self, page: &mut Page) {