From 9a014af75af6c32753a9a3277865c547107cf60a Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Wed, 25 Oct 2023 23:24:41 -0400 Subject: [PATCH] Remove my custom Image struct --- file-service/src/html.rs | 38 -------------------------------------- file-service/src/pages.rs | 5 +++-- 2 files changed, 3 insertions(+), 40 deletions(-) diff --git a/file-service/src/html.rs b/file-service/src/html.rs index d38fb21..5f5e2cd 100644 --- a/file-service/src/html.rs +++ b/file-service/src/html.rs @@ -236,41 +236,3 @@ impl Html for Button { ) } } - -#[derive(Clone, Debug)] -pub struct Image { - path: String, - attributes: Attributes, -} - -impl Image { - pub fn new(path: &str) -> Self { - Self { - path: path.to_owned(), - attributes: Attributes::default(), - } - } - - pub fn with_attributes<'a>( - mut self, - values: impl IntoIterator, - ) -> Self { - self.attributes = Attributes( - values - .into_iter() - .map(|(a, b)| (a.to_owned(), b.to_owned())) - .collect::>(), - ); - self - } -} - -impl Html for Image { - fn to_html_string(&self) -> String { - format!( - "", - path = self.path, - attrs = self.attributes.to_string() - ) - } -} diff --git a/file-service/src/pages.rs b/file-service/src/pages.rs index 55ce528..e12feec 100644 --- a/file-service/src/pages.rs +++ b/file-service/src/pages.rs @@ -87,8 +87,9 @@ pub fn thumbnail(info: &FileInfo) -> Container { .with_html( Container::new(ContainerType::Div).with_link( format!("/{}", *info.id), - Image::new(&format!("{}/tn", *info.id)) - .with_attributes([("class", "thumbnail__image")]) + Container::default() + .with_attributes([("class", "thumbnail")]) + .with_image(&format!("{}/tn", *info.id), "test data") .to_html_string(), ), )