🔥 Remove body and region, not context-specific
This commit is contained in:
parent
ece78b2b4a
commit
2d906621de
6 changed files with 76 additions and 170 deletions
|
|
@ -5,7 +5,6 @@ use crate::core::theme::all::{theme_by_short_name, THEME_DEFAULT};
|
|||
use crate::core::theme::{ComponentsInRegions, ThemeRef};
|
||||
use crate::html::{html, Markup};
|
||||
use crate::html::{Assets, HeadScript, HeadStyles, JavaScript, StyleSheet};
|
||||
use crate::html::{ClassesOp, OptionClasses, OptionId};
|
||||
use crate::locale::{LanguageIdentifier, LANGID_DEFAULT};
|
||||
use crate::service::HttpRequest;
|
||||
use crate::util::TypeInfo;
|
||||
|
|
@ -43,9 +42,6 @@ pub struct Context {
|
|||
headstyles : Assets<HeadStyles>, // Styles in head.
|
||||
javascript : Assets<JavaScript>, // JavaScripts.
|
||||
headscript : Assets<HeadScript>, // Scripts in head.
|
||||
body_id : OptionId,
|
||||
body_classes: OptionClasses,
|
||||
body_skip_to: OptionId,
|
||||
regions : ComponentsInRegions,
|
||||
params : HashMap<&'static str, String>,
|
||||
id_counter : usize,
|
||||
|
|
@ -63,9 +59,6 @@ impl Context {
|
|||
headstyles : Assets::<HeadStyles>::new(), // Styles in head.
|
||||
javascript : Assets::<JavaScript>::new(), // JavaScripts.
|
||||
headscript : Assets::<HeadScript>::new(), // Scripts in head.
|
||||
body_id : OptionId::default(),
|
||||
body_classes: OptionClasses::default(),
|
||||
body_skip_to: OptionId::default(),
|
||||
regions : ComponentsInRegions::default(),
|
||||
params : HashMap::<&str, String>::new(),
|
||||
id_counter : 0,
|
||||
|
|
@ -104,21 +97,6 @@ impl Context {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn alter_body_id(&mut self, id: impl Into<String>) -> &mut Self {
|
||||
self.body_id.alter_value(id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_body_classes(&mut self, op: ClassesOp, classes: impl Into<String>) -> &mut Self {
|
||||
self.body_classes.alter_value(op, classes);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_body_skip_to(&mut self, id: impl Into<String>) -> &mut Self {
|
||||
self.body_skip_to.alter_value(id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn alter_regions(&mut self, region: &'static str, op: AnyOp) -> &mut Self {
|
||||
self.regions.alter_components(region, op);
|
||||
self
|
||||
|
|
@ -152,18 +130,6 @@ impl Context {
|
|||
self.layout
|
||||
}
|
||||
|
||||
pub fn body_id(&self) -> &OptionId {
|
||||
&self.body_id
|
||||
}
|
||||
|
||||
pub fn body_classes(&self) -> &OptionClasses {
|
||||
&self.body_classes
|
||||
}
|
||||
|
||||
pub fn body_skip_to(&self) -> &OptionId {
|
||||
&self.body_skip_to
|
||||
}
|
||||
|
||||
pub fn regions(&self) -> &ComponentsInRegions {
|
||||
&self.regions
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
use crate::base::component::*;
|
||||
use crate::config;
|
||||
use crate::core::component::{ComponentBase, ComponentTrait};
|
||||
use crate::core::package::PackageTrait;
|
||||
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,38 +26,47 @@ pub trait ThemeTrait: PackageTrait + Send + Sync {
|
|||
fn before_prepare_body(&self, page: &mut Page) {}
|
||||
|
||||
fn prepare_body(&self, page: &mut Page) -> Markup {
|
||||
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),
|
||||
),
|
||||
let skip_to_id = page.body_skip_to().get().unwrap_or("content".to_owned());
|
||||
|
||||
html! {
|
||||
body id=[page.body_id().get()] class=[page.body_classes().get()] {
|
||||
@if let Some(skip) = L10n::l("skip_to_content").using(page.context().langid()) {
|
||||
div class="skip__to_content" {
|
||||
a href=(concat_string!("#", skip_to_id)) { (skip) }
|
||||
}
|
||||
}
|
||||
(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),
|
||||
),
|
||||
)
|
||||
.with_id("flex__wrapper"),
|
||||
)
|
||||
.with_id("flex__wrapper"),
|
||||
)
|
||||
.add_item(flex::Item::region().with_id("footer")),
|
||||
)
|
||||
.render(page.context())
|
||||
.add_item(flex::Item::region().with_id("footer"))
|
||||
.render(page.context()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn after_prepare_body(&self, page: &mut Page) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue