✨ Add new components for page layout
This commit is contained in:
parent
b6b7d9687b
commit
36c931486d
9 changed files with 126 additions and 96 deletions
|
|
@ -13,6 +13,7 @@ use std::str::FromStr;
|
|||
pub enum AssetsOp {
|
||||
LangId(&'static LanguageIdentifier),
|
||||
Theme(&'static str),
|
||||
Layout(&'static str),
|
||||
// Stylesheets.
|
||||
AddStyleSheet(StyleSheet),
|
||||
RemoveStyleSheet(&'static str),
|
||||
|
|
@ -34,6 +35,7 @@ pub struct Context {
|
|||
request : HttpRequest,
|
||||
langid : &'static LanguageIdentifier,
|
||||
theme : ThemeRef,
|
||||
layout : &'static str,
|
||||
stylesheet: Assets<StyleSheet>, // Stylesheets.
|
||||
headstyles: Assets<HeadStyles>, // Styles in head.
|
||||
javascript: Assets<JavaScript>, // JavaScripts.
|
||||
|
|
@ -50,6 +52,7 @@ impl Context {
|
|||
request,
|
||||
langid : &LANGID_DEFAULT,
|
||||
theme : *THEME_DEFAULT,
|
||||
layout : "default",
|
||||
stylesheet: Assets::<StyleSheet>::new(), // Stylesheets.
|
||||
headstyles: Assets::<HeadStyles>::new(), // Styles in head.
|
||||
javascript: Assets::<JavaScript>::new(), // JavaScripts.
|
||||
|
|
@ -69,6 +72,9 @@ impl Context {
|
|||
AssetsOp::Theme(theme_name) => {
|
||||
self.theme = theme_by_single_name(theme_name).unwrap_or(*THEME_DEFAULT);
|
||||
}
|
||||
AssetsOp::Layout(layout) => {
|
||||
self.layout = layout;
|
||||
}
|
||||
|
||||
// Stylesheets.
|
||||
AssetsOp::AddStyleSheet(css) => { self.stylesheet.add(css); }
|
||||
|
|
@ -118,6 +124,10 @@ impl Context {
|
|||
self.theme
|
||||
}
|
||||
|
||||
pub fn layout(&self) -> &str {
|
||||
self.layout
|
||||
}
|
||||
|
||||
pub fn regions(&self) -> &ComponentsInRegions {
|
||||
&self.regions
|
||||
}
|
||||
|
|
@ -142,6 +152,10 @@ impl Context {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn prepare_region(&mut self, region: &str) -> Markup {
|
||||
self.regions.all_components(self.theme, region).render(self)
|
||||
}
|
||||
|
||||
// Context EXTRAS.
|
||||
|
||||
pub fn required_id<T>(&mut self, id: Option<String>) -> String {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue