🎨 Use default() for component constructors
This commit is contained in:
parent
306cf5dc43
commit
c3c5e46508
6 changed files with 20 additions and 20 deletions
|
|
@ -66,11 +66,11 @@ impl ComponentTrait for Button {
|
|||
|
||||
impl Button {
|
||||
pub fn with(value: L10n) -> Self {
|
||||
Button::new().with_value(value)
|
||||
Button::default().with_value(value)
|
||||
}
|
||||
|
||||
pub fn submit(value: L10n) -> Self {
|
||||
let mut button = Button::new()
|
||||
let mut button = Button::default()
|
||||
.with_classes(ClassesOp::Replace("form-button".to_owned()), "form-submit")
|
||||
.with_value(value);
|
||||
button.button_type = ButtonType::Submit;
|
||||
|
|
@ -78,7 +78,7 @@ impl Button {
|
|||
}
|
||||
|
||||
pub fn reset(value: L10n) -> Self {
|
||||
let mut button = Button::new()
|
||||
let mut button = Button::default()
|
||||
.with_classes(ClassesOp::Replace("form-button".to_owned()), "form-reset")
|
||||
.with_value(value);
|
||||
button.button_type = ButtonType::Reset;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ impl ComponentTrait for Hidden {
|
|||
|
||||
impl Hidden {
|
||||
pub fn set(name: &str, value: &str) -> Self {
|
||||
Hidden::new().with_name(name).with_value(value)
|
||||
Hidden::default().with_name(name).with_value(value)
|
||||
}
|
||||
|
||||
// Hidden BUILDER.
|
||||
|
|
|
|||
|
|
@ -104,11 +104,11 @@ impl ComponentTrait for Input {
|
|||
|
||||
impl Input {
|
||||
pub fn textfield() -> Self {
|
||||
Input::new()
|
||||
Input::default()
|
||||
}
|
||||
|
||||
pub fn password() -> Self {
|
||||
let mut input = Input::new().with_classes(
|
||||
let mut input = Input::default().with_classes(
|
||||
ClassesOp::Replace("form-type-textfield".to_owned()),
|
||||
"form-type-password",
|
||||
);
|
||||
|
|
@ -117,7 +117,7 @@ impl Input {
|
|||
}
|
||||
|
||||
pub fn search() -> Self {
|
||||
let mut input = Input::new().with_classes(
|
||||
let mut input = Input::default().with_classes(
|
||||
ClassesOp::Replace("form-type-textfield".to_owned()),
|
||||
"form-type-search",
|
||||
);
|
||||
|
|
@ -126,7 +126,7 @@ impl Input {
|
|||
}
|
||||
|
||||
pub fn email() -> Self {
|
||||
let mut input = Input::new().with_classes(
|
||||
let mut input = Input::default().with_classes(
|
||||
ClassesOp::Replace("form-type-textfield".to_owned()),
|
||||
"form-type-email",
|
||||
);
|
||||
|
|
@ -135,7 +135,7 @@ impl Input {
|
|||
}
|
||||
|
||||
pub fn telephone() -> Self {
|
||||
let mut input = Input::new().with_classes(
|
||||
let mut input = Input::default().with_classes(
|
||||
ClassesOp::Replace("form-type-textfield".to_owned()),
|
||||
"form-type-telephone",
|
||||
);
|
||||
|
|
@ -144,7 +144,7 @@ impl Input {
|
|||
}
|
||||
|
||||
pub fn url() -> Self {
|
||||
let mut input = Input::new().with_classes(
|
||||
let mut input = Input::default().with_classes(
|
||||
ClassesOp::Replace("form-type-textfield".to_owned()),
|
||||
"form-type-url",
|
||||
);
|
||||
|
|
|
|||
|
|
@ -89,37 +89,37 @@ impl ComponentTrait for Heading {
|
|||
|
||||
impl Heading {
|
||||
pub fn h1(text: L10n) -> Self {
|
||||
Heading::new()
|
||||
Heading::default()
|
||||
.with_heading_type(HeadingType::H1)
|
||||
.with_text(text)
|
||||
}
|
||||
|
||||
pub fn h2(text: L10n) -> Self {
|
||||
Heading::new()
|
||||
Heading::default()
|
||||
.with_heading_type(HeadingType::H2)
|
||||
.with_text(text)
|
||||
}
|
||||
|
||||
pub fn h3(text: L10n) -> Self {
|
||||
Heading::new()
|
||||
Heading::default()
|
||||
.with_heading_type(HeadingType::H3)
|
||||
.with_text(text)
|
||||
}
|
||||
|
||||
pub fn h4(text: L10n) -> Self {
|
||||
Heading::new()
|
||||
Heading::default()
|
||||
.with_heading_type(HeadingType::H4)
|
||||
.with_text(text)
|
||||
}
|
||||
|
||||
pub fn h5(text: L10n) -> Self {
|
||||
Heading::new()
|
||||
Heading::default()
|
||||
.with_heading_type(HeadingType::H5)
|
||||
.with_text(text)
|
||||
}
|
||||
|
||||
pub fn h6(text: L10n) -> Self {
|
||||
Heading::new()
|
||||
Heading::default()
|
||||
.with_heading_type(HeadingType::H6)
|
||||
.with_text(text)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ pub struct Icon {
|
|||
|
||||
impl ComponentTrait for Icon {
|
||||
fn new() -> Self {
|
||||
Icon::default().with_icon_name("question-circle-fill")
|
||||
Icon::default()
|
||||
}
|
||||
|
||||
fn handle(&self) -> Handle {
|
||||
|
|
@ -40,7 +40,7 @@ impl ComponentTrait for Icon {
|
|||
|
||||
impl Icon {
|
||||
pub fn with(icon_name: &str) -> Self {
|
||||
Icon::new().with_icon_name(icon_name)
|
||||
Icon::default().with_icon_name(icon_name)
|
||||
}
|
||||
|
||||
// Icon BUILDER.
|
||||
|
|
|
|||
|
|
@ -48,11 +48,11 @@ impl ComponentTrait for Paragraph {
|
|||
|
||||
impl Paragraph {
|
||||
pub fn with(component: impl ComponentTrait) -> Self {
|
||||
Paragraph::new().add_component(component)
|
||||
Paragraph::default().add_component(component)
|
||||
}
|
||||
|
||||
pub fn translated(l10n: L10n) -> Self {
|
||||
Paragraph::new().add_translated(l10n)
|
||||
Paragraph::default().add_translated(l10n)
|
||||
}
|
||||
|
||||
// Paragraph BUILDER.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue