This commit is contained in:
parent
b8ed8da199
commit
696b34f2f1
4 changed files with 669 additions and 2 deletions
|
@ -3,12 +3,13 @@ use std::sync::Arc;
|
|||
use maud::{PreEscaped, Render, html};
|
||||
|
||||
use crate::{
|
||||
ogp::Metadata,
|
||||
request::{RequestContext, StringResponse},
|
||||
ui::{
|
||||
UIWidget,
|
||||
color::{Gray, UIColor},
|
||||
htmx::{Event, HTMXAttributes, Selector, SwapStrategy},
|
||||
prelude::{Div, Link},
|
||||
prelude::{Div, Link, Optional},
|
||||
primitives::link::LinkWidget,
|
||||
},
|
||||
};
|
||||
|
@ -25,6 +26,7 @@ pub struct Shell {
|
|||
/// The HTML content for the static body portion.
|
||||
body_content: Arc<PreEscaped<String>>,
|
||||
ui: bool,
|
||||
metadata: Option<Metadata>,
|
||||
bottom_nav: Option<Arc<PreEscaped<String>>>,
|
||||
sidebar: Option<Arc<SidebarWidget>>,
|
||||
navbar: Option<Arc<NavBarWidget>>,
|
||||
|
@ -51,6 +53,7 @@ impl Shell {
|
|||
main_class: Arc::new(body_class.extended_class().join(" ")),
|
||||
body_content: Arc::new(body_content.render()),
|
||||
ui: false,
|
||||
metadata: None,
|
||||
bottom_nav: None,
|
||||
sidebar: None,
|
||||
navbar: None,
|
||||
|
@ -69,6 +72,11 @@ impl Shell {
|
|||
self.clone()
|
||||
}
|
||||
|
||||
pub fn metadata(mut self, metadata: Metadata) -> Self {
|
||||
self.metadata = Some(metadata);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_navbar(mut self, navbar: NavBarWidget) -> Self {
|
||||
self.navbar = Some(Arc::new(navbar));
|
||||
self
|
||||
|
@ -123,6 +131,7 @@ impl Shell {
|
|||
meta name="viewport" content="width=device-width, initial-scale=1.0";
|
||||
};
|
||||
(self.head)
|
||||
(Optional(self.metadata.as_ref(), |meta| meta.render()))
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue