✨ Add OptionId value to page body
This commit is contained in:
parent
d66063a1f7
commit
ae030b5889
3 changed files with 15 additions and 3 deletions
|
|
@ -35,7 +35,7 @@ impl ThemeTrait for Bootsier {
|
||||||
fn prepare_body(&self, page: &mut Page) -> Markup {
|
fn prepare_body(&self, page: &mut Page) -> Markup {
|
||||||
match page.template() {
|
match page.template() {
|
||||||
"admin" => html! {
|
"admin" => html! {
|
||||||
body class=[page.body_classes().get()] {
|
body id=[page.body_id().get()] class=[page.body_classes().get()] {
|
||||||
@for region in &[
|
@for region in &[
|
||||||
"top-menu",
|
"top-menu",
|
||||||
"side-menu",
|
"side-menu",
|
||||||
|
|
@ -46,7 +46,7 @@ impl ThemeTrait for Bootsier {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => html! {
|
_ => html! {
|
||||||
body class=[page.body_classes().get()] {
|
body id=[page.body_id().get()] class=[page.body_classes().get()] {
|
||||||
(self.prepare_region(page, "header"))
|
(self.prepare_region(page, "header"))
|
||||||
(self.prepare_region(page, "nav_branding"))
|
(self.prepare_region(page, "nav_branding"))
|
||||||
(self.prepare_region(page, "nav_main"))
|
(self.prepare_region(page, "nav_main"))
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ pub trait ThemeTrait: PackageTrait + Send + Sync {
|
||||||
let skip_to = concat_string!("#", page.skip_to().get().unwrap_or("content".to_owned()));
|
let skip_to = concat_string!("#", page.skip_to().get().unwrap_or("content".to_owned()));
|
||||||
|
|
||||||
html! {
|
html! {
|
||||||
body class=[page.body_classes().get()] {
|
body id=[page.body_id().get()] class=[page.body_classes().get()] {
|
||||||
@if let Some(skip) = L10n::l("skip_to_content").using(page.context().langid()) {
|
@if let Some(skip) = L10n::l("skip_to_content").using(page.context().langid()) {
|
||||||
div class="pt-body__skip" {
|
div class="pt-body__skip" {
|
||||||
a href=(skip_to) { (skip) }
|
a href=(skip_to) { (skip) }
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ pub struct Page {
|
||||||
properties : Vec<(&'static str, &'static str)>,
|
properties : Vec<(&'static str, &'static str)>,
|
||||||
favicon : Option<Favicon>,
|
favicon : Option<Favicon>,
|
||||||
context : Context,
|
context : Context,
|
||||||
|
body_id : OptionId,
|
||||||
body_classes: OptionClasses,
|
body_classes: OptionClasses,
|
||||||
skip_to : OptionId,
|
skip_to : OptionId,
|
||||||
regions : ComponentsInRegions,
|
regions : ComponentsInRegions,
|
||||||
|
|
@ -38,6 +39,7 @@ impl Page {
|
||||||
properties : Vec::default(),
|
properties : Vec::default(),
|
||||||
favicon : None,
|
favicon : None,
|
||||||
context : Context::new(request),
|
context : Context::new(request),
|
||||||
|
body_id : OptionId::default(),
|
||||||
body_classes: OptionClasses::default(),
|
body_classes: OptionClasses::default(),
|
||||||
skip_to : OptionId::default(),
|
skip_to : OptionId::default(),
|
||||||
regions : ComponentsInRegions::default(),
|
regions : ComponentsInRegions::default(),
|
||||||
|
|
@ -83,6 +85,12 @@ impl Page {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[fn_with]
|
||||||
|
pub fn alter_body_id(&mut self, id: impl Into<String>) -> &mut Self {
|
||||||
|
self.body_id.alter_value(id);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
#[fn_with]
|
#[fn_with]
|
||||||
pub fn alter_body_classes(&mut self, op: ClassesOp, classes: impl Into<String>) -> &mut Self {
|
pub fn alter_body_classes(&mut self, op: ClassesOp, classes: impl Into<String>) -> &mut Self {
|
||||||
self.body_classes.alter_value(op, classes);
|
self.body_classes.alter_value(op, classes);
|
||||||
|
|
@ -138,6 +146,10 @@ impl Page {
|
||||||
&mut self.context
|
&mut self.context
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn body_id(&self) -> &OptionId {
|
||||||
|
&self.body_id
|
||||||
|
}
|
||||||
|
|
||||||
pub fn body_classes(&self) -> &OptionClasses {
|
pub fn body_classes(&self) -> &OptionClasses {
|
||||||
&self.body_classes
|
&self.body_classes
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue