use maud::{Markup, Render, html}; use super::UIWidget; #[allow(non_snake_case)] /// A component for fixing an element's width to the current breakpoint. pub fn Container(inner: T) -> ContainerWidget { ContainerWidget(Box::new(inner)) } pub struct ContainerWidget(Box); impl Render for ContainerWidget { fn render(&self) -> Markup { self.render_with_class("") } } impl UIWidget for ContainerWidget { 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!("container {class}")) } else { html! { div class=(format!("container {class}")) { (self.0.as_ref()) } } } } }