use simi::prelude::*; pub struct MessagePanel<'a> { pub message: &'a String, } impl Component for MessagePanel<'_> { fn render(&self, context: RenderContext) { component! { "Message: " self.message } } } pub struct ValueDisplay { pub value: i32, } impl Component for ValueDisplay { fn render(&self, context: RenderContext) { component! { "Value: " self.value } } } pub struct Counter<'a, A: Application> { pub id: &'static str, pub title: &'static str, pub value: &'a i32, pub up: ElementEventHandler, pub down: ElementEventHandler, } impl Component for Counter<'_, A> { fn render(&self, context: RenderContext) { component! { div (id=#self.id) { p { #self.title self.value } button (class="down" onclick=#self.down) { "Down" } button (class="up" onclick=#self.up) { "Up" } } } } } pub struct ParentComponent<'a, A: Application> { pub child1: Box + 'a>, pub child2: Box + 'a>, } impl Component for ParentComponent<'_, A> { fn render(&self, context: RenderContext) { component! { $ self.child1 $ self.child2 } } }