35 lines
896 B
Rust
35 lines
896 B
Rust
use super::UIWidget;
|
|
use maud::{Markup, Render, html};
|
|
|
|
#[allow(non_snake_case)]
|
|
pub fn Sized<T: UIWidget + 'static>(height: u32, width: u32, inner: T) -> SizedWidget {
|
|
SizedWidget(Box::new(inner), height, width)
|
|
}
|
|
|
|
pub struct SizedWidget(Box<dyn UIWidget>, u32, u32);
|
|
|
|
impl Render for SizedWidget {
|
|
fn render(&self) -> Markup {
|
|
self.render_with_class("")
|
|
}
|
|
}
|
|
|
|
impl UIWidget for SizedWidget {
|
|
fn can_inherit(&self) -> bool {
|
|
true
|
|
}
|
|
|
|
fn render_with_class(&self, class: &str) -> Markup {
|
|
if self.0.as_ref().can_inherit() {
|
|
self.0
|
|
.as_ref()
|
|
.render_with_class(&format!("h-{} w-{} {class}", self.1, self.2))
|
|
} else {
|
|
html! {
|
|
div class=(format!("h-{} w-{} {class}", self.1, self.2)) {
|
|
(self.0.as_ref())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|