🏗️ Use actions to decide component rendering

This commit is contained in:
Manuel Cillero 2024-04-15 02:06:39 +02:00
parent 45cb063e52
commit 7d4cf642ff
27 changed files with 125 additions and 304 deletions

View file

@ -5,10 +5,9 @@ use super::Item;
#[rustfmt::skip]
#[derive(AutoDefault)]
pub struct Submenu {
id : OptionId,
renderable: Renderable,
title : OptionTranslated,
items : MixedComponents,
id : OptionId,
title: OptionTranslated,
items: MixedComponents,
}
impl ComponentTrait for Submenu {
@ -20,10 +19,6 @@ impl ComponentTrait for Submenu {
self.id.get()
}
fn is_renderable(&self, cx: &Context) -> bool {
(self.renderable.check)(cx)
}
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
PrepareMarkup::With(html! {
div id=[self.id()] class="menu__items" {
@ -47,12 +42,6 @@ impl Submenu {
self
}
#[fn_builder]
pub fn alter_renderable(&mut self, check: FnIsRenderable) -> &mut Self {
self.renderable.check = check;
self
}
#[fn_builder]
pub fn alter_title(&mut self, title: L10n) -> &mut Self {
self.title.alter_value(title);