This commit is contained in:
2024-04-29 20:38:17 +02:00
parent 84fdf64793
commit 0949b1452c
5 changed files with 430 additions and 92 deletions

61
src/elements/mod.rs Normal file
View File

@@ -0,0 +1,61 @@
use std::fmt::Display;
pub mod list;
pub enum HxSwap {
OuterHtml,
}
pub enum Icon {
Edit,
Delete,
Save,
Cancel,
}
impl Icon {
pub fn mdi_class(&self) -> &'static str {
match self {
Icon::Edit => "mdi-pencil",
Icon::Delete => "mdi-delete",
Icon::Save => "mdi-content-save",
Icon::Cancel => "mdi-cancel",
}
}
pub fn background(&self) -> &'static str {
match self {
Icon::Edit => "bg-blue-200",
Icon::Delete => "bg-red-200",
Icon::Save => "bg-green-100",
Icon::Cancel => "bg-red-100",
}
}
pub fn background_hover(&self) -> &'static str {
match self {
Icon::Edit => "hover:bg-blue-400",
Icon::Delete => "hover:bg-red-400",
Icon::Save => "hover:bg-green-200",
Icon::Cancel => "hover:bg-red-200",
}
}
}
impl Display for HxSwap {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
match self {
HxSwap::OuterHtml => "outerHtml",
}
)
}
}
pub struct HxConfig {
pub hx_post: String,
pub hx_swap: HxSwap,
pub hx_target: &'static str,
}