From 448231739bac0c689523d52b0c704681a21e8202 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Wed, 25 Oct 2023 23:08:02 -0400 Subject: [PATCH 1/4] Remove my custom Unordered List --- file-service/src/html.rs | 51 --------------------------------------- file-service/src/pages.rs | 2 +- 2 files changed, 1 insertion(+), 52 deletions(-) diff --git a/file-service/src/html.rs b/file-service/src/html.rs index 1ad0760..d38fb21 100644 --- a/file-service/src/html.rs +++ b/file-service/src/html.rs @@ -274,54 +274,3 @@ impl Html for Image { ) } } - -#[derive(Debug)] -pub struct UnorderedList { - children: Vec, - attributes: Attributes, -} - -impl UnorderedList { - pub fn new() -> Self { - Self { - children: vec![], - 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 UnorderedList { - fn to_html_string(&self) -> String { - let children = self - .children - .iter() - .map(|item| format!("
  • {}
  • ", item.to_html_string())) - .collect::>(); - format!( - "
      - {children} -
    ", - attrs = self.attributes.to_string(), - children = children.join("\n") - ) - } -} - -impl HtmlContainer for UnorderedList { - fn add_html(&mut self, html: H) { - self.children.push(html.to_html_string()) - } -} diff --git a/file-service/src/pages.rs b/file-service/src/pages.rs index 977f54f..55ce528 100644 --- a/file-service/src/pages.rs +++ b/file-service/src/pages.rs @@ -95,7 +95,7 @@ pub fn thumbnail(info: &FileInfo) -> Container { .with_html( Container::new(ContainerType::Div) .with_html( - UnorderedList::new() + Container::new(ContainerType::UnorderedList) .with_attributes(vec![("class", "thumbnail__metadata")]) .with_html(info.name.clone()) .with_html(format!("{}", info.created.format("%Y-%m-%d"))), -- 2.44.1 From 9a014af75af6c32753a9a3277865c547107cf60a Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Wed, 25 Oct 2023 23:24:41 -0400 Subject: [PATCH 2/4] 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(), ), ) -- 2.44.1 From a403c1b1b3484427e956384ca9b80755323865b8 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Thu, 26 Oct 2023 00:03:39 -0400 Subject: [PATCH 3/4] Hugely refactor the HTML --- file-service/src/pages.rs | 41 +++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/file-service/src/pages.rs b/file-service/src/pages.rs index e12feec..e68aabe 100644 --- a/file-service/src/pages.rs +++ b/file-service/src/pages.rs @@ -4,32 +4,35 @@ use file_service::{FileHandle, FileInfo, ReadFileError}; pub fn auth(_message: Option) -> build_html::HtmlPage { build_html::HtmlPage::new() - .with_title("Authentication") + .with_title("Sign In") .with_stylesheet("/css") .with_container( Container::new(ContainerType::Div) .with_attributes([("class", "authentication-page")]) + .with_container(auth_form()), + ) +} + +fn auth_form() -> Container { + Container::default() + .with_attributes([("class", "card authentication-form")]) + .with_html( + Form::new() + .with_path("/auth") + .with_method("post") .with_container( Container::new(ContainerType::Div) - .with_attributes([("class", "card authentication-form")]) .with_html( - Form::new() - .with_path("/auth") - .with_method("post") - .with_container( - Container::new(ContainerType::Div) - .with_attributes([("class", "authentication-form__label")]) - .with_html(Label::new("for-token-input", "Authentication")), - ) - .with_container( - Container::new(ContainerType::Div) - .with_attributes([("class", "authentication-form__input")]) - .with_html( - Input::new("password", "password") - .with_id("for-token-input") - .with_attributes([("size", "50")]), - ), - ), + Input::new("password", "password") + .with_id("for-token-input") + .with_attributes([ + ("size", "50"), + ("class", "authentication-form__input"), + ]), + ) + .with_html( + Button::new("Sign In") + .with_attributes([("class", "authentication-form__button")]), ), ), ) -- 2.44.1 From 07b8bb7bfef61a69d6acc6b7f1c3bfdd65dd40a9 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Thu, 26 Oct 2023 00:03:49 -0400 Subject: [PATCH 4/4] Style the authentication page for mobile --- file-service/templates/style.css | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/file-service/templates/style.css b/file-service/templates/style.css index a423bbf..d979df9 100644 --- a/file-service/templates/style.css +++ b/file-service/templates/style.css @@ -29,6 +29,7 @@ body { justify-content: center; align-items: center; height: 200px; + margin: 8px; } .authentication-form { @@ -133,6 +134,16 @@ body { .authentication-form { width: 100%; + display: flex; + flex-direction: column; + } + + .authentication-form__input { + font-size: x-large; + } + + .authentication-form__button { + font-size: x-large; } .upload-form__selector { -- 2.44.1