diff --git a/pagetop/Cargo.toml b/pagetop/Cargo.toml index 01eb60ec..8598de96 100644 --- a/pagetop/Cargo.toml +++ b/pagetop/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pagetop" -version = "0.0.5" +version = "0.0.6" edition = "2021" authors = [ diff --git a/pagetop/src/base/component/block.rs b/pagetop/src/base/component/block.rs index 976c27bc..fdf9922d 100644 --- a/pagetop/src/base/component/block.rs +++ b/pagetop/src/base/component/block.rs @@ -3,9 +3,10 @@ use crate::prelude::*; pub struct Block { renderable: fn() -> bool, weight : i8, - id : OptIden, title : OptAttr, html : Vec, + id : OptIden, + classes : Classes, template : String, } @@ -15,9 +16,10 @@ impl PageComponent for Block { Block { renderable: always, weight : 0, - id : OptIden::none(), title : OptAttr::none(), html : Vec::new(), + id : OptIden::none(), + classes : Classes::none(), template : "default".to_owned(), } } @@ -33,7 +35,7 @@ impl PageComponent for Block { fn default_render(&self, assets: &mut PageAssets) -> Markup { let id = assets.serial_id(self.name(), self.id()); html! { - div id=(id) class="block" { + div id=(id) class=[self.classes("block")] { @match self.title() { Some(title) => h2 class="block-title" { (title) }, None => {} @@ -66,11 +68,6 @@ impl Block { self } - pub fn with_id(mut self, id: &str) -> Self { - self.id.with_value(id); - self - } - pub fn with_title(mut self, title: &str) -> Self { self.title.with_value(title); self @@ -81,6 +78,21 @@ impl Block { self } + pub fn with_id(mut self, id: &str) -> Self { + self.id.with_value(id); + self + } + + pub fn set_classes(mut self, classes: &str) -> Self { + self.classes.set_classes(classes); + self + } + + pub fn add_classes(mut self, classes: &str) -> Self { + self.classes.add_classes(classes); + self + } + pub fn using_template(mut self, template: &str) -> Self { self.template = template.to_owned(); self @@ -88,10 +100,6 @@ impl Block { // Block GETTERS. - pub fn id(&self) -> &Option { - self.id.option() - } - pub fn title(&self) -> &Option { self.title.option() } @@ -100,6 +108,14 @@ impl Block { &self.html } + pub fn id(&self) -> &Option { + self.id.option() + } + + pub fn classes(&self, default: &str) -> Option { + self.classes.option(default) + } + pub fn template(&self) -> &str { self.template.as_str() } diff --git a/pagetop/src/base/component/container.rs b/pagetop/src/base/component/container.rs index cba905d6..94003ae0 100644 --- a/pagetop/src/base/component/container.rs +++ b/pagetop/src/base/component/container.rs @@ -6,8 +6,9 @@ pub struct Container { renderable: fn() -> bool, weight : i8, container : ContainerType, - id : OptIden, components: PageContainer, + id : OptIden, + classes : Classes, template : String, } @@ -18,8 +19,9 @@ impl PageComponent for Container { renderable: always, weight : 0, container : ContainerType::Wrapper, - id : OptIden::none(), components: PageContainer::new(), + id : OptIden::none(), + classes : Classes::none(), template : "default".to_owned(), } } @@ -35,35 +37,35 @@ impl PageComponent for Container { fn default_render(&self, assets: &mut PageAssets) -> Markup { match self.container_type() { ContainerType::Header => html! { - header id=[self.id()] class="header" { + header id=[self.id()] class=[self.classes("header")] { div class="container" { (self.render_components(assets)) } } }, ContainerType::Footer => html! { - footer id=[self.id()] class="footer" { + footer id=[self.id()] class=[self.classes("footer")] { div class="container" { (self.render_components(assets)) } } }, ContainerType::Main => html! { - main id=[self.id()] class="main" { + main id=[self.id()] class=[self.classes("main")] { div class="container" { (self.render_components(assets)) } } }, ContainerType::Section => html! { - section id=[self.id()] class="section" { + section id=[self.id()] class=[self.classes("section")] { div class="container" { (self.render_components(assets)) } } }, _ => html! { - div id=[self.id()] class="container" { + div id=[self.id()] class=[self.classes("container")] { (self.render_components(assets)) } } @@ -109,13 +111,23 @@ impl Container { self } + pub fn add(mut self, component: impl PageComponent) -> Self { + self.components.add(component); + self + } + pub fn with_id(mut self, id: &str) -> Self { self.id.with_value(id); self } - pub fn add(mut self, component: impl PageComponent) -> Self { - self.components.add(component); + pub fn set_classes(mut self, classes: &str) -> Self { + self.classes.set_classes(classes); + self + } + + pub fn add_classes(mut self, classes: &str) -> Self { + self.classes.add_classes(classes); self } @@ -134,6 +146,10 @@ impl Container { self.id.option() } + pub fn classes(&self, default: &str) -> Option { + self.classes.option(default) + } + pub fn template(&self) -> &str { self.template.as_str() } diff --git a/pagetop/src/base/component/form/button.rs b/pagetop/src/base/component/form/button.rs index fbe25738..b2f59609 100644 --- a/pagetop/src/base/component/form/button.rs +++ b/pagetop/src/base/component/form/button.rs @@ -10,6 +10,7 @@ pub struct Button { value : OptAttr, autofocus : OptAttr, disabled : OptAttr, + classes : Classes, template : String, } @@ -24,6 +25,7 @@ impl PageComponent for Button { value : OptAttr::none(), autofocus : OptAttr::none(), disabled : OptAttr::none(), + classes : Classes::none(), template : "default".to_owned(), } } @@ -50,7 +52,7 @@ impl PageComponent for Button { button type=(button_type) id=[id] - class=(button_class) + class=[self.classes(button_class)] name=[self.name()] value=[self.value()] autofocus=[self.autofocus()] @@ -121,6 +123,16 @@ impl Button { self } + pub fn set_classes(mut self, classes: &str) -> Self { + self.classes.set_classes(classes); + self + } + + pub fn add_classes(mut self, classes: &str) -> Self { + self.classes.add_classes(classes); + self + } + pub fn using_template(mut self, template: &str) -> Self { self.template = template.to_owned(); self @@ -148,6 +160,10 @@ impl Button { self.disabled.option() } + pub fn classes(&self, default: &str) -> Option { + self.classes.option(default) + } + pub fn template(&self) -> &str { self.template.as_str() } diff --git a/pagetop/src/base/component/form/date.rs b/pagetop/src/base/component/form/date.rs index 906f5bbc..f1270a82 100644 --- a/pagetop/src/base/component/form/date.rs +++ b/pagetop/src/base/component/form/date.rs @@ -13,6 +13,7 @@ pub struct Date { readonly : OptAttr, required : OptAttr, help_text : OptAttr, + classes : Classes, template : String, } @@ -32,6 +33,7 @@ impl PageComponent for Date { readonly : OptAttr::none(), required : OptAttr::none(), help_text : OptAttr::none(), + classes : Classes::none(), template : "default".to_owned(), } } @@ -45,7 +47,7 @@ impl PageComponent for Date { } fn default_render(&self, _: &mut PageAssets) -> Markup { - let (class, id) = match self.name() { + let (classes, id) = match self.name() { Some(name) => ( concat_string!("form-item form-item-", name, " form-type-date"), Some(concat_string!("edit-", name)) @@ -56,7 +58,7 @@ impl PageComponent for Date { ) }; html! { - div class=(class) { + div class=[self.classes(classes.as_str())] { @match self.label() { Some(label) => label class="form-label" for=[&id] { (label) " " @@ -169,6 +171,16 @@ impl Date { self } + pub fn set_classes(mut self, classes: &str) -> Self { + self.classes.set_classes(classes); + self + } + + pub fn add_classes(mut self, classes: &str) -> Self { + self.classes.add_classes(classes); + self + } + pub fn using_template(mut self, template: &str) -> Self { self.template = template.to_owned(); self @@ -216,6 +228,10 @@ impl Date { self.help_text.option() } + pub fn classes(&self, default: &str) -> Option { + self.classes.option(default) + } + pub fn template(&self) -> &str { self.template.as_str() } diff --git a/pagetop/src/base/component/form/form.rs b/pagetop/src/base/component/form/form.rs index 5ecea5e0..c4d8e206 100644 --- a/pagetop/src/base/component/form/form.rs +++ b/pagetop/src/base/component/form/form.rs @@ -5,11 +5,12 @@ pub enum FormMethod {Get, Post} pub struct Form { renderable: fn() -> bool, weight : i8, - id : OptIden, action : OptAttr, charset : OptAttr, method : FormMethod, elements : PageContainer, + id : OptIden, + classes : Classes, template : String, } @@ -19,11 +20,12 @@ impl PageComponent for Form { Form { renderable: always, weight : 0, - id : OptIden::none(), action : OptAttr::none(), charset : OptAttr::some("UTF-8"), method : FormMethod::Post, elements : PageContainer::new(), + id : OptIden::none(), + classes : Classes::none(), template : "default".to_owned(), } } @@ -44,6 +46,7 @@ impl PageComponent for Form { html! { form id=[self.id()] + class=[self.classes("form")] action=[self.action()] method=[method] accept-charset=[self.charset()] @@ -70,11 +73,6 @@ impl Form { self } - pub fn with_id(mut self, id: &str) -> Self { - self.id.with_value(id); - self - } - pub fn with_action(mut self, action: &str) -> Self { self.action.with_value(action); self @@ -95,6 +93,21 @@ impl Form { self } + pub fn with_id(mut self, id: &str) -> Self { + self.id.with_value(id); + self + } + + pub fn set_classes(mut self, classes: &str) -> Self { + self.classes.set_classes(classes); + self + } + + pub fn add_classes(mut self, classes: &str) -> Self { + self.classes.add_classes(classes); + self + } + pub fn using_template(mut self, template: &str) -> Self { self.template = template.to_owned(); self @@ -102,10 +115,6 @@ impl Form { // Form GETTERS. - pub fn id(&self) -> &Option { - self.id.option() - } - pub fn action(&self) -> &Option { self.action.option() } @@ -118,6 +127,14 @@ impl Form { &self.method } + pub fn id(&self) -> &Option { + self.id.option() + } + + pub fn classes(&self, default: &str) -> Option { + self.classes.option(default) + } + pub fn template(&self) -> &str { self.template.as_str() } diff --git a/pagetop/src/base/component/form/input.rs b/pagetop/src/base/component/form/input.rs index 7dded20f..2e1af61d 100644 --- a/pagetop/src/base/component/form/input.rs +++ b/pagetop/src/base/component/form/input.rs @@ -19,6 +19,7 @@ pub struct Input { readonly : OptAttr, required : OptAttr, help_text : OptAttr, + classes : Classes, template : String, } @@ -42,6 +43,7 @@ impl PageComponent for Input { readonly : OptAttr::none(), required : OptAttr::none(), help_text : OptAttr::none(), + classes : Classes::none(), template : "default".to_owned(), } } @@ -239,6 +241,16 @@ impl Input { self } + pub fn set_classes(mut self, classes: &str) -> Self { + self.classes.set_classes(classes); + self + } + + pub fn add_classes(mut self, classes: &str) -> Self { + self.classes.add_classes(classes); + self + } + pub fn using_template(mut self, template: &str) -> Self { self.template = template.to_owned(); self @@ -302,6 +314,10 @@ impl Input { self.help_text.option() } + pub fn classes(&self, default: &str) -> Option { + self.classes.option(default) + } + pub fn template(&self) -> &str { self.template.as_str() } diff --git a/pagetop/src/base/component/grid/column.rs b/pagetop/src/base/component/grid/column.rs index 6d3a7b19..f5bc4669 100644 --- a/pagetop/src/base/component/grid/column.rs +++ b/pagetop/src/base/component/grid/column.rs @@ -3,9 +3,9 @@ use crate::prelude::*; pub struct Column { renderable: fn() -> bool, weight : i8, + components: PageContainer, id : OptIden, classes : Classes, - components: PageContainer, template : String, } @@ -15,13 +15,17 @@ impl PageComponent for Column { Column { renderable: always, weight : 0, - id : OptIden::none(), - classes : Classes::some(vec!["col"]), components: PageContainer::new(), + id : OptIden::none(), + classes : Classes::none(), template : "default".to_owned(), } } + fn name(&self) -> &'static str { + "GridColumn" + } + fn is_renderable(&self) -> bool { (self.renderable)() } @@ -32,7 +36,7 @@ impl PageComponent for Column { fn default_render(&self, assets: &mut PageAssets) -> Markup { html! { - div id=[self.id()] class=[self.classes()] { + div id=[self.id()] class=[self.classes("col")] { (self.render_components(assets)) } } @@ -53,18 +57,23 @@ impl Column { self } + pub fn add(mut self, component: impl PageComponent) -> Self { + self.components.add(component); + self + } + pub fn with_id(mut self, id: &str) -> Self { self.id.with_value(id); self } - pub fn add_classes(mut self, classes: Vec<&str>) -> Self { - self.classes.add_classes(classes); + pub fn set_classes(mut self, classes: &str) -> Self { + self.classes.set_classes(classes); self } - pub fn add(mut self, component: impl PageComponent) -> Self { - self.components.add(component); + pub fn add_classes(mut self, classes: &str) -> Self { + self.classes.add_classes(classes); self } @@ -79,8 +88,8 @@ impl Column { self.id.option() } - pub fn classes(&self) -> &Option { - self.classes.option() + pub fn classes(&self, default: &str) -> Option { + self.classes.option(default) } pub fn template(&self) -> &str { diff --git a/pagetop/src/base/component/grid/row.rs b/pagetop/src/base/component/grid/row.rs index b1bb2c24..8437c1fe 100644 --- a/pagetop/src/base/component/grid/row.rs +++ b/pagetop/src/base/component/grid/row.rs @@ -3,9 +3,9 @@ use crate::prelude::*; pub struct Row { renderable: fn() -> bool, weight : i8, + columns : PageContainer, id : OptIden, classes : Classes, - columns : PageContainer, template : String, } @@ -15,13 +15,17 @@ impl PageComponent for Row { Row { renderable: always, weight : 0, - id : OptIden::none(), - classes : Classes::some(vec!["row"]), columns : PageContainer::new(), + id : OptIden::none(), + classes : Classes::none(), template : "default".to_owned(), } } + fn name(&self) -> &'static str { + "GridRow" + } + fn is_renderable(&self) -> bool { (self.renderable)() } @@ -32,7 +36,7 @@ impl PageComponent for Row { fn default_render(&self, assets: &mut PageAssets) -> Markup { html! { - div id=[self.id()] class=[self.classes()] { + div id=[self.id()] class=[self.classes("row")] { (self.render_columns(assets)) } } @@ -53,18 +57,23 @@ impl Row { self } + pub fn add_column(mut self, column: grid::Column) -> Self { + self.columns.add(column); + self + } + pub fn with_id(mut self, id: &str) -> Self { self.id.with_value(id); self } - pub fn add_classes(mut self, classes: Vec<&str>) -> Self { - self.classes.add_classes(classes); + pub fn set_classes(mut self, classes: &str) -> Self { + self.classes.set_classes(classes); self } - pub fn add_column(mut self, column: grid::Column) -> Self { - self.columns.add(column); + pub fn add_classes(mut self, classes: &str) -> Self { + self.classes.add_classes(classes); self } @@ -79,8 +88,8 @@ impl Row { self.id.option() } - pub fn classes(&self) -> &Option { - self.classes.option() + pub fn classes(&self, default: &str) -> Option { + self.classes.option(default) } pub fn template(&self) -> &str { diff --git a/pagetop/src/base/component/image.rs b/pagetop/src/base/component/image.rs index 799aab63..c324782a 100644 --- a/pagetop/src/base/component/image.rs +++ b/pagetop/src/base/component/image.rs @@ -4,6 +4,8 @@ pub struct Image { renderable: fn() -> bool, weight : i8, source : OptAttr, + id : OptIden, + classes : Classes, template : String, } @@ -14,6 +16,8 @@ impl PageComponent for Image { renderable: always, weight : 0, source : OptAttr::none(), + id : OptIden::none(), + classes : Classes::none(), template : "default".to_owned(), } } @@ -28,7 +32,10 @@ impl PageComponent for Image { fn default_render(&self, _: &mut PageAssets) -> Markup { html! { - img src=[self.source()] class="img-fluid"; + img + src=[self.source()] + id=[self.id()] + class=[self.classes("img-fluid")]; } } } @@ -56,6 +63,21 @@ impl Image { self } + pub fn with_id(mut self, id: &str) -> Self { + self.id.with_value(id); + self + } + + pub fn set_classes(mut self, classes: &str) -> Self { + self.classes.set_classes(classes); + self + } + + pub fn add_classes(mut self, classes: &str) -> Self { + self.classes.add_classes(classes); + self + } + pub fn using_template(mut self, template: &str) -> Self { self.template = template.to_owned(); self @@ -67,6 +89,14 @@ impl Image { self.source.option() } + pub fn id(&self) -> &Option { + self.id.option() + } + + pub fn classes(&self, default: &str) -> Option { + self.classes.option(default) + } + pub fn template(&self) -> &str { self.template.as_str() } diff --git a/pagetop/src/base/component/menu.rs b/pagetop/src/base/component/menu.rs index 253cd3d8..91881908 100644 --- a/pagetop/src/base/component/menu.rs +++ b/pagetop/src/base/component/menu.rs @@ -155,8 +155,9 @@ impl MenuItem { pub struct Menu { renderable: fn() -> bool, weight : i8, - id : OptIden, items : PageContainer, + id : OptIden, + classes : Classes, template : String, } @@ -166,8 +167,9 @@ impl PageComponent for Menu { Menu { renderable: always, weight : 0, - id : OptIden::none(), items : PageContainer::new(), + id : OptIden::none(), + classes : Classes::none(), template : "default".to_owned(), } } @@ -195,7 +197,7 @@ impl PageComponent for Menu { let id = assets.serial_id(self.name(), self.id()); html! { - ul id=(id) class="sm sm-clean" { + ul id=(id) class=[self.classes("sm sm-clean")] { (self.render_items(assets)) } script type="text/javascript" defer { @@ -222,13 +224,23 @@ impl Menu { self } + pub fn add(mut self, item: MenuItem) -> Self { + self.items.add(item); + self + } + pub fn with_id(mut self, id: &str) -> Self { self.id.with_value(id); self } - pub fn add(mut self, item: MenuItem) -> Self { - self.items.add(item); + pub fn set_classes(mut self, classes: &str) -> Self { + self.classes.set_classes(classes); + self + } + + pub fn add_classes(mut self, classes: &str) -> Self { + self.classes.add_classes(classes); self } @@ -243,6 +255,10 @@ impl Menu { self.id.option() } + pub fn classes(&self, default: &str) -> Option { + self.classes.option(default) + } + pub fn template(&self) -> &str { self.template.as_str() } diff --git a/pagetop/src/base/theme/bulmix/mod.rs b/pagetop/src/base/theme/bulmix/mod.rs index b8d57ba7..0e8a4d9b 100644 --- a/pagetop/src/base/theme/bulmix/mod.rs +++ b/pagetop/src/base/theme/bulmix/mod.rs @@ -31,4 +31,30 @@ impl ThemeTrait for BulmixTheme { ) .add_jquery(); } + + fn render_component( + &self, + component: &dyn PageComponent, + assets: &mut PageAssets + ) -> Option { + match component.name() { + "GridRow" => { + let row = component.downcast_ref::().unwrap(); + Some(html! { + div id=[row.id()] class=[row.classes("columns")] { + (row.render_columns(assets)) + } + }) + }, + "GridColumn" => { + let col = component.downcast_ref::().unwrap(); + Some(html! { + div id=[col.id()] class=[col.classes("column")] { + (col.render_components(assets)) + } + }) + }, + _ => None + } + } } diff --git a/pagetop/src/html/classes.rs b/pagetop/src/html/classes.rs index c2a35984..6c41aafb 100644 --- a/pagetop/src/html/classes.rs +++ b/pagetop/src/html/classes.rs @@ -1,48 +1,23 @@ use crate::concat_string; -pub struct Classes(Option); +pub struct Classes(String); impl Classes { pub fn none() -> Self { - Classes(None) + Classes("".to_owned()) } - pub fn some(classes: Vec<&str>) -> Self { - let mut c = Classes::none(); - c.add_classes(classes); - c + pub fn set_classes(&mut self, classes: &str) -> &mut Self { + self.0 = classes.to_owned(); + self } - pub fn add_classes(&mut self, classes: Vec<&str>) { - for class in classes.iter() { - self.add_class(class); - } + pub fn add_classes(&mut self, classes: &str) -> &mut Self { + self.0 = concat_string!(self.0, " ", classes).trim().to_owned(); + self } - fn add_class(&mut self, class: &str) { - let class = class.trim().replace(" ", "_"); - if !class.is_empty() { - match &self.0 { - None => self.0 = Some(class), - Some(classes) => if !classes.split(" ").any(|c| *c == class) { - self.0 = Some(concat_string!(classes, " ", class)) - } - } - } - } - - pub fn classes(&self) -> &str { - match &self.0 { - Some(classes) => classes.as_str(), - None => "", - } - } - - pub fn has_classes(&self) -> bool { - self.0 != None - } - - pub fn option(&self) -> &Option { - &self.0 + pub fn option(&self, default: &str) -> Option { + Some(concat_string!(default.to_owned(), " ", self.0).trim().to_owned()) } } diff --git a/pagetop/src/html/optattr.rs b/pagetop/src/html/optattr.rs index a76f33b7..d009e32e 100644 --- a/pagetop/src/html/optattr.rs +++ b/pagetop/src/html/optattr.rs @@ -6,17 +6,18 @@ impl OptAttr { } pub fn some(value: &str) -> Self { - let mut o = OptAttr::none(); + let mut o = OptAttr(None); o.with_value(value); o } - pub fn with_value(&mut self, value: &str) { + pub fn with_value(&mut self, value: &str) -> &mut Self { let value = value.trim(); self.0 = match value.is_empty() { true => None, false => Some(value.to_owned()), }; + self } pub fn option(&self) -> &Option { diff --git a/pagetop/src/html/optiden.rs b/pagetop/src/html/optiden.rs index ec46acf1..52a65c10 100644 --- a/pagetop/src/html/optiden.rs +++ b/pagetop/src/html/optiden.rs @@ -6,17 +6,18 @@ impl OptIden { } pub fn some(id: &str) -> Self { - let mut o = OptIden::none(); + let mut o = OptIden(None); o.with_value(id); o } - pub fn with_value(&mut self, id: &str) { + pub fn with_value(&mut self, id: &str) -> &mut Self { let id = id.trim(); self.0 = match id.is_empty() { true => None, false => Some(id.replace(" ", "_")), }; + self } pub fn option(&self) -> &Option { diff --git a/pagetop/src/response/page/page.rs b/pagetop/src/response/page/page.rs index 50ff3040..cb561626 100644 --- a/pagetop/src/response/page/page.rs +++ b/pagetop/src/response/page/page.rs @@ -45,8 +45,8 @@ pub struct Page<'a> { title : OptAttr, description : OptAttr, assets : PageAssets, - body_classes: Classes, regions : HashMap<&'a str, PageContainer>, + body_classes: Classes, template : String, } @@ -64,9 +64,9 @@ impl<'a> Page<'a> { }, title : OptAttr::none(), description : OptAttr::none(), - body_classes: Classes::some(vec!["body"]), assets : PageAssets::new(), regions : COMPONENTS.read().unwrap().clone(), + body_classes: Classes::none(), template : "default".to_owned(), } } @@ -97,11 +97,6 @@ impl<'a> Page<'a> { self } - pub fn add_body_classes(&mut self, classes: Vec<&str>) -> &mut Self { - self.body_classes.add_classes(classes); - self - } - pub fn add_to( &mut self, region: &'a str, @@ -115,6 +110,16 @@ impl<'a> Page<'a> { self } + pub fn set_body_classes(&mut self, classes: &str) -> &mut Self { + self.body_classes.set_classes(classes); + self + } + + pub fn add_body_classes(&mut self, classes: &str) -> &mut Self { + self.body_classes.add_classes(classes); + self + } + pub fn using_template(&mut self, template: &str) -> &mut Self { self.template = template.to_owned(); self @@ -138,14 +143,14 @@ impl<'a> Page<'a> { self.description.option() } - pub fn body_classes(&mut self) -> &str { - self.body_classes.classes() - } - pub fn assets(&mut self) -> &mut PageAssets { &mut self.assets } + pub fn body_classes(&self, default: &str) -> Option { + self.body_classes.option(default) + } + pub fn template(&self) -> &str { self.template.as_str() } diff --git a/pagetop/src/theme/definition.rs b/pagetop/src/theme/definition.rs index 51b1d4c8..acc30f47 100644 --- a/pagetop/src/theme/definition.rs +++ b/pagetop/src/theme/definition.rs @@ -55,7 +55,7 @@ pub trait ThemeTrait: Send + Sync { fn render_page_body(&self, page: &mut Page) -> Markup { html! { - body class=(page.body_classes()) { + body class=[page.body_classes("body")] { @match page.template() { "admin" => { @for region in &["top-menu", "side-menu", "content"] { @@ -85,8 +85,8 @@ pub trait ThemeTrait: Send + Sync { Cómo usarlo: match component.name() { - "block" => { - let block = component.downcast_mut::().unwrap(); + "Block" => { + let block = component.downcast_ref::().unwrap(); match block.template() { "default" => Some(block_default(block)), _ => None