✨ 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 {
|
||||
match page.template() {
|
||||
"admin" => html! {
|
||||
body class=[page.body_classes().get()] {
|
||||
body id=[page.body_id().get()] class=[page.body_classes().get()] {
|
||||
@for region in &[
|
||||
"top-menu",
|
||||
"side-menu",
|
||||
|
|
@ -46,7 +46,7 @@ impl ThemeTrait for Bootsier {
|
|||
}
|
||||
},
|
||||
_ => 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, "nav_branding"))
|
||||
(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()));
|
||||
|
||||
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()) {
|
||||
div class="pt-body__skip" {
|
||||
a href=(skip_to) { (skip) }
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ pub struct Page {
|
|||
properties : Vec<(&'static str, &'static str)>,
|
||||
favicon : Option<Favicon>,
|
||||
context : Context,
|
||||
body_id : OptionId,
|
||||
body_classes: OptionClasses,
|
||||
skip_to : OptionId,
|
||||
regions : ComponentsInRegions,
|
||||
|
|
@ -38,6 +39,7 @@ impl Page {
|
|||
properties : Vec::default(),
|
||||
favicon : None,
|
||||
context : Context::new(request),
|
||||
body_id : OptionId::default(),
|
||||
body_classes: OptionClasses::default(),
|
||||
skip_to : OptionId::default(),
|
||||
regions : ComponentsInRegions::default(),
|
||||
|
|
@ -83,6 +85,12 @@ impl Page {
|
|||
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]
|
||||
pub fn alter_body_classes(&mut self, op: ClassesOp, classes: impl Into<String>) -> &mut Self {
|
||||
self.body_classes.alter_value(op, classes);
|
||||
|
|
@ -138,6 +146,10 @@ impl Page {
|
|||
&mut self.context
|
||||
}
|
||||
|
||||
pub fn body_id(&self) -> &OptionId {
|
||||
&self.body_id
|
||||
}
|
||||
|
||||
pub fn body_classes(&self) -> &OptionClasses {
|
||||
&self.body_classes
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue