This commit is contained in:
parent
7fadc681e9
commit
1196f00ca7
2 changed files with 17 additions and 1 deletions
|
@ -1,8 +1,17 @@
|
|||
use maud::{PreEscaped, html};
|
||||
|
||||
use crate::ui::color::UIColor;
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn MaterialIcon(identifier: &str) -> PreEscaped<String> {
|
||||
html! {
|
||||
span class="material-symbols-outlined select-none" { (identifier) };
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn ColoredMaterialIcon<C: UIColor + 'static>(identifier: &str, color: C) -> PreEscaped<String> {
|
||||
html! {
|
||||
span class=(format!("material-symbols-outlined select-none text-{}", color.color_class())) { (identifier) };
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ pub struct Form {
|
|||
action: String,
|
||||
method: Option<FormMethod>,
|
||||
multipart: bool,
|
||||
id: String,
|
||||
items: Vec<Box<dyn UIWidget>>,
|
||||
}
|
||||
|
||||
|
@ -25,10 +26,16 @@ impl Form {
|
|||
action: action.to_string(),
|
||||
method: None,
|
||||
multipart: false,
|
||||
id: String::new(),
|
||||
items: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn id(mut self, id: &str) -> Self {
|
||||
self.id = id.to_string();
|
||||
self
|
||||
}
|
||||
|
||||
pub async fn add_csrf(self, u: &User) -> Self {
|
||||
self.add_input(
|
||||
HiddenInput("csrf", &u.get_csrf().await.to_string()).add_attr("class", "csrf"),
|
||||
|
@ -81,7 +88,7 @@ impl UIWidget for Form {
|
|||
.unwrap_or("post");
|
||||
|
||||
html! {
|
||||
form action=(self.action) method=(method) enctype=(if self.multipart { "multipart/form-data" } else { "application/x-www-form-urlencoded" }) class=(class) {
|
||||
form action=(self.action) method=(method) id=(self.id) enctype=(if self.multipart { "multipart/form-data" } else { "application/x-www-form-urlencoded" }) class=(class) {
|
||||
@for item in &self.items {
|
||||
(item)
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue