diff --git a/pagetop-megamenu/src/component/item.rs b/pagetop-megamenu/src/component/item.rs index 7a4a5236..00038b4a 100644 --- a/pagetop-megamenu/src/component/item.rs +++ b/pagetop-megamenu/src/component/item.rs @@ -7,15 +7,13 @@ new_handle!(COMPONENT_MEGAITEM); type Label = OneComponent; type Content = OneComponent; -pub type MegaItemPath = fn(cx: &Context) -> &str; - #[derive(Default)] pub enum MegaItemType { #[default] Void, Label(Label), - Link(Label, MegaItemPath), - LinkBlank(Label, MegaItemPath), + Link(Label, ContextualPath), + LinkBlank(Label, ContextualPath), Html(Content), Submenu(Label, MegaMenu), Separator, @@ -86,14 +84,14 @@ impl MegaItem { } } - pub fn link(label: L10n, path: MegaItemPath) -> Self { + pub fn link(label: L10n, path: ContextualPath) -> Self { MegaItem { item_type: MegaItemType::Link(Label::with(label), path), ..Default::default() } } - pub fn link_blank(label: L10n, path: MegaItemPath) -> Self { + pub fn link_blank(label: L10n, path: ContextualPath) -> Self { MegaItem { item_type: MegaItemType::LinkBlank(Label::with(label), path), ..Default::default() diff --git a/pagetop-megamenu/src/lib.rs b/pagetop-megamenu/src/lib.rs index fc75fa9f..356e27ab 100644 --- a/pagetop-megamenu/src/lib.rs +++ b/pagetop-megamenu/src/lib.rs @@ -2,7 +2,7 @@ use pagetop::prelude::*; pub mod component { mod item; - pub use item::{MegaItem, MegaItemPath, MegaItemType, COMPONENT_MEGAITEM}; + pub use item::{MegaItem, MegaItemType, COMPONENT_MEGAITEM}; mod menu; pub use menu::{MegaMenu, COMPONENT_MEGAMENU}; } diff --git a/pagetop-minimal/src/component.rs b/pagetop-minimal/src/component.rs index 0d0c1311..3cbae79f 100644 --- a/pagetop-minimal/src/component.rs +++ b/pagetop-minimal/src/component.rs @@ -17,8 +17,8 @@ mod block; pub use block::{Block, COMPONENT_BLOCK}; mod site_branding; pub use site_branding::{SiteBranding, COMPONENT_BRANDING}; -mod poweredby; -pub use poweredby::{PoweredBy, PoweredByLogo, COMPONENT_POWEREDBY}; +mod powered_by; +pub use powered_by::{PoweredBy, PoweredByLogo, COMPONENT_POWEREDBY}; pub mod form_element; pub use form_element::{Form, FormMethod, COMPONENT_FORM}; diff --git a/pagetop-minimal/src/component/poweredby.rs b/pagetop-minimal/src/component/powered_by.rs similarity index 99% rename from pagetop-minimal/src/component/poweredby.rs rename to pagetop-minimal/src/component/powered_by.rs index e4867834..63eeb0bb 100644 --- a/pagetop-minimal/src/component/poweredby.rs +++ b/pagetop-minimal/src/component/powered_by.rs @@ -38,7 +38,7 @@ impl ComponentTrait for PoweredBy { } fn id(&self) -> Option { - Some("poweredby".to_owned()) + Some("powered-by".to_owned()) } fn weight(&self) -> Weight { diff --git a/pagetop-minimal/src/component/site_branding.rs b/pagetop-minimal/src/component/site_branding.rs index fbe10ac6..82f5838e 100644 --- a/pagetop-minimal/src/component/site_branding.rs +++ b/pagetop-minimal/src/component/site_branding.rs @@ -10,21 +10,32 @@ type SiteSlogan = OneComponent; type SiteLogo = OneComponent; #[rustfmt::skip] -#[derive(Default)] pub struct SiteBranding { weight : Weight, renderable: Renderable, name : String, slogan : SiteSlogan, logo : SiteLogo, + frontpage : ContextualPath, +} + +#[rustfmt::skip] +impl Default for SiteBranding { + fn default() -> Self { + SiteBranding { + weight : Weight::default(), + renderable: Renderable::default(), + name : config::SETTINGS.app.name.to_owned(), + slogan : SiteSlogan::default(), + logo : SiteLogo::default(), + frontpage : |_| "/", + } + } } impl ComponentTrait for SiteBranding { fn new() -> Self { - SiteBranding { - name: config::SETTINGS.app.name.to_owned(), - ..Default::default() - } + SiteBranding::default() } fn handle(&self) -> Handle { @@ -58,7 +69,7 @@ impl ComponentTrait for SiteBranding { } div class="site-branding-text" { div class="site-branding-name" { - a href="/" title=(title) rel="home" { (self.name()) } + a href=(self.frontpage()(cx)) title=(title) rel="home" { (self.name()) } } @if !slogan.is_empty() { div class="site-branding-slogan" { @@ -105,6 +116,12 @@ impl SiteBranding { self } + #[fn_builder] + pub fn alter_frontpage(&mut self, frontpage: ContextualPath) -> &mut Self { + self.frontpage = frontpage; + self + } + // SiteBranding GETTERS. pub fn name(&self) -> &String { @@ -118,4 +135,8 @@ impl SiteBranding { pub fn logo(&self) -> &SiteLogo { &self.logo } + + pub fn frontpage(&self) -> &ContextualPath { + &self.frontpage + } } diff --git a/pagetop-minimal/static/css/minimal.css b/pagetop-minimal/static/css/minimal.css index 8f674cbf..9c6df304 100644 --- a/pagetop-minimal/static/css/minimal.css +++ b/pagetop-minimal/static/css/minimal.css @@ -1,9 +1,44 @@ +/* SiteBranding component */ +#site-branding { + float: left; +} +.site-branding-wrapper { + position: relative; +} +.site-branding-logo { + display: none; +} +.site-branding-text { + display: inline-block; + margin: 10px 0 0 10px; +} +.site-branding-slogan { + display: none; +} +@media (min-width: 768px) { + #site-branding { + display: inline-block; + } + .site-branding-logo { + display: inline-block; + margin: 10px 0 0 10px; + } + .site-branding-text { + position: absolute; + width: max-content; + bottom: 0; + } + .site-branding-slogan { + display: block; + } +} + /* PoweredBy component */ -#poweredby { +#powered-by { text-align: center; } -#poweredby .pagetop-logo img, -#poweredby .pagetop-logo svg { +#powered-by .pagetop-logo img, +#powered-by .pagetop-logo svg { margin-left: .275em; height: 1.275em; vertical-align: middle; diff --git a/pagetop/src/core/component.rs b/pagetop/src/core/component.rs index 833aa16c..a4573f1d 100644 --- a/pagetop/src/core/component.rs +++ b/pagetop/src/core/component.rs @@ -1,5 +1,6 @@ mod context; pub use context::{Context, ContextOp}; +pub type ContextualPath = fn(cx: &Context) -> &str; mod definition; pub use definition::{component_mut, component_ref, ComponentBase, ComponentTrait};