🏗️ Use actions to decide component rendering
This commit is contained in:
parent
45cb063e52
commit
7d4cf642ff
27 changed files with 125 additions and 304 deletions
|
|
@ -5,9 +5,8 @@ use super::Group;
|
|||
#[rustfmt::skip]
|
||||
#[derive(AutoDefault)]
|
||||
pub struct Megamenu {
|
||||
id : OptionId,
|
||||
renderable: Renderable,
|
||||
groups : MixedComponents,
|
||||
id : OptionId,
|
||||
groups: MixedComponents,
|
||||
}
|
||||
|
||||
impl ComponentTrait for Megamenu {
|
||||
|
|
@ -19,10 +18,6 @@ impl ComponentTrait for Megamenu {
|
|||
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__groups" {
|
||||
|
|
@ -41,12 +36,6 @@ impl Megamenu {
|
|||
self
|
||||
}
|
||||
|
||||
#[fn_builder]
|
||||
pub fn alter_renderable(&mut self, check: FnIsRenderable) -> &mut Self {
|
||||
self.renderable.check = check;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_builder]
|
||||
pub fn alter_groups(&mut self, op: TypedOp<Group>) -> &mut Self {
|
||||
self.groups.alter_typed(op);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue