Style the upload form
This commit is contained in:
parent
cfdceff055
commit
78c017ede7
|
@ -186,6 +186,7 @@ pub struct Button {
|
||||||
ty: Option<String>,
|
ty: Option<String>,
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
label: String,
|
label: String,
|
||||||
|
attributes: Attributes,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Button {
|
impl Button {
|
||||||
|
@ -194,6 +195,7 @@ impl Button {
|
||||||
ty: None,
|
ty: None,
|
||||||
name: None,
|
name: None,
|
||||||
label: label.to_owned(),
|
label: label.to_owned(),
|
||||||
|
attributes: Attributes::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,6 +203,19 @@ impl Button {
|
||||||
self.ty = Some(ty.to_owned());
|
self.ty = Some(ty.to_owned());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn with_attributes<'a>(
|
||||||
|
mut self,
|
||||||
|
values: impl IntoIterator<Item = (&'a str, &'a str)>,
|
||||||
|
) -> Self {
|
||||||
|
self.attributes = Attributes(
|
||||||
|
values
|
||||||
|
.into_iter()
|
||||||
|
.map(|(a, b)| (a.to_owned(), b.to_owned()))
|
||||||
|
.collect::<Vec<(String, String)>>(),
|
||||||
|
);
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Html for Button {
|
impl Html for Button {
|
||||||
|
@ -214,9 +229,10 @@ impl Html for Button {
|
||||||
None => "".to_owned(),
|
None => "".to_owned(),
|
||||||
};
|
};
|
||||||
format!(
|
format!(
|
||||||
"<button {ty} {name}>{label}</button>",
|
"<button {ty} {name} {attrs}>{label}</button>",
|
||||||
name = name,
|
name = name,
|
||||||
label = self.label
|
label = self.label,
|
||||||
|
attrs = self.attributes.to_string()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,9 +75,16 @@ pub fn upload_form() -> Form {
|
||||||
.with_container(
|
.with_container(
|
||||||
Container::new(ContainerType::Div)
|
Container::new(ContainerType::Div)
|
||||||
.with_attributes([("class", "card upload-form")])
|
.with_attributes([("class", "card upload-form")])
|
||||||
.with_html(Input::new("file", "file").with_id("for-selector-input"))
|
.with_html(Input::new("file", "file").with_attributes([
|
||||||
.with_html(Label::new("for-selector-input", "Select a file"))
|
("id", "for-selector-input"),
|
||||||
.with_html(Button::new("Upload file").with_type("submit")),
|
("placeholder", "select file"),
|
||||||
|
("class", "upload-form__selector"),
|
||||||
|
]))
|
||||||
|
.with_html(
|
||||||
|
Button::new("Upload file")
|
||||||
|
.with_attributes([("class", "upload-form__button")])
|
||||||
|
.with_type("submit"),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,14 @@ body {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.upload-form__selector {
|
||||||
|
margin: var(--space-small);
|
||||||
|
}
|
||||||
|
|
||||||
|
.upload-form__button {
|
||||||
|
margin: var(--space-small);
|
||||||
|
}
|
||||||
|
|
||||||
.gallery {
|
.gallery {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
|
Loading…
Reference in New Issue