🚧 Pack and Veck for arrays of components

This commit is contained in:
Manuel Cillero 2023-08-15 00:53:14 +02:00
parent 3d86115f97
commit 6197052ae7
22 changed files with 229 additions and 114 deletions

View file

@ -22,8 +22,8 @@ pub enum AnchorTarget {
Context(String),
}
type AnchorIcon = OneComponent<Icon>;
type AnchorHtml = OneComponent<L10n>;
type AnchorIcon = ComponentOne<Icon>;
type AnchorHtml = ComponentOne<L10n>;
#[rustfmt::skip]
#[derive(Default)]

View file

@ -94,17 +94,13 @@ impl Block {
}
pub fn with_component(mut self, component: impl ComponentTrait) -> Self {
self.stuff.alter(PackOp::Add, ComponentArc::new(component));
self.stuff.alter(PackOp::Add(ComponentArc::with(component)));
self
}
pub fn with_component_arc(mut self, arc: ComponentArc) -> Self {
self.stuff.alter(PackOp::Add, arc);
self
}
pub fn alter_components(&mut self, op: PackOp, component: impl ComponentTrait) -> &mut Self {
self.stuff.alter(op, ComponentArc::new(component));
#[fn_builder]
pub fn alter_components(&mut self, op: PackOp) -> &mut Self {
self.stuff.alter(op);
self
}

View file

@ -155,17 +155,13 @@ impl Container {
}
pub fn with_component(mut self, component: impl ComponentTrait) -> Self {
self.stuff.alter(PackOp::Add, ComponentArc::new(component));
self.stuff.alter(PackOp::Add(ComponentArc::with(component)));
self
}
pub fn with_component_arc(mut self, arc: ComponentArc) -> Self {
self.stuff.alter(PackOp::Add, arc);
self
}
pub fn alter_components(&mut self, op: PackOp, component: impl ComponentTrait) -> &mut Self {
self.stuff.alter(op, ComponentArc::new(component));
#[fn_builder]
pub fn alter_components(&mut self, op: PackOp) -> &mut Self {
self.stuff.alter(op);
self
}

View file

@ -13,7 +13,7 @@ pub struct Container {
renderable: Renderable,
id : IdentifierValue,
classes : Classes,
items : PackComponents,
items : VeckComponents<flex::Item>,
template : String,
}
@ -83,12 +83,13 @@ impl Container {
}
pub fn with_item(mut self, item: flex::Item) -> Self {
self.items.alter(PackOp::Add, ComponentArc::new(item));
self.items.alter(VeckOp::Add(ComponentOne::with(item)));
self
}
pub fn alter_items(&mut self, op: PackOp, item: flex::Item) -> &mut Self {
self.items.alter(op, ComponentArc::new(item));
#[fn_builder]
pub fn alter_items(&mut self, op: VeckOp<flex::Item>) -> &mut Self {
self.items.alter(op);
self
}
@ -104,7 +105,7 @@ impl Container {
&self.classes
}
pub fn items(&self) -> &PackComponents {
pub fn items(&self) -> &VeckComponents<flex::Item> {
&self.items
}

View file

@ -136,17 +136,13 @@ impl Item {
}
pub fn with_component(mut self, component: impl ComponentTrait) -> Self {
self.stuff.alter(PackOp::Add, ComponentArc::new(component));
self.stuff.alter(PackOp::Add(ComponentArc::with(component)));
self
}
pub fn with_component_arc(mut self, arc: ComponentArc) -> Self {
self.stuff.alter(PackOp::Add, arc);
self
}
pub fn alter_components(&mut self, op: PackOp, component: impl ComponentTrait) -> &mut Self {
self.stuff.alter(op, ComponentArc::new(component));
#[fn_builder]
pub fn alter_components(&mut self, op: PackOp) -> &mut Self {
self.stuff.alter(op);
self
}

View file

@ -10,7 +10,7 @@ pub enum ButtonType {
Reset,
}
type ButtonValue = OneComponent<L10n>;
type ButtonValue = ComponentOne<L10n>;
#[rustfmt::skip]
#[derive(Default)]

View file

@ -21,7 +21,7 @@ pub struct Form {
action : AttributeValue,
charset : AttributeValue,
method : FormMethod,
elements : PackComponents,
stuff : PackComponents,
template : String,
}
@ -121,17 +121,13 @@ impl Form {
}
pub fn with_element(mut self, element: impl ComponentTrait) -> Self {
self.elements.alter(PackOp::Add, ComponentArc::new(element));
self.stuff.alter(PackOp::Add(ComponentArc::with(element)));
self
}
pub fn with_element_arc(mut self, arc: ComponentArc) -> Self {
self.elements.alter(PackOp::Add, arc);
self
}
pub fn alter_elements(&mut self, op: PackOp, element: impl ComponentTrait) -> &mut Self {
self.elements.alter(op, ComponentArc::new(element));
#[fn_builder]
pub fn alter_elements(&mut self, op: PackOp) -> &mut Self {
self.stuff.alter(op);
self
}
@ -160,7 +156,7 @@ impl Form {
}
pub fn elements(&self) -> &PackComponents {
&self.elements
&self.stuff
}
pub fn template(&self) -> &str {

View file

@ -13,8 +13,8 @@ pub enum InputType {
Url,
}
type InputLabel = OneComponent<L10n>;
type InputHelpText = OneComponent<L10n>;
type InputLabel = ComponentOne<L10n>;
type InputHelpText = ComponentOne<L10n>;
#[rustfmt::skip]
#[derive(Default)]

View file

@ -136,17 +136,13 @@ impl Column {
}
pub fn with_component(mut self, component: impl ComponentTrait) -> Self {
self.stuff.alter(PackOp::Add, ComponentArc::new(component));
self.stuff.alter(PackOp::Add(ComponentArc::with(component)));
self
}
pub fn with_component_arc(mut self, arc: ComponentArc) -> Self {
self.stuff.alter(PackOp::Add, arc);
self
}
pub fn alter_components(&mut self, op: PackOp, component: impl ComponentTrait) -> &mut Self {
self.stuff.alter(op, ComponentArc::new(component));
#[fn_builder]
pub fn alter_components(&mut self, op: PackOp) -> &mut Self {
self.stuff.alter(op);
self
}

View file

@ -13,7 +13,7 @@ pub struct Row {
renderable: Renderable,
id : IdentifierValue,
classes : Classes,
columns : PackComponents,
columns : VeckComponents<grid::Column>,
template : String,
}
@ -83,12 +83,13 @@ impl Row {
}
pub fn with_column(mut self, column: grid::Column) -> Self {
self.columns.alter(PackOp::Add, ComponentArc::new(column));
self.columns.alter(VeckOp::Add(ComponentOne::with(column)));
self
}
pub fn alter_columns(&mut self, op: PackOp, column: grid::Column) -> &mut Self {
self.columns.alter(op, ComponentArc::new(column));
#[fn_builder]
pub fn alter_columns(&mut self, op: VeckOp<grid::Column>) -> &mut Self {
self.columns.alter(op);
self
}
@ -104,7 +105,7 @@ impl Row {
&self.classes
}
pub fn columns(&self) -> &PackComponents {
pub fn columns(&self) -> &VeckComponents<grid::Column> {
&self.columns
}

View file

@ -25,7 +25,7 @@ pub enum HeadingDisplay {
Subtitle,
}
type HeadingText = OneComponent<L10n>;
type HeadingText = ComponentOne<L10n>;
#[rustfmt::skip]
#[derive(Default)]

View file

@ -90,17 +90,13 @@ impl Paragraph {
}
pub fn with_component(mut self, component: impl ComponentTrait) -> Self {
self.stuff.alter(PackOp::Add, ComponentArc::new(component));
self.stuff.alter(PackOp::Add(ComponentArc::with(component)));
self
}
pub fn with_component_arc(mut self, arc: ComponentArc) -> Self {
self.stuff.alter(PackOp::Add, arc);
self
}
pub fn alter_components(&mut self, op: PackOp, component: impl ComponentTrait) -> &mut Self {
self.stuff.alter(op, ComponentArc::new(component));
#[fn_builder]
pub fn alter_components(&mut self, op: PackOp) -> &mut Self {
self.stuff.alter(op);
self
}

View file

@ -6,8 +6,8 @@ use crate::LOCALES_MINIMAL;
new_handle!(COMPONENT_BRANDING);
type SiteSlogan = OneComponent<L10n>;
type SiteLogo = OneComponent<Image>;
type SiteSlogan = ComponentOne<L10n>;
type SiteLogo = ComponentOne<Image>;
#[rustfmt::skip]
pub struct SiteBranding {