Añade macro para patrón "builder" de componentes

This commit is contained in:
Manuel Cillero 2023-01-27 00:37:27 +01:00
parent aa26389777
commit efc59216b4
20 changed files with 133 additions and 665 deletions

View file

@ -2,6 +2,7 @@
members = [
"pagetop",
"pagetop-macros",
"pagetop-build",
# Modules.
"pagetop-admin",

View file

@ -49,6 +49,8 @@ actix-web-files = { package = "actix-files", version = "0.6.2" }
actix-web-static-files = "4.0.0"
static-files = "0.2.3"
pagetop-macros = { path = "../pagetop-macros", version = "0.0" }
maud = { version = "0.24.0", features = ["actix-web"] }
serde = { version = "1.0", features = ["derive"] }

View file

@ -105,83 +105,31 @@ impl Anchor {
// Anchor BUILDER.
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
pub fn with_renderable(mut self, check: IsRenderable) -> Self {
self.alter_renderable(check);
self
}
pub fn with_id(mut self, id: &str) -> Self {
self.alter_id(id);
self
}
pub fn with_classes(mut self, op: ClassesOp, classes: &str) -> Self {
self.alter_classes(op, classes);
self
}
pub fn with_type(mut self, anchor_type: AnchorType) -> Self {
self.alter_type(anchor_type);
self
}
pub fn with_href(mut self, href: &str) -> Self {
self.alter_href(href);
self
}
pub fn with_html(mut self, html: Markup) -> Self {
self.alter_html(html);
self
}
pub fn with_left_icon(mut self, icon: Icon) -> Self {
self.alter_left_icon(icon);
self
}
pub fn with_right_icon(mut self, icon: Icon) -> Self {
self.alter_right_icon(icon);
self
}
pub fn with_target(mut self, target: AnchorTarget) -> Self {
self.alter_target(target);
self
}
pub fn using_template(mut self, template: &str) -> Self {
self.alter_template(template);
self
}
// Anchor ALTER.
#[fn_with]
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}
#[fn_with]
pub fn alter_renderable(&mut self, check: IsRenderable) -> &mut Self {
self.renderable.check = check;
self
}
#[fn_with]
pub fn alter_id(&mut self, id: &str) -> &mut Self {
self.id.alter_value(id);
self
}
#[fn_with]
pub fn alter_classes(&mut self, op: ClassesOp, classes: &str) -> &mut Self {
self.classes.alter_value(op, classes);
self
}
#[fn_with]
pub fn alter_type(&mut self, anchor_type: AnchorType) -> &mut Self {
self.anchor_type = anchor_type;
self.classes.alter_value(
@ -194,33 +142,39 @@ impl Anchor {
self
}
#[fn_with]
pub fn alter_href(&mut self, href: &str) -> &mut Self {
self.href.alter_value(href);
self
}
#[fn_with]
pub fn alter_html(&mut self, html: Markup) -> &mut Self {
self.html.markup = html;
self
}
#[fn_with]
pub fn alter_left_icon(&mut self, icon: Icon) -> &mut Self {
self.left_icon.clear();
self.left_icon.add(icon);
self
}
#[fn_with]
pub fn alter_right_icon(&mut self, icon: Icon) -> &mut Self {
self.right_icon.clear();
self.right_icon.add(icon);
self
}
#[fn_with]
pub fn alter_target(&mut self, target: AnchorTarget) -> &mut Self {
self.target = target;
self
}
#[fn_with]
pub fn alter_template(&mut self, template: &str) -> &mut Self {
self.template = template.to_owned();
self

View file

@ -63,73 +63,43 @@ impl ComponentTrait for Block {
impl Block {
// Block BUILDER.
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
pub fn with_renderable(mut self, check: IsRenderable) -> Self {
self.alter_renderable(check);
self
}
pub fn with_id(mut self, id: &str) -> Self {
self.alter_id(id);
self
}
pub fn with_classes(mut self, op: ClassesOp, classes: &str) -> Self {
self.alter_classes(op, classes);
self
}
pub fn with_title(mut self, title: &str) -> Self {
self.alter_title(title);
self
}
pub fn with_component(mut self, component: impl ComponentTrait) -> Self {
self.alter_component(component);
self
}
pub fn using_template(mut self, template: &str) -> Self {
self.alter_template(template);
self
}
// Block ALTER.
#[fn_with]
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}
#[fn_with]
pub fn alter_renderable(&mut self, check: IsRenderable) -> &mut Self {
self.renderable.check = check;
self
}
#[fn_with]
pub fn alter_id(&mut self, id: &str) -> &mut Self {
self.id.alter_value(id);
self
}
#[fn_with]
pub fn alter_classes(&mut self, op: ClassesOp, classes: &str) -> &mut Self {
self.classes.alter_value(op, classes);
self
}
#[fn_with]
pub fn alter_title(&mut self, title: &str) -> &mut Self {
self.title.alter_value(title);
self
}
#[fn_with]
pub fn alter_component(&mut self, component: impl ComponentTrait) -> &mut Self {
self.components.add(component);
self
}
#[fn_with]
pub fn alter_template(&mut self, template: &str) -> &mut Self {
self.template = template.to_owned();
self

View file

@ -124,73 +124,43 @@ impl Container {
// Container BUILDER.
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
pub fn with_renderable(mut self, check: IsRenderable) -> Self {
self.alter_renderable(check);
self
}
pub fn with_id(mut self, id: &str) -> Self {
self.alter_id(id);
self
}
pub fn with_classes(mut self, op: ClassesOp, classes: &str) -> Self {
self.alter_classes(op, classes);
self
}
pub fn with_inner_classes(mut self, op: ClassesOp, classes: &str) -> Self {
self.alter_inner_classes(op, classes);
self
}
pub fn with_component(mut self, component: impl ComponentTrait) -> Self {
self.alter_component(component);
self
}
pub fn using_template(mut self, template: &str) -> Self {
self.alter_template(template);
self
}
// Container ALTER.
#[fn_with]
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}
#[fn_with]
pub fn alter_renderable(&mut self, check: IsRenderable) -> &mut Self {
self.renderable.check = check;
self
}
#[fn_with]
pub fn alter_id(&mut self, id: &str) -> &mut Self {
self.id.alter_value(id);
self
}
#[fn_with]
pub fn alter_classes(&mut self, op: ClassesOp, classes: &str) -> &mut Self {
self.classes.alter_value(op, classes);
self
}
#[fn_with]
pub fn alter_inner_classes(&mut self, op: ClassesOp, classes: &str) -> &mut Self {
self.inner_classes.alter_value(op, classes);
self
}
#[fn_with]
pub fn alter_component(&mut self, component: impl ComponentTrait) -> &mut Self {
self.components.add(component);
self
}
#[fn_with]
pub fn alter_template(&mut self, template: &str) -> &mut Self {
self.template = template.to_owned();
self

View file

@ -97,73 +97,37 @@ impl Button {
// Button BUILDER.
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
pub fn with_renderable(mut self, check: IsRenderable) -> Self {
self.alter_renderable(check);
self
}
pub fn with_classes(mut self, op: ClassesOp, classes: &str) -> Self {
self.alter_classes(op, classes);
self
}
pub fn with_name(mut self, name: &str) -> Self {
self.alter_name(name);
self
}
pub fn with_value(mut self, value: &str) -> Self {
self.alter_value(value);
self
}
pub fn with_autofocus(mut self, toggle: bool) -> Self {
self.alter_autofocus(toggle);
self
}
pub fn with_disabled(mut self, toggle: bool) -> Self {
self.alter_disabled(toggle);
self
}
pub fn using_template(mut self, template: &str) -> Self {
self.alter_template(template);
self
}
// Button ALTER.
#[fn_with]
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}
#[fn_with]
pub fn alter_renderable(&mut self, check: IsRenderable) -> &mut Self {
self.renderable.check = check;
self
}
#[fn_with]
pub fn alter_classes(&mut self, op: ClassesOp, classes: &str) -> &mut Self {
self.classes.alter_value(op, classes);
self
}
#[fn_with]
pub fn alter_name(&mut self, name: &str) -> &mut Self {
self.name.alter_value(name);
self
}
#[fn_with]
pub fn alter_value(&mut self, value: &str) -> &mut Self {
self.value.alter_value(value);
self
}
#[fn_with]
pub fn alter_autofocus(&mut self, toggle: bool) -> &mut Self {
self.autofocus.alter_value(match toggle {
true => "autofocus",
@ -172,6 +136,7 @@ impl Button {
self
}
#[fn_with]
pub fn alter_disabled(&mut self, toggle: bool) -> &mut Self {
self.disabled.alter_value(match toggle {
true => "disabled",
@ -180,6 +145,7 @@ impl Button {
self
}
#[fn_with]
pub fn alter_template(&mut self, template: &str) -> &mut Self {
self.template = template.to_owned();
self

View file

@ -85,113 +85,49 @@ impl ComponentTrait for Date {
impl Date {
// Date BUILDER.
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
pub fn with_renderable(mut self, check: IsRenderable) -> Self {
self.alter_renderable(check);
self
}
pub fn with_classes(mut self, op: ClassesOp, classes: &str) -> Self {
self.alter_classes(op, classes);
self
}
pub fn with_name(mut self, name: &str) -> Self {
self.alter_name(name);
self
}
pub fn with_value(mut self, value: &str) -> Self {
self.alter_value(value);
self
}
pub fn with_label(mut self, label: &str) -> Self {
self.alter_label(label);
self
}
pub fn with_placeholder(mut self, placeholder: &str) -> Self {
self.alter_placeholder(placeholder);
self
}
pub fn with_autofocus(mut self, toggle: bool) -> Self {
self.alter_autofocus(toggle);
self
}
pub fn with_autocomplete(mut self, toggle: bool) -> Self {
self.alter_autocomplete(toggle);
self
}
pub fn with_disabled(mut self, toggle: bool) -> Self {
self.alter_disabled(toggle);
self
}
pub fn with_readonly(mut self, toggle: bool) -> Self {
self.alter_readonly(toggle);
self
}
pub fn with_required(mut self, toggle: bool) -> Self {
self.alter_required(toggle);
self
}
pub fn with_help_text(mut self, help_text: &str) -> Self {
self.alter_help_text(help_text);
self
}
pub fn using_template(mut self, template: &str) -> Self {
self.alter_template(template);
self
}
// Date ALTER.
#[fn_with]
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}
#[fn_with]
pub fn alter_renderable(&mut self, check: IsRenderable) -> &mut Self {
self.renderable.check = check;
self
}
#[fn_with]
pub fn alter_classes(&mut self, op: ClassesOp, classes: &str) -> &mut Self {
self.classes.alter_value(op, classes);
self
}
#[fn_with]
pub fn alter_name(&mut self, name: &str) -> &mut Self {
self.name.alter_value(name);
self
}
#[fn_with]
pub fn alter_value(&mut self, value: &str) -> &mut Self {
self.value.alter_value(value);
self
}
#[fn_with]
pub fn alter_label(&mut self, label: &str) -> &mut Self {
self.label.alter_value(label);
self
}
#[fn_with]
pub fn alter_placeholder(&mut self, placeholder: &str) -> &mut Self {
self.placeholder.alter_value(placeholder);
self
}
#[fn_with]
pub fn alter_autofocus(&mut self, toggle: bool) -> &mut Self {
self.autofocus.alter_value(match toggle {
true => "autofocus",
@ -200,6 +136,7 @@ impl Date {
self
}
#[fn_with]
pub fn alter_autocomplete(&mut self, toggle: bool) -> &mut Self {
self.autocomplete.alter_value(match toggle {
true => "",
@ -208,6 +145,7 @@ impl Date {
self
}
#[fn_with]
pub fn alter_disabled(&mut self, toggle: bool) -> &mut Self {
self.disabled.alter_value(match toggle {
true => "disabled",
@ -216,6 +154,7 @@ impl Date {
self
}
#[fn_with]
pub fn alter_readonly(&mut self, toggle: bool) -> &mut Self {
self.readonly.alter_value(match toggle {
true => "readonly",
@ -224,6 +163,7 @@ impl Date {
self
}
#[fn_with]
pub fn alter_required(&mut self, toggle: bool) -> &mut Self {
self.required.alter_value(match toggle {
true => "required",
@ -232,11 +172,13 @@ impl Date {
self
}
#[fn_with]
pub fn alter_help_text(&mut self, help_text: &str) -> &mut Self {
self.help_text.alter_value(help_text);
self
}
#[fn_with]
pub fn alter_template(&mut self, template: &str) -> &mut Self {
self.template = template.to_owned();
self

View file

@ -78,93 +78,55 @@ impl ComponentTrait for Form {
impl Form {
// Form BUILDER.
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
pub fn with_renderable(mut self, check: IsRenderable) -> Self {
self.alter_renderable(check);
self
}
pub fn with_id(mut self, id: &str) -> Self {
self.alter_id(id);
self
}
pub fn with_classes(mut self, op: ClassesOp, classes: &str) -> Self {
self.alter_classes(op, classes);
self
}
pub fn with_action(mut self, action: &str) -> Self {
self.alter_action(action);
self
}
pub fn with_charset(mut self, charset: &str) -> Self {
self.alter_charset(charset);
self
}
pub fn with_method(mut self, method: FormMethod) -> Self {
self.alter_method(method);
self
}
pub fn with_element(mut self, element: impl ComponentTrait) -> Self {
self.alter_element(element);
self
}
pub fn using_template(mut self, template: &str) -> Self {
self.alter_template(template);
self
}
// Form ALTER.
#[fn_with]
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}
#[fn_with]
pub fn alter_renderable(&mut self, check: IsRenderable) -> &mut Self {
self.renderable.check = check;
self
}
#[fn_with]
pub fn alter_id(&mut self, id: &str) -> &mut Self {
self.id.alter_value(id);
self
}
#[fn_with]
pub fn alter_classes(&mut self, op: ClassesOp, classes: &str) -> &mut Self {
self.classes.alter_value(op, classes);
self
}
#[fn_with]
pub fn alter_action(&mut self, action: &str) -> &mut Self {
self.action.alter_value(action);
self
}
#[fn_with]
pub fn alter_charset(&mut self, charset: &str) -> &mut Self {
self.charset.alter_value(charset);
self
}
#[fn_with]
pub fn alter_method(&mut self, method: FormMethod) -> &mut Self {
self.method = method;
self
}
#[fn_with]
pub fn alter_element(&mut self, element: impl ComponentTrait) -> &mut Self {
self.elements.add(element);
self
}
#[fn_with]
pub fn alter_template(&mut self, template: &str) -> &mut Self {
self.template = template.to_owned();
self

View file

@ -46,33 +46,19 @@ impl Hidden {
// Hidden BUILDER.
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
pub fn with_name(mut self, name: &str) -> Self {
self.alter_name(name);
self
}
pub fn with_value(mut self, value: &str) -> Self {
self.alter_value(value);
self
}
// Hidden ALTER.
#[fn_with]
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}
#[fn_with]
pub fn alter_name(&mut self, name: &str) -> &mut Self {
self.name.alter_value(name);
self
}
#[fn_with]
pub fn alter_value(&mut self, value: &str) -> &mut Self {
self.value.alter_value(value);
self

View file

@ -168,108 +168,25 @@ impl Input {
// Input BUILDER.
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
pub fn with_renderable(mut self, check: IsRenderable) -> Self {
self.alter_renderable(check);
self
}
pub fn with_classes(mut self, op: ClassesOp, classes: &str) -> Self {
self.alter_classes(op, classes);
self
}
pub fn with_name(mut self, name: &str) -> Self {
self.alter_name(name);
self
}
pub fn with_value(mut self, value: &str) -> Self {
self.alter_value(value);
self
}
pub fn with_label(mut self, label: &str) -> Self {
self.alter_label(label);
self
}
pub fn with_size(mut self, size: Option<u16>) -> Self {
self.alter_size(size);
self
}
pub fn with_minlength(mut self, minlength: Option<u16>) -> Self {
self.alter_minlength(minlength);
self
}
pub fn with_maxlength(mut self, maxlength: Option<u16>) -> Self {
self.alter_maxlength(maxlength);
self
}
pub fn with_placeholder(mut self, placeholder: &str) -> Self {
self.alter_placeholder(placeholder);
self
}
pub fn with_autofocus(mut self, toggle: bool) -> Self {
self.alter_autofocus(toggle);
self
}
pub fn with_autocomplete(mut self, toggle: bool) -> Self {
self.alter_autocomplete(toggle);
self
}
pub fn with_disabled(mut self, toggle: bool) -> Self {
self.alter_disabled(toggle);
self
}
pub fn with_readonly(mut self, toggle: bool) -> Self {
self.alter_readonly(toggle);
self
}
pub fn with_required(mut self, toggle: bool) -> Self {
self.alter_required(toggle);
self
}
pub fn with_help_text(mut self, help_text: &str) -> Self {
self.alter_help_text(help_text);
self
}
pub fn using_template(mut self, template: &str) -> Self {
self.alter_template(template);
self
}
// Input ALTER.
#[fn_with]
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}
#[fn_with]
pub fn alter_renderable(&mut self, check: IsRenderable) -> &mut Self {
self.renderable.check = check;
self
}
#[fn_with]
pub fn alter_classes(&mut self, op: ClassesOp, classes: &str) -> &mut Self {
self.classes.alter_value(op, classes);
self
}
#[fn_with]
pub fn alter_name(&mut self, name: &str) -> &mut Self {
self.name.alter_value(name);
self.alter_classes(
@ -279,36 +196,43 @@ impl Input {
self
}
#[fn_with]
pub fn alter_value(&mut self, value: &str) -> &mut Self {
self.value.alter_value(value);
self
}
#[fn_with]
pub fn alter_label(&mut self, label: &str) -> &mut Self {
self.label.alter_value(label);
self
}
#[fn_with]
pub fn alter_size(&mut self, size: Option<u16>) -> &mut Self {
self.size = size;
self
}
#[fn_with]
pub fn alter_minlength(&mut self, minlength: Option<u16>) -> &mut Self {
self.minlength = minlength;
self
}
#[fn_with]
pub fn alter_maxlength(&mut self, maxlength: Option<u16>) -> &mut Self {
self.maxlength = maxlength;
self
}
#[fn_with]
pub fn alter_placeholder(&mut self, placeholder: &str) -> &mut Self {
self.placeholder.alter_value(placeholder);
self
}
#[fn_with]
pub fn alter_autofocus(&mut self, toggle: bool) -> &mut Self {
self.autofocus.alter_value(match toggle {
true => "autofocus",
@ -317,6 +241,7 @@ impl Input {
self
}
#[fn_with]
pub fn alter_autocomplete(&mut self, toggle: bool) -> &mut Self {
self.autocomplete.alter_value(match toggle {
true => "",
@ -325,6 +250,7 @@ impl Input {
self
}
#[fn_with]
pub fn alter_disabled(&mut self, toggle: bool) -> &mut Self {
self.disabled.alter_value(match toggle {
true => "disabled",
@ -333,6 +259,7 @@ impl Input {
self
}
#[fn_with]
pub fn alter_readonly(&mut self, toggle: bool) -> &mut Self {
self.readonly.alter_value(match toggle {
true => "readonly",
@ -341,6 +268,7 @@ impl Input {
self
}
#[fn_with]
pub fn alter_required(&mut self, toggle: bool) -> &mut Self {
self.required.alter_value(match toggle {
true => "required",
@ -349,11 +277,13 @@ impl Input {
self
}
#[fn_with]
pub fn alter_help_text(&mut self, help_text: &str) -> &mut Self {
self.help_text.alter_value(help_text);
self
}
#[fn_with]
pub fn alter_template(&mut self, template: &str) -> &mut Self {
self.template = template.to_owned();
self

View file

@ -89,64 +89,32 @@ impl ComponentTrait for Column {
impl Column {
// Column BUILDER.
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
pub fn with_renderable(mut self, check: IsRenderable) -> Self {
self.alter_renderable(check);
self
}
pub fn with_id(mut self, id: &str) -> Self {
self.alter_id(id);
self
}
pub fn with_classes(mut self, op: ClassesOp, classes: &str) -> Self {
self.alter_classes(op, classes);
self
}
pub fn with_size(mut self, size: ColumnSize) -> Self {
self.alter_size(size);
self
}
pub fn with_component(mut self, component: impl ComponentTrait) -> Self {
self.alter_component(component);
self
}
pub fn using_template(mut self, template: &str) -> Self {
self.alter_template(template);
self
}
// Column ALTER.
#[fn_with]
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}
#[fn_with]
pub fn alter_renderable(&mut self, check: IsRenderable) -> &mut Self {
self.renderable.check = check;
self
}
#[fn_with]
pub fn alter_id(&mut self, id: &str) -> &mut Self {
self.id.alter_value(id);
self
}
#[fn_with]
pub fn alter_classes(&mut self, op: ClassesOp, classes: &str) -> &mut Self {
self.classes.alter_value(op, classes);
self
}
#[rustfmt::skip]
#[fn_with]
pub fn alter_size(&mut self, size: ColumnSize) -> &mut Self {
match size {
ColumnSize::Default => self.alter_classes(ClassesOp::SetDefault, SIZE__DEFAULT),
@ -167,10 +135,13 @@ impl Column {
self
}
#[fn_with]
pub fn alter_component(&mut self, component: impl ComponentTrait) -> &mut Self {
self.components.add(component);
self
}
#[fn_with]
pub fn alter_template(&mut self, template: &str) -> &mut Self {
self.template = template.to_owned();
self

View file

@ -56,63 +56,37 @@ impl ComponentTrait for Row {
impl Row {
// Row BUILDER.
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
pub fn with_renderable(mut self, check: IsRenderable) -> Self {
self.alter_renderable(check);
self
}
pub fn with_id(mut self, id: &str) -> Self {
self.alter_id(id);
self
}
pub fn with_classes(mut self, op: ClassesOp, classes: &str) -> Self {
self.alter_classes(op, classes);
self
}
pub fn with_column(mut self, column: grid::Column) -> Self {
self.alter_column(column);
self
}
pub fn using_template(mut self, template: &str) -> Self {
self.alter_template(template);
self
}
// Row ALTER.
#[fn_with]
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}
#[fn_with]
pub fn alter_renderable(&mut self, check: IsRenderable) -> &mut Self {
self.renderable.check = check;
self
}
#[fn_with]
pub fn alter_id(&mut self, id: &str) -> &mut Self {
self.id.alter_value(id);
self
}
#[fn_with]
pub fn alter_classes(&mut self, op: ClassesOp, classes: &str) -> &mut Self {
self.classes.alter_value(op, classes);
self
}
#[fn_with]
pub fn alter_column(&mut self, column: grid::Column) -> &mut Self {
self.columns.add(column);
self
}
#[fn_with]
pub fn alter_template(&mut self, template: &str) -> &mut Self {
self.template = template.to_owned();
self

View file

@ -116,79 +116,44 @@ impl Heading {
// Heading BUILDER.
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
pub fn with_renderable(mut self, check: IsRenderable) -> Self {
self.alter_renderable(check);
self
}
pub fn with_id(mut self, id: &str) -> Self {
self.alter_id(id);
self
}
pub fn with_classes(mut self, op: ClassesOp, classes: &str) -> Self {
self.alter_classes(op, classes);
self
}
pub fn with_heading_type(mut self, heading_type: HeadingType) -> Self {
self.alter_heading_type(heading_type);
self
}
pub fn with_html(mut self, html: Markup) -> Self {
self.alter_html(html);
self
}
pub fn with_display(mut self, display: HeadingDisplay) -> Self {
self.alter_display(display);
self
}
pub fn using_template(mut self, template: &str) -> Self {
self.alter_template(template);
self
}
// Heading ALTER.
#[fn_with]
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}
#[fn_with]
pub fn alter_renderable(&mut self, check: IsRenderable) -> &mut Self {
self.renderable.check = check;
self
}
#[fn_with]
pub fn alter_id(&mut self, id: &str) -> &mut Self {
self.id.alter_value(id);
self
}
#[fn_with]
pub fn alter_classes(&mut self, op: ClassesOp, classes: &str) -> &mut Self {
self.classes.alter_value(op, classes);
self
}
#[fn_with]
pub fn alter_heading_type(&mut self, heading_type: HeadingType) -> &mut Self {
self.heading_type = heading_type;
self
}
#[fn_with]
pub fn alter_html(&mut self, html: Markup) -> &mut Self {
self.html.markup = html;
self
}
#[rustfmt::skip]
#[fn_with]
pub fn alter_display(&mut self, display: HeadingDisplay) -> &mut Self {
self.display = display;
self.classes.alter_value(
@ -206,6 +171,7 @@ impl Heading {
self
}
#[fn_with]
pub fn alter_template(&mut self, template: &str) -> &mut Self {
self.template = template.to_owned();
self

View file

@ -48,43 +48,25 @@ impl Html {
// Html BUILDER.
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
pub fn with_renderable(mut self, check: IsRenderable) -> Self {
self.alter_renderable(check);
self
}
pub fn with_html(mut self, html: Markup) -> Self {
self.alter_html(html);
self
}
pub fn using_template(mut self, template: &str) -> Self {
self.alter_template(template);
self
}
// Html ALTER.
#[fn_with]
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}
#[fn_with]
pub fn alter_renderable(&mut self, check: IsRenderable) -> &mut Self {
self.renderable.check = check;
self
}
#[fn_with]
pub fn alter_html(&mut self, html: Markup) -> &mut Self {
self.html.markup = html;
self
}
#[fn_with]
pub fn alter_template(&mut self, template: &str) -> &mut Self {
self.template = template.to_owned();
self

View file

@ -54,38 +54,19 @@ impl Icon {
// Icon BUILDER.
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
pub fn with_renderable(mut self, check: IsRenderable) -> Self {
self.alter_renderable(check);
self
}
pub fn with_icon_name(mut self, name: &str) -> Self {
self.alter_icon_name(name);
self
}
pub fn with_classes(mut self, op: ClassesOp, classes: &str) -> Self {
self.alter_classes(op, classes);
self
}
// Icon ALTER.
#[fn_with]
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}
#[fn_with]
pub fn alter_renderable(&mut self, check: IsRenderable) -> &mut Self {
self.renderable.check = check;
self
}
#[fn_with]
pub fn alter_icon_name(&mut self, name: &str) -> &mut Self {
self.icon_name = name.to_owned();
self.alter_classes(
@ -95,6 +76,7 @@ impl Icon {
self
}
#[fn_with]
pub fn alter_classes(&mut self, op: ClassesOp, classes: &str) -> &mut Self {
self.classes.alter_value(op, classes);
self

View file

@ -55,63 +55,37 @@ impl Image {
// Image BUILDER.
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
pub fn with_renderable(mut self, check: IsRenderable) -> Self {
self.alter_renderable(check);
self
}
pub fn with_id(mut self, id: &str) -> Self {
self.alter_id(id);
self
}
pub fn with_classes(mut self, op: ClassesOp, classes: &str) -> Self {
self.alter_classes(op, classes);
self
}
pub fn with_source(mut self, source: &str) -> Self {
self.alter_source(source);
self
}
pub fn using_template(mut self, template: &str) -> Self {
self.alter_template(template);
self
}
// Image ALTER.
#[fn_with]
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}
#[fn_with]
pub fn alter_renderable(&mut self, check: IsRenderable) -> &mut Self {
self.renderable.check = check;
self
}
#[fn_with]
pub fn alter_id(&mut self, id: &str) -> &mut Self {
self.id.alter_value(id);
self
}
#[fn_with]
pub fn alter_classes(&mut self, op: ClassesOp, classes: &str) -> &mut Self {
self.classes.alter_value(op, classes);
self
}
#[fn_with]
pub fn alter_source(&mut self, source: &str) -> &mut Self {
self.source.alter_value(source);
self
}
#[fn_with]
pub fn alter_template(&mut self, template: &str) -> &mut Self {
self.template = template.to_owned();
self

View file

@ -127,23 +127,13 @@ impl MenuItem {
// MenuItem BUILDER.
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
pub fn with_renderable(mut self, check: IsRenderable) -> Self {
self.alter_renderable(check);
self
}
// MenuItem ALTER.
#[fn_with]
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}
#[fn_with]
pub fn alter_renderable(&mut self, check: IsRenderable) -> &mut Self {
self.renderable.check = check;
self
@ -233,63 +223,37 @@ impl ComponentTrait for Menu {
impl Menu {
// Menu BUILDER.
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
pub fn with_renderable(mut self, check: IsRenderable) -> Self {
self.alter_renderable(check);
self
}
pub fn with_id(mut self, id: &str) -> Self {
self.alter_id(id);
self
}
pub fn with_classes(mut self, op: ClassesOp, classes: &str) -> Self {
self.alter_classes(op, classes);
self
}
pub fn with_item(mut self, item: MenuItem) -> Self {
self.alter_item(item);
self
}
pub fn using_template(mut self, template: &str) -> Self {
self.alter_template(template);
self
}
// Menu ALTER.
#[fn_with]
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}
#[fn_with]
pub fn alter_renderable(&mut self, check: IsRenderable) -> &mut Self {
self.renderable.check = check;
self
}
#[fn_with]
pub fn alter_id(&mut self, id: &str) -> &mut Self {
self.id.alter_value(id);
self
}
#[fn_with]
pub fn alter_classes(&mut self, op: ClassesOp, classes: &str) -> &mut Self {
self.classes.alter_value(op, classes);
self
}
#[fn_with]
pub fn alter_item(&mut self, item: MenuItem) -> &mut Self {
self.items.add(item);
self
}
#[fn_with]
pub fn alter_template(&mut self, template: &str) -> &mut Self {
self.template = template.to_owned();
self

View file

@ -69,69 +69,38 @@ impl Paragraph {
// Paragraph BUILDER.
pub fn with_weight(mut self, weight: isize) -> Self {
self.alter_weight(weight);
self
}
pub fn with_renderable(mut self, check: IsRenderable) -> Self {
self.alter_renderable(check);
self
}
pub fn with_id(mut self, id: &str) -> Self {
self.alter_id(id);
self
}
pub fn with_classes(mut self, op: ClassesOp, classes: &str) -> Self {
self.alter_classes(op, classes);
self
}
pub fn with_component(mut self, component: impl ComponentTrait) -> Self {
self.alter_component(component);
self
}
pub fn with_display(mut self, display: ParagraphDisplay) -> Self {
self.alter_display(display);
self
}
pub fn using_template(mut self, template: &str) -> Self {
self.alter_template(template);
self
}
// Paragraph ALTER.
#[fn_with]
pub fn alter_weight(&mut self, weight: isize) -> &mut Self {
self.weight = weight;
self
}
#[fn_with]
pub fn alter_renderable(&mut self, check: IsRenderable) -> &mut Self {
self.renderable.check = check;
self
}
#[fn_with]
pub fn alter_id(&mut self, id: &str) -> &mut Self {
self.id.alter_value(id);
self
}
#[fn_with]
pub fn alter_classes(&mut self, op: ClassesOp, classes: &str) -> &mut Self {
self.classes.alter_value(op, classes);
self
}
#[fn_with]
pub fn alter_component(&mut self, component: impl ComponentTrait) -> &mut Self {
self.components.add(component);
self
}
#[rustfmt::skip]
#[fn_with]
pub fn alter_display(&mut self, display: ParagraphDisplay) -> &mut Self {
self.display = display;
self.classes.alter_value(
@ -148,6 +117,7 @@ impl Paragraph {
self
}
#[fn_with]
pub fn alter_template(&mut self, template: &str) -> &mut Self {
self.template = template.to_owned();
self

View file

@ -44,6 +44,8 @@ pub use doc_comment::doc_comment;
pub use once_cell::sync::Lazy as LazyStatic;
pub use tracing_unwrap::ResultExt;
pub use pagetop_macros::fn_with;
// LOCAL.
#[allow(unused_imports)]

View file

@ -1,5 +1,5 @@
// Re-exports.
pub use crate::{concat_string, LazyStatic, ResultExt};
pub use crate::{concat_string, fn_with, LazyStatic, ResultExt};
// Macros.
pub use crate::{args, pub_config, pub_handle, pub_locale, serve_static_files};