🚚 Restore macro name #[fn_builder] for fn_with
This commit is contained in:
parent
2389aad546
commit
a9a5d232a2
36 changed files with 190 additions and 187 deletions
|
|
@ -14,11 +14,11 @@ pub fn html(input: TokenStream) -> TokenStream {
|
|||
}
|
||||
|
||||
#[proc_macro_attribute]
|
||||
pub fn fn_with(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||
pub fn fn_builder(_: TokenStream, item: TokenStream) -> TokenStream {
|
||||
let fn_item = parse_macro_input!(item as ItemFn);
|
||||
let fn_name = fn_item.sig.ident.to_string();
|
||||
let fn_alter_name = fn_item.sig.ident.to_string();
|
||||
|
||||
if !fn_name.starts_with("alter_") {
|
||||
if !fn_alter_name.starts_with("alter_") {
|
||||
let expanded = quote_spanned! {
|
||||
fn_item.sig.ident.span() =>
|
||||
compile_error!("expected a \"pub fn alter_...() -> &mut Self\" method");
|
||||
|
|
@ -45,12 +45,12 @@ pub fn fn_with(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
|||
})
|
||||
.collect();
|
||||
|
||||
let fn_with_name = fn_name.replace("alter_", "with_");
|
||||
let fn_with_name = fn_alter_name.replace("alter_", "with_");
|
||||
|
||||
#[rustfmt::skip]
|
||||
let fn_with = parse_str::<ItemFn>(concat_string!("
|
||||
pub fn ", fn_with_name, "(mut self, ", args.join(", "), ") -> Self {
|
||||
self.", fn_name, "(", param.join(", "), ");
|
||||
self.", fn_alter_name, "(", param.join(", "), ");
|
||||
self
|
||||
}
|
||||
").as_str()).unwrap();
|
||||
|
|
@ -117,7 +117,7 @@ pub fn test(_: TokenStream, item: TokenStream) -> TokenStream {
|
|||
}
|
||||
|
||||
#[proc_macro_derive(AutoDefault, attributes(default))]
|
||||
pub fn derive_auto_default(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
|
||||
pub fn derive_auto_default(input: TokenStream) -> TokenStream {
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
match smart_default::body_impl::impl_my_derive(&input) {
|
||||
Ok(output) => output.into(),
|
||||
|
|
|
|||
|
|
@ -52,25 +52,25 @@ impl ComponentTrait for Block {
|
|||
impl Block {
|
||||
// Block BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_id(&mut self, id: impl Into<String>) -> &mut Self {
|
||||
self.id.alter_value(id);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_weight(&mut self, value: Weight) -> &mut Self {
|
||||
self.weight = value;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_renderable(&mut self, check: FnIsRenderable) -> &mut Self {
|
||||
self.renderable.check = check;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_title(&mut self, title: L10n) -> &mut Self {
|
||||
self.title.alter_value(title);
|
||||
self
|
||||
|
|
@ -82,7 +82,7 @@ impl Block {
|
|||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_components(&mut self, op: ArcAnyOp) -> &mut Self {
|
||||
self.stuff.alter_value(op);
|
||||
self
|
||||
|
|
|
|||
|
|
@ -61,43 +61,43 @@ impl ComponentTrait for Branding {
|
|||
impl Branding {
|
||||
// Branding BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_id(&mut self, id: impl Into<String>) -> &mut Self {
|
||||
self.id.alter_value(id);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_weight(&mut self, value: Weight) -> &mut Self {
|
||||
self.weight = value;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_renderable(&mut self, check: FnIsRenderable) -> &mut Self {
|
||||
self.renderable.check = check;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_app_name(&mut self, app_name: impl Into<String>) -> &mut Self {
|
||||
self.app_name = app_name.into();
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_slogan(&mut self, slogan: L10n) -> &mut Self {
|
||||
self.slogan.alter_value(slogan);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_logo(&mut self, logo: Option<Image>) -> &mut Self {
|
||||
self.logo.alter_value(logo);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_frontpage(&mut self, frontpage: FnContextualPath) -> &mut Self {
|
||||
self.frontpage = frontpage;
|
||||
self
|
||||
|
|
|
|||
|
|
@ -78,61 +78,61 @@ impl Button {
|
|||
|
||||
// Button BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_id(&mut self, id: impl Into<String>) -> &mut Self {
|
||||
self.id.alter_value(id);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_weight(&mut self, value: Weight) -> &mut Self {
|
||||
self.weight = value;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_renderable(&mut self, check: FnIsRenderable) -> &mut Self {
|
||||
self.renderable.check = check;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_style(&mut self, style: ButtonStyle) -> &mut Self {
|
||||
self.style = style;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_font_size(&mut self, font_size: FontSize) -> &mut Self {
|
||||
self.font_size = font_size;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_left_icon(&mut self, icon: Option<Icon>) -> &mut Self {
|
||||
self.left_icon.alter_value(icon);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_right_icon(&mut self, icon: Option<Icon>) -> &mut Self {
|
||||
self.right_icon.alter_value(icon);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_href(&mut self, href: impl Into<String>) -> &mut Self {
|
||||
self.href.alter_value(href);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_html(&mut self, html: L10n) -> &mut Self {
|
||||
self.html.alter_value(html);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_target(&mut self, target: ButtonTarget) -> &mut Self {
|
||||
self.target = target;
|
||||
self
|
||||
|
|
|
|||
|
|
@ -63,19 +63,19 @@ impl ComponentTrait for Container {
|
|||
impl Container {
|
||||
// Container BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_id(&mut self, id: impl Into<String>) -> &mut Self {
|
||||
self.id.alter_value(id);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_weight(&mut self, value: Weight) -> &mut Self {
|
||||
self.weight = value;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_renderable(&mut self, check: FnIsRenderable) -> &mut Self {
|
||||
self.renderable.check = check;
|
||||
self
|
||||
|
|
@ -87,37 +87,37 @@ impl Container {
|
|||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_items(&mut self, op: ArcTypedOp<flex::Item>) -> &mut Self {
|
||||
self.items.alter_value(op);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_direction(&mut self, direction: flex::Direction) -> &mut Self {
|
||||
self.direction = direction;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_wrap_align(&mut self, wrap: flex::WrapAlign) -> &mut Self {
|
||||
self.wrap_align = wrap;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_content_justify(&mut self, justify: flex::ContentJustify) -> &mut Self {
|
||||
self.content_justify = justify;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_items_align(&mut self, align: flex::ItemAlign) -> &mut Self {
|
||||
self.items_align = align;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_gap(&mut self, gap: flex::Gap) -> &mut Self {
|
||||
self.gap = gap;
|
||||
self
|
||||
|
|
|
|||
|
|
@ -67,55 +67,55 @@ impl ComponentTrait for Item {
|
|||
impl Item {
|
||||
// Item BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_id(&mut self, id: impl Into<String>) -> &mut Self {
|
||||
self.id.alter_value(id);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_weight(&mut self, value: Weight) -> &mut Self {
|
||||
self.weight = value;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_renderable(&mut self, check: FnIsRenderable) -> &mut Self {
|
||||
self.renderable.check = check;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_inner_classes(&mut self, op: ClassesOp, classes: impl Into<String>) -> &mut Self {
|
||||
self.inner_classes.alter_value(op, classes);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_grow(&mut self, grow: flex::ItemGrow) -> &mut Self {
|
||||
self.item_grow = grow;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_shrink(&mut self, shrink: flex::ItemShrink) -> &mut Self {
|
||||
self.item_shrink = shrink;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_size(&mut self, size: flex::ItemSize) -> &mut Self {
|
||||
self.item_size = size;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_offset(&mut self, offset: flex::ItemOffset) -> &mut Self {
|
||||
self.item_offset = offset;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_align(&mut self, align: flex::ItemAlign) -> &mut Self {
|
||||
self.item_align = align;
|
||||
self
|
||||
|
|
@ -127,7 +127,7 @@ impl Item {
|
|||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_components(&mut self, op: ArcAnyOp) -> &mut Self {
|
||||
self.stuff.alter_value(op);
|
||||
self
|
||||
|
|
|
|||
|
|
@ -92,55 +92,55 @@ impl ActionButton {
|
|||
|
||||
// Button BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_weight(&mut self, value: Weight) -> &mut Self {
|
||||
self.weight = value;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_renderable(&mut self, check: FnIsRenderable) -> &mut Self {
|
||||
self.renderable.check = check;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_style(&mut self, style: ButtonStyle) -> &mut Self {
|
||||
self.style = style;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_font_size(&mut self, font_size: FontSize) -> &mut Self {
|
||||
self.font_size = font_size;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_left_icon(&mut self, icon: Option<Icon>) -> &mut Self {
|
||||
self.left_icon.alter_value(icon);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_right_icon(&mut self, icon: Option<Icon>) -> &mut Self {
|
||||
self.right_icon.alter_value(icon);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_name(&mut self, name: &str) -> &mut Self {
|
||||
self.name.alter_value(name);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_value(&mut self, value: L10n) -> &mut Self {
|
||||
self.value.alter_value(value);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_autofocus(&mut self, toggle: bool) -> &mut Self {
|
||||
self.autofocus.alter_value(match toggle {
|
||||
true => "autofocus",
|
||||
|
|
@ -149,7 +149,7 @@ impl ActionButton {
|
|||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_disabled(&mut self, toggle: bool) -> &mut Self {
|
||||
self.disabled.alter_value(match toggle {
|
||||
true => "disabled",
|
||||
|
|
|
|||
|
|
@ -68,43 +68,43 @@ impl ComponentTrait for Date {
|
|||
impl Date {
|
||||
// Date BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_weight(&mut self, value: Weight) -> &mut Self {
|
||||
self.weight = value;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_renderable(&mut self, check: FnIsRenderable) -> &mut Self {
|
||||
self.renderable.check = check;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_name(&mut self, name: &str) -> &mut Self {
|
||||
self.name.alter_value(name);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_value(&mut self, value: &str) -> &mut Self {
|
||||
self.value.alter_value(value);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_label(&mut self, label: &str) -> &mut Self {
|
||||
self.label.alter_value(label);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_placeholder(&mut self, placeholder: &str) -> &mut Self {
|
||||
self.placeholder.alter_value(placeholder);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_autofocus(&mut self, toggle: bool) -> &mut Self {
|
||||
self.autofocus.alter_value(match toggle {
|
||||
true => "autofocus",
|
||||
|
|
@ -113,7 +113,7 @@ impl Date {
|
|||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_autocomplete(&mut self, toggle: bool) -> &mut Self {
|
||||
self.autocomplete.alter_value(match toggle {
|
||||
true => "",
|
||||
|
|
@ -122,7 +122,7 @@ impl Date {
|
|||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_disabled(&mut self, toggle: bool) -> &mut Self {
|
||||
self.disabled.alter_value(match toggle {
|
||||
true => "disabled",
|
||||
|
|
@ -131,7 +131,7 @@ impl Date {
|
|||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_readonly(&mut self, toggle: bool) -> &mut Self {
|
||||
self.readonly.alter_value(match toggle {
|
||||
true => "readonly",
|
||||
|
|
@ -140,7 +140,7 @@ impl Date {
|
|||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_required(&mut self, toggle: bool) -> &mut Self {
|
||||
self.required.alter_value(match toggle {
|
||||
true => "required",
|
||||
|
|
@ -149,7 +149,7 @@ impl Date {
|
|||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_help_text(&mut self, help_text: &str) -> &mut Self {
|
||||
self.help_text.alter_value(help_text);
|
||||
self
|
||||
|
|
|
|||
|
|
@ -61,37 +61,37 @@ impl ComponentTrait for Form {
|
|||
impl Form {
|
||||
// Form BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_id(&mut self, id: impl Into<String>) -> &mut Self {
|
||||
self.id.alter_value(id);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_weight(&mut self, value: Weight) -> &mut Self {
|
||||
self.weight = value;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_renderable(&mut self, check: FnIsRenderable) -> &mut Self {
|
||||
self.renderable.check = check;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_action(&mut self, action: &str) -> &mut Self {
|
||||
self.action.alter_value(action);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_charset(&mut self, charset: &str) -> &mut Self {
|
||||
self.charset.alter_value(charset);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_method(&mut self, method: FormMethod) -> &mut Self {
|
||||
self.method = method;
|
||||
self
|
||||
|
|
@ -103,7 +103,7 @@ impl Form {
|
|||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_elements(&mut self, op: ArcAnyOp) -> &mut Self {
|
||||
self.stuff.alter_value(op);
|
||||
self
|
||||
|
|
|
|||
|
|
@ -32,19 +32,19 @@ impl Hidden {
|
|||
|
||||
// Hidden BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_weight(&mut self, value: Weight) -> &mut Self {
|
||||
self.weight = value;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_name(&mut self, name: &str) -> &mut Self {
|
||||
self.name.alter_value(name);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_value(&mut self, value: &str) -> &mut Self {
|
||||
self.value.alter_value(value);
|
||||
self
|
||||
|
|
|
|||
|
|
@ -147,19 +147,19 @@ impl Input {
|
|||
|
||||
// Input BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_weight(&mut self, value: Weight) -> &mut Self {
|
||||
self.weight = value;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_renderable(&mut self, check: FnIsRenderable) -> &mut Self {
|
||||
self.renderable.check = check;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_name(&mut self, name: &str) -> &mut Self {
|
||||
if let Some(previous) = self.name.get() {
|
||||
self.remove_classes(concat_string!("form-item-", previous));
|
||||
|
|
@ -169,43 +169,43 @@ impl Input {
|
|||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_value(&mut self, value: &str) -> &mut Self {
|
||||
self.value.alter_value(value);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_label(&mut self, label: L10n) -> &mut Self {
|
||||
self.label.alter_value(label);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_size(&mut self, size: Option<u16>) -> &mut Self {
|
||||
self.size = size;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_minlength(&mut self, minlength: Option<u16>) -> &mut Self {
|
||||
self.minlength = minlength;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_maxlength(&mut self, maxlength: Option<u16>) -> &mut Self {
|
||||
self.maxlength = maxlength;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_placeholder(&mut self, placeholder: &str) -> &mut Self {
|
||||
self.placeholder.alter_value(placeholder);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_autofocus(&mut self, toggle: bool) -> &mut Self {
|
||||
self.autofocus.alter_value(match toggle {
|
||||
true => "autofocus",
|
||||
|
|
@ -214,7 +214,7 @@ impl Input {
|
|||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_autocomplete(&mut self, toggle: bool) -> &mut Self {
|
||||
self.autocomplete.alter_value(match toggle {
|
||||
true => "",
|
||||
|
|
@ -223,7 +223,7 @@ impl Input {
|
|||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_disabled(&mut self, toggle: bool) -> &mut Self {
|
||||
self.disabled.alter_value(match toggle {
|
||||
true => "disabled",
|
||||
|
|
@ -232,7 +232,7 @@ impl Input {
|
|||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_readonly(&mut self, toggle: bool) -> &mut Self {
|
||||
self.readonly.alter_value(match toggle {
|
||||
true => "readonly",
|
||||
|
|
@ -241,7 +241,7 @@ impl Input {
|
|||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_required(&mut self, toggle: bool) -> &mut Self {
|
||||
self.required.alter_value(match toggle {
|
||||
true => "required",
|
||||
|
|
@ -250,7 +250,7 @@ impl Input {
|
|||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_help_text(&mut self, help_text: L10n) -> &mut Self {
|
||||
self.help_text.alter_value(help_text);
|
||||
self
|
||||
|
|
|
|||
|
|
@ -125,37 +125,37 @@ impl Heading {
|
|||
|
||||
// Heading BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_id(&mut self, id: impl Into<String>) -> &mut Self {
|
||||
self.id.alter_value(id);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_weight(&mut self, value: Weight) -> &mut Self {
|
||||
self.weight = value;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_renderable(&mut self, check: FnIsRenderable) -> &mut Self {
|
||||
self.renderable.check = check;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_heading_type(&mut self, heading_type: HeadingType) -> &mut Self {
|
||||
self.heading_type = heading_type;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_size(&mut self, size: HeadingSize) -> &mut Self {
|
||||
self.size = size;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_text(&mut self, text: L10n) -> &mut Self {
|
||||
self.text.alter_value(text);
|
||||
self
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ impl Html {
|
|||
|
||||
// Html BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_html(&mut self, html: Markup) -> &mut Self {
|
||||
self.0 = html;
|
||||
self
|
||||
|
|
|
|||
|
|
@ -48,25 +48,25 @@ impl Icon {
|
|||
|
||||
// Icon BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_weight(&mut self, value: Weight) -> &mut Self {
|
||||
self.weight = value;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_renderable(&mut self, check: FnIsRenderable) -> &mut Self {
|
||||
self.renderable.check = check;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_icon_name(&mut self, name: impl Into<String>) -> &mut Self {
|
||||
self.icon_name.alter_value(name);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_font_size(&mut self, font_size: FontSize) -> &mut Self {
|
||||
self.font_size = font_size;
|
||||
self
|
||||
|
|
|
|||
|
|
@ -82,31 +82,31 @@ impl Image {
|
|||
|
||||
// Image BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_id(&mut self, id: impl Into<String>) -> &mut Self {
|
||||
self.id.alter_value(id);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_weight(&mut self, value: Weight) -> &mut Self {
|
||||
self.weight = value;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_renderable(&mut self, check: FnIsRenderable) -> &mut Self {
|
||||
self.renderable.check = check;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_source(&mut self, source: &str) -> &mut Self {
|
||||
self.source.alter_value(source);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_size(&mut self, size: ImageSize) -> &mut Self {
|
||||
self.size = size;
|
||||
self
|
||||
|
|
|
|||
|
|
@ -66,13 +66,13 @@ impl Element {
|
|||
|
||||
// Element BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_weight(&mut self, value: Weight) -> &mut Self {
|
||||
self.weight = value;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_renderable(&mut self, check: FnIsRenderable) -> &mut Self {
|
||||
self.renderable.check = check;
|
||||
self
|
||||
|
|
|
|||
|
|
@ -40,19 +40,19 @@ impl ComponentTrait for Group {
|
|||
impl Group {
|
||||
// Group BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_id(&mut self, id: impl Into<String>) -> &mut Self {
|
||||
self.id.alter_value(id);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_weight(&mut self, value: Weight) -> &mut Self {
|
||||
self.weight = value;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_renderable(&mut self, check: FnIsRenderable) -> &mut Self {
|
||||
self.renderable.check = check;
|
||||
self
|
||||
|
|
@ -64,7 +64,7 @@ impl Group {
|
|||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_elements(&mut self, op: ArcTypedOp<Element>) -> &mut Self {
|
||||
self.elements.alter_value(op);
|
||||
self
|
||||
|
|
|
|||
|
|
@ -156,31 +156,31 @@ impl Item {
|
|||
|
||||
// Item BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_weight(&mut self, value: Weight) -> &mut Self {
|
||||
self.weight = value;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_renderable(&mut self, check: FnIsRenderable) -> &mut Self {
|
||||
self.renderable.check = check;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_description(&mut self, text: L10n) -> &mut Self {
|
||||
self.description.alter_value(text);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_left_icon(&mut self, icon: Option<Icon>) -> &mut Self {
|
||||
self.left_icon.alter_value(icon);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_right_icon(&mut self, icon: Option<Icon>) -> &mut Self {
|
||||
self.right_icon.alter_value(icon);
|
||||
self
|
||||
|
|
|
|||
|
|
@ -40,19 +40,19 @@ impl ComponentTrait for Megamenu {
|
|||
impl Megamenu {
|
||||
// Megamenu BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_id(&mut self, id: impl Into<String>) -> &mut Self {
|
||||
self.id.alter_value(id);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_weight(&mut self, value: Weight) -> &mut Self {
|
||||
self.weight = value;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_renderable(&mut self, check: FnIsRenderable) -> &mut Self {
|
||||
self.renderable.check = check;
|
||||
self
|
||||
|
|
@ -64,7 +64,7 @@ impl Megamenu {
|
|||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_groups(&mut self, op: ArcTypedOp<Group>) -> &mut Self {
|
||||
self.groups.alter_value(op);
|
||||
self
|
||||
|
|
|
|||
|
|
@ -68,19 +68,19 @@ impl ComponentTrait for Menu {
|
|||
impl Menu {
|
||||
// Menu BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_id(&mut self, id: impl Into<String>) -> &mut Self {
|
||||
self.id.alter_value(id);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_weight(&mut self, value: Weight) -> &mut Self {
|
||||
self.weight = value;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_renderable(&mut self, check: FnIsRenderable) -> &mut Self {
|
||||
self.renderable.check = check;
|
||||
self
|
||||
|
|
@ -92,7 +92,7 @@ impl Menu {
|
|||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_items(&mut self, op: ArcTypedOp<Item>) -> &mut Self {
|
||||
self.items.alter_value(op);
|
||||
self
|
||||
|
|
|
|||
|
|
@ -46,25 +46,25 @@ impl ComponentTrait for Submenu {
|
|||
impl Submenu {
|
||||
// Submenu BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_id(&mut self, id: impl Into<String>) -> &mut Self {
|
||||
self.id.alter_value(id);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_weight(&mut self, value: Weight) -> &mut Self {
|
||||
self.weight = value;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_renderable(&mut self, check: FnIsRenderable) -> &mut Self {
|
||||
self.renderable.check = check;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_title(&mut self, title: L10n) -> &mut Self {
|
||||
self.title.alter_value(title);
|
||||
self
|
||||
|
|
@ -76,7 +76,7 @@ impl Submenu {
|
|||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_items(&mut self, op: ArcTypedOp<Item>) -> &mut Self {
|
||||
self.items.alter_value(op);
|
||||
self
|
||||
|
|
|
|||
|
|
@ -55,25 +55,25 @@ impl Paragraph {
|
|||
|
||||
// Paragraph BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_id(&mut self, id: impl Into<String>) -> &mut Self {
|
||||
self.id.alter_value(id);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_weight(&mut self, value: Weight) -> &mut Self {
|
||||
self.weight = value;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_renderable(&mut self, check: FnIsRenderable) -> &mut Self {
|
||||
self.renderable.check = check;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_font_size(&mut self, font_size: FontSize) -> &mut Self {
|
||||
self.font_size = font_size;
|
||||
self
|
||||
|
|
@ -91,7 +91,7 @@ impl Paragraph {
|
|||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_components(&mut self, op: ArcAnyOp) -> &mut Self {
|
||||
self.stuff.alter_value(op);
|
||||
self
|
||||
|
|
|
|||
|
|
@ -71,25 +71,25 @@ impl ComponentTrait for PoweredBy {
|
|||
impl PoweredBy {
|
||||
// PoweredBy BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_weight(&mut self, value: Weight) -> &mut Self {
|
||||
self.weight = value;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_renderable(&mut self, check: FnIsRenderable) -> &mut Self {
|
||||
self.renderable.check = check;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_copyright(&mut self, copyright: Option<impl Into<String>>) -> &mut Self {
|
||||
self.copyright = copyright.map(|c| c.into());
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_logo(&mut self, logo: PoweredByLogo) -> &mut Self {
|
||||
self.logo = logo;
|
||||
self
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ impl Translate {
|
|||
|
||||
// Translate BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_l10n(&mut self, l10n: L10n) -> &mut Self {
|
||||
self.0 = l10n;
|
||||
self
|
||||
|
|
|
|||
|
|
@ -115,25 +115,25 @@ impl Wrapper {
|
|||
|
||||
// Wrapper BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_id(&mut self, id: impl Into<String>) -> &mut Self {
|
||||
self.id.alter_value(id);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_weight(&mut self, value: Weight) -> &mut Self {
|
||||
self.weight = value;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_renderable(&mut self, check: FnIsRenderable) -> &mut Self {
|
||||
self.renderable.check = check;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_inner_classes(&mut self, op: ClassesOp, classes: impl Into<String>) -> &mut Self {
|
||||
self.inner_classes.alter_value(op, classes);
|
||||
self
|
||||
|
|
@ -145,7 +145,7 @@ impl Wrapper {
|
|||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_components(&mut self, op: ArcAnyOp) -> &mut Self {
|
||||
self.stuff.alter_value(op);
|
||||
self
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::core::component::{ComponentTrait, Context};
|
||||
use crate::html::{html, Markup};
|
||||
use crate::{fn_with, TypeId, Weight};
|
||||
use crate::{fn_builder, TypeId, Weight};
|
||||
|
||||
use std::sync::{Arc, RwLock, RwLockReadGuard, RwLockWriteGuard};
|
||||
|
||||
|
|
@ -79,7 +79,7 @@ impl AnyComponents {
|
|||
|
||||
// AnyComponents BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_value(&mut self, op: ArcAnyOp) -> &mut Self {
|
||||
match op {
|
||||
ArcAnyOp::Add(arc) => self.0.push(arc),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::core::component::{ComponentTrait, Context};
|
||||
use crate::html::{html, Markup};
|
||||
use crate::{fn_with, TypeId, Weight};
|
||||
use crate::{fn_builder, TypeId, Weight};
|
||||
|
||||
use std::sync::{Arc, RwLock, RwLockReadGuard, RwLockWriteGuard};
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ impl<C: ComponentTrait + Default> TypedComponents<C> {
|
|||
|
||||
// TypedComponents BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_value(&mut self, op: ArcTypedOp<C>) -> &mut Self {
|
||||
match op {
|
||||
ArcTypedOp::Add(one) => self.0.push(one),
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
//! **OptionClasses** assumes that the order of the classes is irrelevant
|
||||
//! (<https://stackoverflow.com/a/1321712>), and duplicate classes will not be allowed.
|
||||
|
||||
use crate::{fn_with, AutoDefault};
|
||||
use crate::{fn_builder, AutoDefault};
|
||||
|
||||
pub enum ClassesOp {
|
||||
Add,
|
||||
|
|
@ -30,7 +30,7 @@ impl OptionClasses {
|
|||
|
||||
// OptionClasses BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_value(&mut self, op: ClassesOp, classes: impl Into<String>) -> &mut Self {
|
||||
let classes: String = classes.into();
|
||||
let classes: Vec<&str> = classes.split_ascii_whitespace().collect();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::core::component::{ArcTypedComponent, ComponentTrait, Context};
|
||||
use crate::fn_with;
|
||||
use crate::fn_builder;
|
||||
use crate::html::{html, Markup};
|
||||
|
||||
pub struct OptionComponent<C: ComponentTrait>(Option<ArcTypedComponent<C>>);
|
||||
|
|
@ -17,7 +17,7 @@ impl<C: ComponentTrait> OptionComponent<C> {
|
|||
|
||||
// OptionComponent BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_value(&mut self, component: Option<C>) -> &mut Self {
|
||||
if let Some(component) = component {
|
||||
self.0 = Some(ArcTypedComponent::new(component));
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{fn_with, AutoDefault};
|
||||
use crate::{fn_builder, AutoDefault};
|
||||
|
||||
#[derive(AutoDefault)]
|
||||
pub struct OptionId(Option<String>);
|
||||
|
|
@ -10,7 +10,7 @@ impl OptionId {
|
|||
|
||||
// OptionId BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_value(&mut self, value: impl Into<String>) -> &mut Self {
|
||||
self.0 = Some(value.into().trim().replace(' ', "_"));
|
||||
self
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{fn_with, AutoDefault};
|
||||
use crate::{fn_builder, AutoDefault};
|
||||
|
||||
#[derive(AutoDefault)]
|
||||
pub struct OptionName(Option<String>);
|
||||
|
|
@ -10,7 +10,7 @@ impl OptionName {
|
|||
|
||||
// OptionName BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_value(&mut self, value: impl Into<String>) -> &mut Self {
|
||||
self.0 = Some(value.into().trim().replace(' ', "_"));
|
||||
self
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{fn_with, AutoDefault};
|
||||
use crate::{fn_builder, AutoDefault};
|
||||
|
||||
#[derive(AutoDefault)]
|
||||
pub struct OptionString(Option<String>);
|
||||
|
|
@ -10,7 +10,7 @@ impl OptionString {
|
|||
|
||||
// OptionString BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_value(&mut self, value: impl Into<String>) -> &mut Self {
|
||||
self.0 = Some(value.into().trim().to_owned());
|
||||
self
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::html::Markup;
|
||||
use crate::locale::{L10n, LanguageIdentifier};
|
||||
use crate::{fn_with, AutoDefault};
|
||||
use crate::{fn_builder, AutoDefault};
|
||||
|
||||
#[derive(AutoDefault)]
|
||||
pub struct OptionTranslated(L10n);
|
||||
|
|
@ -12,7 +12,7 @@ impl OptionTranslated {
|
|||
|
||||
// OptionTranslated BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_value(&mut self, value: L10n) -> &mut Self {
|
||||
self.0 = value;
|
||||
self
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ pub use concat_string::concat_string;
|
|||
/// Enables flexible identifier concatenation in macros, allowing new items with pasted identifiers.
|
||||
pub use paste::paste;
|
||||
|
||||
pub use pagetop_macros::{fn_with, main, test, AutoDefault, ComponentClasses};
|
||||
pub use pagetop_macros::{fn_builder, main, test, AutoDefault, ComponentClasses};
|
||||
|
||||
// *************************************************************************************************
|
||||
// GLOBAL.
|
||||
|
|
@ -90,12 +90,12 @@ pub use pagetop_macros::{fn_with, main, test, AutoDefault, ComponentClasses};
|
|||
pub use once_cell::sync::Lazy as LazyStatic;
|
||||
pub use static_files::Resource as StaticResource;
|
||||
|
||||
pub type HashMapResources = std::collections::HashMap<&'static str, StaticResource>;
|
||||
|
||||
pub use std::any::TypeId;
|
||||
|
||||
pub type Weight = i8;
|
||||
|
||||
pub type HashMapResources = std::collections::HashMap<&'static str, StaticResource>;
|
||||
|
||||
static_locales!(LOCALES_PAGETOP);
|
||||
|
||||
// *************************************************************************************************
|
||||
|
|
|
|||
|
|
@ -1,29 +1,31 @@
|
|||
//! The PageTop Prelude.
|
||||
|
||||
// Re-exported macros and derives.
|
||||
pub use crate::{concat_string, fn_with, html, main, paste, test, AutoDefault, ComponentClasses};
|
||||
// RE-EXPORTED MACROS AND DERIVES.
|
||||
pub use crate::{concat_string, fn_builder, main, paste, test};
|
||||
pub use crate::{AutoDefault, ComponentClasses};
|
||||
|
||||
// Global.
|
||||
// GLOBAL.
|
||||
pub use crate::{HashMapResources, LazyStatic, TypeId, Weight};
|
||||
|
||||
// Functions and macro helpers.
|
||||
pub use crate::util;
|
||||
|
||||
// MACROS.
|
||||
|
||||
// crate::config
|
||||
pub use crate::default_settings;
|
||||
// crate::html
|
||||
pub use crate::html;
|
||||
// crate::locale
|
||||
pub use crate::static_locales;
|
||||
// crate::service
|
||||
pub use crate::{service_for_static_files, static_files};
|
||||
// crate::core::actions
|
||||
// crate::core::action
|
||||
pub use crate::actions;
|
||||
// crate::util
|
||||
pub use crate::kv;
|
||||
|
||||
// API.
|
||||
|
||||
pub use crate::util;
|
||||
|
||||
pub use crate::config;
|
||||
|
||||
pub use crate::trace;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use crate::base::action;
|
|||
use crate::core::component::{AnyComponents, ArcAnyComponent, ComponentTrait};
|
||||
use crate::core::component::{Context, ContextOp};
|
||||
use crate::core::theme::ComponentsInRegions;
|
||||
use crate::fn_builder;
|
||||
use crate::html::{html, Markup, DOCTYPE};
|
||||
use crate::html::{ClassesOp, Favicon, OptionClasses, OptionId, OptionTranslated};
|
||||
use crate::locale::L10n;
|
||||
|
|
@ -49,68 +50,68 @@ impl Page {
|
|||
|
||||
// Page BUILDER.
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_title(&mut self, title: L10n) -> &mut Self {
|
||||
self.title.alter_value(title);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_description(&mut self, description: L10n) -> &mut Self {
|
||||
self.description.alter_value(description);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_metadata(&mut self, name: &'static str, content: &'static str) -> &mut Self {
|
||||
self.metadata.push((name, content));
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_property(&mut self, property: &'static str, content: &'static str) -> &mut Self {
|
||||
self.metadata.push((property, content));
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_favicon(&mut self, favicon: Option<Favicon>) -> &mut Self {
|
||||
self.favicon = favicon;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_context(&mut self, op: ContextOp) -> &mut Self {
|
||||
self.context.alter(op);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_body_id(&mut self, id: impl Into<String>) -> &mut Self {
|
||||
self.body_id.alter_value(id);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_body_classes(&mut self, op: ClassesOp, classes: impl Into<String>) -> &mut Self {
|
||||
self.body_classes.alter_value(op, classes);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_skip_to(&mut self, id: impl Into<String>) -> &mut Self {
|
||||
self.skip_to.alter_value(id);
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_component(&mut self, component: impl ComponentTrait) -> &mut Self {
|
||||
self.regions
|
||||
.add_component_in("content", ArcAnyComponent::new(component));
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_component_in(
|
||||
&mut self,
|
||||
region: &'static str,
|
||||
|
|
@ -121,7 +122,7 @@ impl Page {
|
|||
self
|
||||
}
|
||||
|
||||
#[fn_with]
|
||||
#[fn_builder]
|
||||
pub fn alter_template(&mut self, template: &str) -> &mut Self {
|
||||
self.template = template.to_owned();
|
||||
self
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue