update
This commit is contained in:
parent
8208fa8899
commit
ed739d792f
35 changed files with 1675 additions and 447 deletions
40
src/ui/primitives/header.rs
Normal file
40
src/ui/primitives/header.rs
Normal file
|
@ -0,0 +1,40 @@
|
|||
use maud::{Markup, Render, html};
|
||||
|
||||
use crate::ui::UIWidget;
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn Header<T: UIWidget + 'static>(inner: T) -> HeaderWidget {
|
||||
HeaderWidget(Box::new(inner))
|
||||
}
|
||||
|
||||
pub struct HeaderWidget(Box<dyn UIWidget>);
|
||||
|
||||
impl Render for HeaderWidget {
|
||||
fn render(&self) -> Markup {
|
||||
self.render_with_class("")
|
||||
}
|
||||
}
|
||||
|
||||
impl UIWidget for HeaderWidget {
|
||||
fn can_inherit(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn base_class(&self) -> Vec<String> {
|
||||
vec![]
|
||||
}
|
||||
|
||||
fn extended_class(&self) -> Vec<String> {
|
||||
let mut c = self.base_class();
|
||||
c.extend_from_slice(&self.0.extended_class());
|
||||
c
|
||||
}
|
||||
|
||||
fn render_with_class(&self, class: &str) -> Markup {
|
||||
html! {
|
||||
header class=(class) {
|
||||
(self.0.as_ref())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue