From 9ab63b13d74b272d5a557e61f486ff980917d41d Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 4 Sep 2021 17:04:36 +0200 Subject: Add some style elements Signed-off-by: Matthias Beyer --- src/frontend.rs | 33 ++++++++++++++++++++++++++++----- src/main.rs | 1 + 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/frontend.rs b/src/frontend.rs index 964367e..e5a9285 100644 --- a/src/frontend.rs +++ b/src/frontend.rs @@ -6,9 +6,16 @@ use actix_web::HttpRequest; use actix_web::HttpResponse; use actix_web::Error; +// TODO: This is not how you do it +#[get("/style.css")] +pub async fn css() -> &'static str { + std::include_str!("../static/bulma.css") +} + #[get("/")] pub async fn index() -> Result { Ok(maud::html! { + link rel="stylesheet" href="style.css"; html { body { h1 { "Waterlevels" } @@ -37,6 +44,7 @@ pub struct LandscapeSize { pub async fn make_landscape(form: web::Form) -> Result { if form.elements > 100 { return Ok(maud::html! { + link rel="stylesheet" href="style.css"; html { body { p { "For runtime reasons, this application only supports landscapes up to 100 elements" } @@ -46,6 +54,7 @@ pub async fn make_landscape(form: web::Form) -> Result Result { // This is just "good enough" for now. if ls.hours > 1000 { return Ok(maud::html! { + link rel="stylesheet" href="style.css"; html { body { h1 { "Landscape error" } @@ -107,20 +117,33 @@ pub async fn calculate(req: HttpRequest) -> Result { let calculated_landscape = crate::backend::landscape::Landscape::new(ls.levels.clone()).rain(ls.hours); Ok(maud::html! { + link rel="stylesheet" href="style.css"; html { body { - h1 { "Landscape!" } + h1 { "Landscape" } p { "Filling in " (ls.hours) " hours" } - @for value in &ls.levels { - p { (value) } + table class="table" { + tbody { + tr { + @for value in &ls.levels { + td { (value) } + } + } + } } h2 { "Filled" } - @for val in calculated_landscape.into_inner() { - p { (val.0) " + " (val.1) } + table class="table" { + tbody { + tr { + @for val in calculated_landscape.into_inner() { + td { (val.0) " + " (val.1) } + } + } + } } } } diff --git a/src/main.rs b/src/main.rs index cf87858..8a99b08 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,6 +29,7 @@ async fn main() -> anyhow::Result<()> { App::new() .wrap(Logger::default()) .wrap(Logger::new("%a %{User-Agent}i")) + .service(crate::frontend::css) .service(crate::frontend::index) .service(crate::frontend::make_landscape) .service(crate::frontend::calculate) -- cgit v1.2.3