From 1196f00ca72fea6f8e3503f7ae8de9801e259e4e Mon Sep 17 00:00:00 2001 From: JMARyA Date: Wed, 19 Feb 2025 23:08:57 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ui/components/icon.rs | 9 +++++++++ src/ui/primitives/input/form.rs | 9 ++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/ui/components/icon.rs b/src/ui/components/icon.rs index 240f96d..5454c64 100644 --- a/src/ui/components/icon.rs +++ b/src/ui/components/icon.rs @@ -1,8 +1,17 @@ use maud::{PreEscaped, html}; +use crate::ui::color::UIColor; + #[allow(non_snake_case)] pub fn MaterialIcon(identifier: &str) -> PreEscaped { html! { span class="material-symbols-outlined select-none" { (identifier) }; } } + +#[allow(non_snake_case)] +pub fn ColoredMaterialIcon(identifier: &str, color: C) -> PreEscaped { + html! { + span class=(format!("material-symbols-outlined select-none text-{}", color.color_class())) { (identifier) }; + } +} diff --git a/src/ui/primitives/input/form.rs b/src/ui/primitives/input/form.rs index f4258f0..51d6ffb 100644 --- a/src/ui/primitives/input/form.rs +++ b/src/ui/primitives/input/form.rs @@ -16,6 +16,7 @@ pub struct Form { action: String, method: Option, multipart: bool, + id: String, items: Vec>, } @@ -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) };