🏗️ 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

@ -3,12 +3,11 @@ use crate::prelude::*;
#[rustfmt::skip]
#[derive(AutoDefault, ComponentClasses)]
pub struct Block {
id : OptionId,
renderable: Renderable,
classes : OptionClasses,
style : StyleBase,
title : OptionTranslated,
mixed : MixedComponents,
id : OptionId,
classes: OptionClasses,
style : StyleBase,
title : OptionTranslated,
mixed : MixedComponents,
}
impl ComponentTrait for Block {
@ -20,10 +19,6 @@ impl ComponentTrait for Block {
self.id.get()
}
fn is_renderable(&self, cx: &Context) -> bool {
(self.renderable.check)(cx)
}
fn setup_before_prepare(&mut self, _cx: &mut Context) {
self.alter_classes(
ClassesOp::Prepend,
@ -60,12 +55,6 @@ impl Block {
self
}
#[fn_builder]
pub fn alter_renderable(&mut self, check: FnIsRenderable) -> &mut Self {
self.renderable.check = check;
self
}
#[fn_builder]
pub fn alter_style(&mut self, style: StyleBase) -> &mut Self {
self.style = style;