From f32a221022c475dd1a6757de56c91fba18f8e079 Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Tue, 20 Feb 2024 20:49:14 -0500 Subject: [PATCH] ui: start out with flex column arrangments --- src/main.rs | 1 + src/routes.rs | 23 ++++++++++++++++------- static/site.css | 18 ++++++++++++++++++ 3 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 static/site.css diff --git a/src/main.rs b/src/main.rs index eab586b..cdb66b6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -64,6 +64,7 @@ async fn main() -> anyhow::Result<()> { let router = Router::new() // JSON api endpoints .nest("/js", routes::mk_js_routes(config.clone())) + .nest("/static", routes::mk_static_routes(config.clone())) .nest("/api", routes::mk_api_routes(config.clone())) // HTMX ui component endpoints .nest("/ui", routes::mk_ui_routes(config.clone())) diff --git a/src/routes.rs b/src/routes.rs index ae052bc..47dbb22 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -144,6 +144,7 @@ pub async fn index(State(config): State) -> Markup { script src="/js/plotly.js" { } script src="/js/htmx.js" { } script src="/js/lib.js" { } + link rel="stylesheet" href="/static/site.css" { } (app(State(config.clone())).await) } } @@ -157,15 +158,16 @@ pub async fn app(State(config): State) -> Markup { .enumerate() .collect::>(); html! { - div { - // Header menu - ul { - @for title in &titles { - li hx-get=(format!("/ui/dash/{}", title.0)) hx-target="#dashboard" { (title.1) } + div class="row-flex" { + div class="flex-item-shrink" { + // Header menu + ul { + @for title in &titles { + li hx-get=(format!("/ui/dash/{}", title.0)) hx-target="#dashboard" { (title.1) } + } } } - // dashboard display - div id="dashboard" { } + div class="flex-item-grow" id="dashboard" { } } } } @@ -197,3 +199,10 @@ pub fn mk_js_routes(config: Arc>) -> Router { .route("/htmx.js", get(htmx)) .with_state(State(config)) } + +pub fn mk_static_routes(config: Arc>) -> Router { + Router::new() + .route("/site.css", get(|| async { return include_str!("../static/site.css"); })) + .with_state(State(config)) +} + diff --git a/static/site.css b/static/site.css new file mode 100644 index 0000000..d8de113 --- /dev/null +++ b/static/site.css @@ -0,0 +1,18 @@ +.column-flex { + display: flex; + flex-direction: column; +} + +.row-flex { + display: flex; + flex-direction: row; +} + +.flex-item-grow { + flex: 1 0 auto; +} + +.flex-item-shrink { + flex: 0 1 auto; +} +