♻️ Weight is a property of mixed components struct

This commit is contained in:
Manuel Cillero 2024-04-14 22:33:20 +02:00
parent 322cd9b6bf
commit 45cb063e52
23 changed files with 60 additions and 266 deletions

View file

@ -13,7 +13,6 @@ pub enum ItemType {
#[derive(AutoDefault, ComponentClasses)]
pub struct Item {
id : OptionId,
weight : Weight,
renderable : Renderable,
classes : OptionClasses,
item_type : ItemType,
@ -34,10 +33,6 @@ impl ComponentTrait for Item {
self.id.get()
}
fn weight(&self) -> Weight {
self.weight
}
fn is_renderable(&self, cx: &Context) -> bool {
(self.renderable.check)(cx)
}
@ -72,20 +67,16 @@ impl ComponentTrait for Item {
if output.is_empty() && region.is_empty() {
return PrepareMarkup::None;
}
let order = match self.weight() {
0 => None,
_ => Some(concat_string!("order: ", self.weight().to_string(), ";")),
};
match self.item_type() {
ItemType::Default => PrepareMarkup::With(html! {
div id=[self.id()] class=[self.classes().get()] style=[order] {
div id=[self.id()] class=[self.classes().get()] {
div class="flex__content" {
(output)
}
}
}),
ItemType::Region => PrepareMarkup::With(html! {
div id=[self.id()] class=[self.classes().get()] style=[order] {
div id=[self.id()] class=[self.classes().get()] {
div class="flex__content flex__region" {
(region)
(output)
@ -93,7 +84,7 @@ impl ComponentTrait for Item {
}
}),
ItemType::Wrapper => PrepareMarkup::With(html! {
div id=[self.id()] class=[self.classes().get()] style=[order] {
div id=[self.id()] class=[self.classes().get()] {
(output)
}
}),
@ -138,12 +129,6 @@ impl Item {
self
}
#[fn_builder]
pub fn alter_weight(&mut self, value: Weight) -> &mut Self {
self.weight = value;
self
}
#[fn_builder]
pub fn alter_renderable(&mut self, check: FnIsRenderable) -> &mut Self {
self.renderable.check = check;