💥 Consolidate component class name management
This commit is contained in:
parent
d1bfb2a799
commit
45d8c55e61
19 changed files with 178 additions and 165 deletions
|
|
@ -42,8 +42,8 @@ pub struct Input {
|
|||
impl ComponentTrait for Input {
|
||||
fn new() -> Self {
|
||||
Input::default()
|
||||
.with_classes(ClassesOp::SetDefault, "form-item")
|
||||
.with_classes(ClassesOp::Add, "form-type-textfield")
|
||||
.with_classes(ClassesOp::SetDefault, &["form-item"])
|
||||
.with_classes(ClassesOp::Add, &["form-type-textfield"])
|
||||
.with_size(Some(60))
|
||||
.with_maxlength(Some(128))
|
||||
}
|
||||
|
|
@ -116,7 +116,7 @@ impl Input {
|
|||
pub fn password() -> Self {
|
||||
let mut input = Input::new().with_classes(
|
||||
ClassesOp::Replace("form-type-textfield".to_owned()),
|
||||
"form-type-password",
|
||||
&["form-type-password"],
|
||||
);
|
||||
input.input_type = InputType::Password;
|
||||
input
|
||||
|
|
@ -125,7 +125,7 @@ impl Input {
|
|||
pub fn search() -> Self {
|
||||
let mut input = Input::new().with_classes(
|
||||
ClassesOp::Replace("form-type-textfield".to_owned()),
|
||||
"form-type-search",
|
||||
&["form-type-search"],
|
||||
);
|
||||
input.input_type = InputType::Search;
|
||||
input
|
||||
|
|
@ -134,7 +134,7 @@ impl Input {
|
|||
pub fn email() -> Self {
|
||||
let mut input = Input::new().with_classes(
|
||||
ClassesOp::Replace("form-type-textfield".to_owned()),
|
||||
"form-type-email",
|
||||
&["form-type-email"],
|
||||
);
|
||||
input.input_type = InputType::Email;
|
||||
input
|
||||
|
|
@ -143,7 +143,7 @@ impl Input {
|
|||
pub fn telephone() -> Self {
|
||||
let mut input = Input::new().with_classes(
|
||||
ClassesOp::Replace("form-type-textfield".to_owned()),
|
||||
"form-type-telephone",
|
||||
&["form-type-telephone"],
|
||||
);
|
||||
input.input_type = InputType::Telephone;
|
||||
input
|
||||
|
|
@ -152,7 +152,7 @@ impl Input {
|
|||
pub fn url() -> Self {
|
||||
let mut input = Input::new().with_classes(
|
||||
ClassesOp::Replace("form-type-textfield".to_owned()),
|
||||
"form-type-url",
|
||||
&["form-type-url"],
|
||||
);
|
||||
input.input_type = InputType::Url;
|
||||
input
|
||||
|
|
@ -173,7 +173,7 @@ impl Input {
|
|||
}
|
||||
|
||||
#[fn_builder]
|
||||
pub fn alter_classes(&mut self, op: ClassesOp, classes: &str) -> &mut Self {
|
||||
pub fn alter_classes(&mut self, op: ClassesOp, classes: &[impl ToString]) -> &mut Self {
|
||||
self.classes.alter_value(op, classes);
|
||||
self
|
||||
}
|
||||
|
|
@ -183,7 +183,7 @@ impl Input {
|
|||
self.name.alter_value(name);
|
||||
self.alter_classes(
|
||||
ClassesOp::SetDefault,
|
||||
concat_string!("form-item form-item-", name).as_str(),
|
||||
&[concat_string!("form-item form-item-", name)],
|
||||
);
|
||||
self
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue