From d7acf0c3d15344dce4315598c920ffc9f91b0ae5 Mon Sep 17 00:00:00 2001 From: Manuel Cillero Date: Sat, 16 Mar 2024 21:41:04 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Simplify=20?= =?UTF-8?q?component=20vector=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/component/block.rs | 4 +- src/base/component/flex/item.rs | 4 +- src/base/component/form/form_main.rs | 12 +- src/base/component/menu/element.rs | 4 +- src/base/component/menu/group.rs | 16 +- src/base/component/menu/item.rs | 6 +- src/base/component/menu/megamenu.rs | 16 +- src/base/component/menu/menu_main.rs | 16 +- src/base/component/menu/submenu.rs | 16 +- src/base/component/paragraph.rs | 4 +- src/core/component.rs | 9 +- src/core/component/arc_typed.rs | 141 ------------------ src/core/component/context.rs | 4 +- src/core/component/{arc_mixed.rs => mixed.rs} | 95 ++++++++++-- src/core/theme/regions.rs | 12 +- src/html/opt_component.rs | 8 +- src/response/page.rs | 8 +- 17 files changed, 154 insertions(+), 221 deletions(-) delete mode 100644 src/core/component/arc_typed.rs rename src/core/component/{arc_mixed.rs => mixed.rs} (56%) diff --git a/src/base/component/block.rs b/src/base/component/block.rs index abfddc04..7ec8b490 100644 --- a/src/base/component/block.rs +++ b/src/base/component/block.rs @@ -90,14 +90,14 @@ impl Block { } #[fn_builder] - pub fn alter_components(&mut self, op: MixedOp) -> &mut Self { + pub fn alter_components(&mut self, op: AnyOp) -> &mut Self { self.mixed.alter_value(op); self } #[rustfmt::skip] pub fn add_component(mut self, component: impl ComponentTrait) -> Self { - self.mixed.alter_value(MixedOp::Add(AnyComponent::with(component))); + self.mixed.alter_value(AnyOp::Add(AnyComponent::with(component))); self } diff --git a/src/base/component/flex/item.rs b/src/base/component/flex/item.rs index 4b91dcdd..5775cf2a 100644 --- a/src/base/component/flex/item.rs +++ b/src/base/component/flex/item.rs @@ -139,14 +139,14 @@ impl Item { } #[fn_builder] - pub fn alter_components(&mut self, op: MixedOp) -> &mut Self { + pub fn alter_components(&mut self, op: AnyOp) -> &mut Self { self.mixed.alter_value(op); self } #[rustfmt::skip] pub fn add_component(mut self, component: impl ComponentTrait) -> Self { - self.mixed.alter_value(MixedOp::Add(AnyComponent::with(component))); + self.mixed.alter_value(AnyOp::Add(AnyComponent::with(component))); self } diff --git a/src/base/component/form/form_main.rs b/src/base/component/form/form_main.rs index af8beb8f..039e18bc 100644 --- a/src/base/component/form/form_main.rs +++ b/src/base/component/form/form_main.rs @@ -97,15 +97,15 @@ impl Form { self } - #[rustfmt::skip] - pub fn add_element(mut self, element: impl ComponentTrait) -> Self { - self.mixed.alter_value(MixedOp::Add(AnyComponent::with(element))); + #[fn_builder] + pub fn alter_elements(&mut self, op: AnyOp) -> &mut Self { + self.mixed.alter_value(op); self } - #[fn_builder] - pub fn alter_elements(&mut self, op: MixedOp) -> &mut Self { - self.mixed.alter_value(op); + #[rustfmt::skip] + pub fn add_element(mut self, element: impl ComponentTrait) -> Self { + self.mixed.alter_value(AnyOp::Add(AnyComponent::with(element))); self } diff --git a/src/base/component/menu/element.rs b/src/base/component/menu/element.rs index 3f887733..a6a7d731 100644 --- a/src/base/component/menu/element.rs +++ b/src/base/component/menu/element.rs @@ -2,8 +2,8 @@ use crate::prelude::*; use super::Submenu; -type Content = OneComponent; -type SubmenuItems = OneComponent; +type Content = TypedComponent; +type SubmenuItems = TypedComponent; #[derive(AutoDefault)] pub enum ElementType { diff --git a/src/base/component/menu/group.rs b/src/base/component/menu/group.rs index d083d602..7c5cf15e 100644 --- a/src/base/component/menu/group.rs +++ b/src/base/component/menu/group.rs @@ -8,7 +8,7 @@ pub struct Group { id : OptionId, weight : Weight, renderable: Renderable, - elements : TypedComponents, + elements : MixedComponents, } impl ComponentTrait for Group { @@ -58,21 +58,21 @@ impl Group { self } - #[rustfmt::skip] - pub fn add_element(mut self, element: Element) -> Self { - self.elements.alter_value(TypedOp::Add(OneComponent::with(element))); + #[fn_builder] + pub fn alter_elements(&mut self, op: TypedOp) -> &mut Self { + self.elements.alter_typed(op); self } - #[fn_builder] - pub fn alter_elements(&mut self, op: TypedOp) -> &mut Self { - self.elements.alter_value(op); + #[rustfmt::skip] + pub fn add_element(mut self, element: Element) -> Self { + self.elements.alter_value(AnyOp::Add(AnyComponent::with(element))); self } // Group GETTERS. - pub fn elements(&self) -> &TypedComponents { + pub fn elements(&self) -> &MixedComponents { &self.elements } } diff --git a/src/base/component/menu/item.rs b/src/base/component/menu/item.rs index ccd39875..bf11bf9a 100644 --- a/src/base/component/menu/item.rs +++ b/src/base/component/menu/item.rs @@ -3,9 +3,9 @@ use crate::prelude::*; use super::{Megamenu, Submenu}; type Label = L10n; -type Content = OneComponent; -type SubmenuItems = OneComponent; -type MegamenuGroups = OneComponent; +type Content = TypedComponent; +type SubmenuItems = TypedComponent; +type MegamenuGroups = TypedComponent; #[derive(AutoDefault)] pub enum ItemType { diff --git a/src/base/component/menu/megamenu.rs b/src/base/component/menu/megamenu.rs index 43962953..60c0d4d0 100644 --- a/src/base/component/menu/megamenu.rs +++ b/src/base/component/menu/megamenu.rs @@ -8,7 +8,7 @@ pub struct Megamenu { id : OptionId, weight : Weight, renderable: Renderable, - groups : TypedComponents, + groups : MixedComponents, } impl ComponentTrait for Megamenu { @@ -58,21 +58,21 @@ impl Megamenu { self } - #[rustfmt::skip] - pub fn add_group(mut self, group: Group) -> Self { - self.groups.alter_value(TypedOp::Add(OneComponent::with(group))); + #[fn_builder] + pub fn alter_groups(&mut self, op: TypedOp) -> &mut Self { + self.groups.alter_typed(op); self } - #[fn_builder] - pub fn alter_groups(&mut self, op: TypedOp) -> &mut Self { - self.groups.alter_value(op); + #[rustfmt::skip] + pub fn add_group(mut self, group: Group) -> Self { + self.groups.alter_value(AnyOp::Add(AnyComponent::with(group))); self } // Megamenu GETTERS. - pub fn groups(&self) -> &TypedComponents { + pub fn groups(&self) -> &MixedComponents { &self.groups } } diff --git a/src/base/component/menu/menu_main.rs b/src/base/component/menu/menu_main.rs index c56b8eb5..2366fc8b 100644 --- a/src/base/component/menu/menu_main.rs +++ b/src/base/component/menu/menu_main.rs @@ -8,7 +8,7 @@ pub struct Menu { id : OptionId, weight : Weight, renderable: Renderable, - items : TypedComponents, + items : MixedComponents, } impl ComponentTrait for Menu { @@ -86,21 +86,21 @@ impl Menu { self } - #[rustfmt::skip] - pub fn add_item(mut self, item: Item) -> Self { - self.items.alter_value(TypedOp::Add(OneComponent::with(item))); + #[fn_builder] + pub fn alter_items(&mut self, op: TypedOp) -> &mut Self { + self.items.alter_typed(op); self } - #[fn_builder] - pub fn alter_items(&mut self, op: TypedOp) -> &mut Self { - self.items.alter_value(op); + #[rustfmt::skip] + pub fn add_item(mut self, item: Item) -> Self { + self.items.alter_value(AnyOp::Add(AnyComponent::with(item))); self } // Menu GETTERS. - pub fn items(&self) -> &TypedComponents { + pub fn items(&self) -> &MixedComponents { &self.items } } diff --git a/src/base/component/menu/submenu.rs b/src/base/component/menu/submenu.rs index 268d7746..f637bc75 100644 --- a/src/base/component/menu/submenu.rs +++ b/src/base/component/menu/submenu.rs @@ -9,7 +9,7 @@ pub struct Submenu { weight : Weight, renderable: Renderable, title : OptionTranslated, - items : TypedComponents, + items : MixedComponents, } impl ComponentTrait for Submenu { @@ -70,15 +70,15 @@ impl Submenu { self } - #[rustfmt::skip] - pub fn add_item(mut self, item: Item) -> Self { - self.items.alter_value(TypedOp::Add(OneComponent::with(item))); + #[fn_builder] + pub fn alter_items(&mut self, op: TypedOp) -> &mut Self { + self.items.alter_typed(op); self } - #[fn_builder] - pub fn alter_items(&mut self, op: TypedOp) -> &mut Self { - self.items.alter_value(op); + #[rustfmt::skip] + pub fn add_item(mut self, item: Item) -> Self { + self.items.alter_value(AnyOp::Add(AnyComponent::with(item))); self } @@ -88,7 +88,7 @@ impl Submenu { &self.title } - pub fn items(&self) -> &TypedComponents { + pub fn items(&self) -> &MixedComponents { &self.items } } diff --git a/src/base/component/paragraph.rs b/src/base/component/paragraph.rs index b31eb8fe..89640532 100644 --- a/src/base/component/paragraph.rs +++ b/src/base/component/paragraph.rs @@ -80,14 +80,14 @@ impl Paragraph { } #[fn_builder] - pub fn alter_components(&mut self, op: MixedOp) -> &mut Self { + pub fn alter_components(&mut self, op: AnyOp) -> &mut Self { self.mixed.alter_value(op); self } #[rustfmt::skip] pub fn add_component(mut self, component: impl ComponentTrait) -> Self { - self.mixed.alter_value(MixedOp::Add(AnyComponent::with(component))); + self.mixed.alter_value(AnyOp::Add(AnyComponent::with(component))); self } diff --git a/src/core/component.rs b/src/core/component.rs index e36c4ec2..34a6147a 100644 --- a/src/core/component.rs +++ b/src/core/component.rs @@ -11,8 +11,7 @@ pub use definition::{component_as_mut, component_as_ref, ComponentBase, Componen mod classes; pub use classes::{ComponentClasses, ComponentClassesOp}; -mod arc_mixed; -pub use arc_mixed::{AnyComponent, MixedComponents, MixedOp}; - -mod arc_typed; -pub use arc_typed::{OneComponent, TypedComponents, TypedOp}; +mod mixed; +pub use mixed::MixedComponents; +pub use mixed::{AnyComponent, AnyOp}; +pub use mixed::{TypedComponent, TypedOp}; diff --git a/src/core/component/arc_typed.rs b/src/core/component/arc_typed.rs deleted file mode 100644 index ccf99e90..00000000 --- a/src/core/component/arc_typed.rs +++ /dev/null @@ -1,141 +0,0 @@ -use crate::core::component::{ComponentTrait, Context}; -use crate::html::{html, Markup}; -use crate::{fn_builder, TypeId, Weight}; - -use std::sync::{Arc, RwLock, RwLockReadGuard, RwLockWriteGuard}; - -pub struct OneComponent(Arc>); - -impl Clone for OneComponent { - fn clone(&self) -> Self { - Self(self.0.clone()) - } -} - -impl OneComponent { - pub fn with(component: C) -> Self { - OneComponent(Arc::new(RwLock::new(component))) - } - - // OneComponent BUILDER. - - pub fn set(&mut self, component: C) { - self.0 = Arc::new(RwLock::new(component)); - } - - // OneComponent GETTERS. - - pub fn get(&self) -> RwLockReadGuard<'_, C> { - self.0.read().unwrap() - } - - pub fn get_mut(&self) -> RwLockWriteGuard<'_, C> { - self.0.write().unwrap() - } - - // OneComponent RENDER. - - pub fn render(&self, cx: &mut Context) -> Markup { - self.0.write().unwrap().render(cx) - } - - // OneComponent HELPERS. - - fn type_id(&self) -> TypeId { - self.0.read().unwrap().type_id() - } - - fn id(&self) -> String { - self.0.read().unwrap().id().unwrap_or_default() - } - - fn weight(&self) -> Weight { - self.0.read().unwrap().weight() - } -} - -// ************************************************************************************************* - -pub enum TypedOp { - Add(OneComponent), - InsertAfterId(&'static str, OneComponent), - InsertBeforeId(&'static str, OneComponent), - Prepend(OneComponent), - RemoveById(&'static str), - ReplaceById(&'static str, OneComponent), - Reset, -} - -#[derive(Clone, Default)] -pub struct TypedComponents(Vec>); - -impl TypedComponents { - pub fn new(one: OneComponent) -> Self { - TypedComponents::default().with_value(TypedOp::Add(one)) - } - - // TypedComponents BUILDER. - - #[fn_builder] - pub fn alter_value(&mut self, op: TypedOp) -> &mut Self { - match op { - TypedOp::Add(one) => self.0.push(one), - TypedOp::InsertAfterId(id, one) => match self.0.iter().position(|c| c.id() == id) { - Some(index) => self.0.insert(index + 1, one), - _ => self.0.push(one), - }, - TypedOp::InsertBeforeId(id, one) => match self.0.iter().position(|c| c.id() == id) { - Some(index) => self.0.insert(index, one), - _ => self.0.insert(0, one), - }, - TypedOp::Prepend(one) => self.0.insert(0, one), - TypedOp::RemoveById(id) => { - if let Some(index) = self.0.iter().position(|c| c.id() == id) { - self.0.remove(index); - } - } - TypedOp::ReplaceById(id, one) => { - for c in self.0.iter_mut() { - if c.id() == id { - *c = one; - break; - } - } - } - TypedOp::Reset => self.0.clear(), - } - self - } - - // TypedComponents GETTERS. - - pub fn is_empty(&self) -> bool { - self.0.is_empty() - } - - pub fn get_by_id(&self, id: impl Into) -> Option<&OneComponent> { - let id = id.into(); - self.0.iter().find(|&c| c.id() == id) - } - - pub fn iter_by_id(&self, id: impl Into) -> impl Iterator> { - let id = id.into(); - self.0.iter().filter(move |&c| c.id() == id) - } - - pub fn iter_by_type_id(&self, type_id: TypeId) -> impl Iterator> { - self.0.iter().filter(move |&c| c.type_id() == type_id) - } - - // TypedComponents RENDER. - - pub fn render(&self, cx: &mut Context) -> Markup { - let mut components = self.0.clone(); - components.sort_by_key(|c| c.weight()); - html! { - @for c in components.iter() { - (c.render(cx)) - } - } - } -} diff --git a/src/core/component/context.rs b/src/core/component/context.rs index 02f96e46..7d10d8d5 100644 --- a/src/core/component/context.rs +++ b/src/core/component/context.rs @@ -1,5 +1,5 @@ use crate::base::component::add_base_assets; -use crate::core::component::MixedOp; +use crate::core::component::AnyOp; use crate::core::theme::all::{theme_by_single_name, THEME_DEFAULT}; use crate::core::theme::{ComponentsInRegions, ThemeRef}; use crate::html::{html, Assets, HeadScript, HeadStyles, JavaScript, Markup, StyleSheet}; @@ -95,7 +95,7 @@ impl Context { self } - pub fn alter_regions(&mut self, region: &'static str, op: MixedOp) -> &mut Self { + pub fn alter_regions(&mut self, region: &'static str, op: AnyOp) -> &mut Self { self.regions.alter_components(region, op); self } diff --git a/src/core/component/arc_mixed.rs b/src/core/component/mixed.rs similarity index 56% rename from src/core/component/arc_mixed.rs rename to src/core/component/mixed.rs index f14bdaa9..58fb4f36 100644 --- a/src/core/component/arc_mixed.rs +++ b/src/core/component/mixed.rs @@ -51,7 +51,43 @@ impl AnyComponent { // ************************************************************************************************* -pub enum MixedOp { +pub struct TypedComponent(Arc>); + +impl Clone for TypedComponent { + fn clone(&self) -> Self { + Self(self.0.clone()) + } +} + +impl TypedComponent { + pub fn with(component: C) -> Self { + TypedComponent(Arc::new(RwLock::new(component))) + } + + // TypedComponent GETTERS. + + pub fn get(&self) -> RwLockReadGuard<'_, C> { + self.0.read().unwrap() + } + + pub fn get_mut(&self) -> RwLockWriteGuard<'_, C> { + self.0.write().unwrap() + } + + fn to_any(&self) -> AnyComponent { + AnyComponent(self.0.clone()) + } + + // TypedComponent RENDER. + + pub fn render(&self, cx: &mut Context) -> Markup { + self.0.write().unwrap().render(cx) + } +} + +// ************************************************************************************************* + +pub enum AnyOp { Add(AnyComponent), InsertAfterId(&'static str, AnyComponent), InsertBeforeId(&'static str, AnyComponent), @@ -61,6 +97,16 @@ pub enum MixedOp { Reset, } +pub enum TypedOp { + Add(TypedComponent), + InsertAfterId(&'static str, TypedComponent), + InsertBeforeId(&'static str, TypedComponent), + Prepend(TypedComponent), + RemoveById(&'static str), + ReplaceById(&'static str, TypedComponent), + Reset, +} + #[derive(Clone, Default)] pub struct MixedComponents(Vec); @@ -70,7 +116,7 @@ impl MixedComponents { } pub fn with(any: AnyComponent) -> Self { - MixedComponents::default().with_value(MixedOp::Add(any)) + MixedComponents::default().with_value(AnyOp::Add(any)) } pub(crate) fn merge(mixes: &[Option<&MixedComponents>]) -> Self { @@ -84,24 +130,24 @@ impl MixedComponents { // MixedComponents BUILDER. #[fn_builder] - pub fn alter_value(&mut self, op: MixedOp) -> &mut Self { + pub fn alter_value(&mut self, op: AnyOp) -> &mut Self { match op { - MixedOp::Add(any) => self.0.push(any), - MixedOp::InsertAfterId(id, any) => match self.0.iter().position(|c| c.id() == id) { + AnyOp::Add(any) => self.0.push(any), + AnyOp::InsertAfterId(id, any) => match self.0.iter().position(|c| c.id() == id) { Some(index) => self.0.insert(index + 1, any), _ => self.0.push(any), }, - MixedOp::InsertBeforeId(id, any) => match self.0.iter().position(|c| c.id() == id) { + AnyOp::InsertBeforeId(id, any) => match self.0.iter().position(|c| c.id() == id) { Some(index) => self.0.insert(index, any), _ => self.0.insert(0, any), }, - MixedOp::Prepend(any) => self.0.insert(0, any), - MixedOp::RemoveById(id) => { + AnyOp::Prepend(any) => self.0.insert(0, any), + AnyOp::RemoveById(id) => { if let Some(index) = self.0.iter().position(|c| c.id() == id) { self.0.remove(index); } } - MixedOp::ReplaceById(id, any) => { + AnyOp::ReplaceById(id, any) => { for c in self.0.iter_mut() { if c.id() == id { *c = any; @@ -109,11 +155,40 @@ impl MixedComponents { } } } - MixedOp::Reset => self.0.clear(), + AnyOp::Reset => self.0.clear(), } self } + #[fn_builder] + #[rustfmt::skip] + pub fn alter_typed(&mut self, op: TypedOp) -> &mut Self { + match op { + TypedOp::Add(typed) => { + self.alter_value(AnyOp::Add(typed.to_any())) + } + TypedOp::InsertAfterId(id, typed) => { + self.alter_value(AnyOp::InsertAfterId(id, typed.to_any())) + } + TypedOp::InsertBeforeId(id, typed) => { + self.alter_value(AnyOp::InsertBeforeId(id, typed.to_any())) + } + TypedOp::Prepend(typed) => { + self.alter_value(AnyOp::Prepend(typed.to_any())) + } + TypedOp::RemoveById(id) => { + self.alter_value(AnyOp::RemoveById(id)) + } + TypedOp::ReplaceById(id, typed) => { + self.alter_value(AnyOp::ReplaceById(id, typed.to_any())) + } + TypedOp::Reset => { + self.alter_value(AnyOp::Reset) + } + }; + self + } + // MixedComponents GETTERS. pub fn is_empty(&self) -> bool { diff --git a/src/core/theme/regions.rs b/src/core/theme/regions.rs index 09921ef4..79b08125 100644 --- a/src/core/theme/regions.rs +++ b/src/core/theme/regions.rs @@ -1,4 +1,4 @@ -use crate::core::component::{AnyComponent, MixedComponents, MixedOp}; +use crate::core::component::{AnyComponent, AnyOp, MixedComponents}; use crate::core::theme::ThemeRef; use crate::{fn_builder, AutoDefault, LazyStatic, TypeId}; @@ -16,11 +16,11 @@ pub struct ComponentsInRegions(HashMap<&'static str, MixedComponents>); impl ComponentsInRegions { pub fn new(region: &'static str, any: AnyComponent) -> Self { - ComponentsInRegions::default().with_components(region, MixedOp::Add(any)) + ComponentsInRegions::default().with_components(region, AnyOp::Add(any)) } #[fn_builder] - pub fn alter_components(&mut self, region: &'static str, op: MixedOp) -> &mut Self { + pub fn alter_components(&mut self, region: &'static str, op: AnyOp) -> &mut Self { if let Some(region) = self.0.get_mut(region) { region.alter_value(op); } else { @@ -52,18 +52,18 @@ impl InRegion { COMMON_REGIONS .write() .unwrap() - .alter_components("content", MixedOp::Add(any)); + .alter_components("content", AnyOp::Add(any)); } InRegion::Named(name) => { COMMON_REGIONS .write() .unwrap() - .alter_components(name, MixedOp::Add(any)); + .alter_components(name, AnyOp::Add(any)); } InRegion::OfTheme(region, theme) => { let mut regions = THEME_REGIONS.write().unwrap(); if let Some(r) = regions.get_mut(&theme.type_id()) { - r.alter_components(region, MixedOp::Add(any)); + r.alter_components(region, AnyOp::Add(any)); } else { regions.insert(theme.type_id(), ComponentsInRegions::new(region, any)); } diff --git a/src/html/opt_component.rs b/src/html/opt_component.rs index ef5a6c83..9bb4523c 100644 --- a/src/html/opt_component.rs +++ b/src/html/opt_component.rs @@ -1,8 +1,8 @@ -use crate::core::component::{ComponentTrait, Context, OneComponent}; +use crate::core::component::{ComponentTrait, Context, TypedComponent}; use crate::fn_builder; use crate::html::{html, Markup}; -pub struct OptionComponent(Option>); +pub struct OptionComponent(Option>); impl Default for OptionComponent { fn default() -> Self { @@ -20,7 +20,7 @@ impl OptionComponent { #[fn_builder] pub fn alter_value(&mut self, component: Option) -> &mut Self { if let Some(component) = component { - self.0 = Some(OneComponent::with(component)); + self.0 = Some(TypedComponent::with(component)); } else { self.0 = None; } @@ -29,7 +29,7 @@ impl OptionComponent { // OptionComponent GETTERS. - pub fn get(&self) -> Option> { + pub fn get(&self) -> Option> { if let Some(value) = &self.0 { return Some(value.clone()); } diff --git a/src/response/page.rs b/src/response/page.rs index f7c9cb79..b28355c5 100644 --- a/src/response/page.rs +++ b/src/response/page.rs @@ -4,7 +4,7 @@ pub use error::ErrorPage; pub use actix_web::Result as ResultPage; use crate::base::action; -use crate::core::component::{AnyComponent, ComponentTrait, MixedOp}; +use crate::core::component::{AnyComponent, AnyOp, ComponentTrait}; use crate::core::component::{AssetsOp, Context}; use crate::fn_builder; use crate::html::{html, Markup, DOCTYPE}; @@ -106,14 +106,14 @@ impl Page { } #[fn_builder] - pub fn alter_regions(&mut self, region: &'static str, op: MixedOp) -> &mut Self { + pub fn alter_regions(&mut self, region: &'static str, op: AnyOp) -> &mut Self { self.context.alter_regions(region, op); self } pub fn with_component(mut self, component: impl ComponentTrait) -> Self { self.context - .alter_regions("content", MixedOp::Add(AnyComponent::with(component))); + .alter_regions("content", AnyOp::Add(AnyComponent::with(component))); self } @@ -123,7 +123,7 @@ impl Page { component: impl ComponentTrait, ) -> Self { self.context - .alter_regions(region, MixedOp::Add(AnyComponent::with(component))); + .alter_regions(region, AnyOp::Add(AnyComponent::with(component))); self }