diff --git a/src/asset.rs b/src/asset.rs
index 0c878d7..3eefe2f 100644
--- a/src/asset.rs
+++ b/src/asset.rs
@@ -19,7 +19,7 @@ pub fn flowbite_css() -> DataResponse {
)
}
-#[get("/assets/flowbite.min.s")]
+#[get("/assets/flowbite.min.js")]
pub fn flowbite_js() -> DataResponse {
DataResponse::new(
include_str!("flowbite.min.js").as_bytes().to_vec(),
diff --git a/src/ui/primitives/div.rs b/src/ui/primitives/div.rs
index 0d1c8d6..224e32b 100644
--- a/src/ui/primitives/div.rs
+++ b/src/ui/primitives/div.rs
@@ -136,8 +136,7 @@ impl UIWidget for DivWidget {
.join(" ");
PreEscaped(format!(
- "
{}
",
- self.extended_class_().join(" "),
+ " {}
",
inner.0
))
}
diff --git a/src/ui/primitives/image.rs b/src/ui/primitives/image.rs
index 7070a16..713fb35 100644
--- a/src/ui/primitives/image.rs
+++ b/src/ui/primitives/image.rs
@@ -7,12 +7,18 @@ pub fn Image(src: &str) -> ImageWidget {
ImageWidget {
src: src.to_owned(),
alt: String::new(),
+ width: None,
+ height: None,
+ caption: None,
}
}
pub struct ImageWidget {
src: String,
alt: String,
+ width: Option,
+ height: Option,
+ caption: Option,
}
impl Render for ImageWidget {
@@ -27,6 +33,46 @@ impl ImageWidget {
self.alt = alt.to_string();
self
}
+
+ #[must_use]
+ pub fn width(mut self, width: u32) -> Self {
+ self.width = Some(width);
+ self
+ }
+
+ #[must_use]
+ pub fn height(mut self, height: u32) -> Self {
+ self.height = Some(height);
+ self
+ }
+
+ #[must_use]
+ pub fn caption(mut self, caption: &str) -> Self {
+ self.caption = Some(caption.to_string());
+ self
+ }
+
+ pub fn build_img(&self, class: &str) -> PreEscaped {
+ let mut str = "
"));
+
+ PreEscaped(str)
+ }
}
impl UIWidget for ImageWidget {
@@ -43,9 +89,16 @@ impl UIWidget for ImageWidget {
}
fn render_with_class(&self, class: &str) -> Markup {
- html! {
- img src=(self.src) alt=(self.alt) class=(class) {};
+ if let Some(caption) = &self.caption {
+ return html! {
+ figure class="w-fit" {
+ (self.build_img(class))
+ figcaption class="mt-2 text-sm text-center text-gray-500 dark:text-gray-400" { (caption) };
+ }
+ };
}
+
+ self.build_img(class)
}
}
@@ -218,7 +271,7 @@ impl UIWidget for SourceWidget {
html! {
@if let Some(mime) = &self.mime {
source src=(self.src) type=(mime);
- } else {
+ } @else {
source src=(self.src);
};
}