Files
packager/rust/src/components/mod.rs

104 lines
3.3 KiB
Rust
Raw Normal View History

2023-05-08 22:31:01 +02:00
use maud::{html, Markup, DOCTYPE};
2023-05-08 00:05:45 +02:00
pub mod home;
pub mod inventory;
2023-05-18 00:11:52 +02:00
pub mod trip;
2023-05-17 17:47:26 +02:00
2023-05-08 00:05:45 +02:00
pub use home::*;
pub use inventory::*;
2023-05-18 00:11:52 +02:00
pub use trip::*;
2023-05-08 00:05:45 +02:00
2023-08-29 21:33:59 +02:00
pub struct Root;
2023-05-08 00:05:45 +02:00
pub enum TopLevelPage {
Inventory,
Trips,
None,
}
impl Root {
2023-08-29 21:33:59 +02:00
pub fn build(body: Markup, active_page: &TopLevelPage) -> Markup {
html!(
2023-05-08 22:31:01 +02:00
(DOCTYPE)
html {
head {
title { "Packager" }
2023-08-29 21:33:59 +02:00
script src="https://unpkg.com/htmx.org@1.9.2" {}
2023-05-08 22:31:01 +02:00
script src="https://cdn.tailwindcss.com" {}
script src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.js" defer {}
link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@mdi/font@6.9.96/css/materialdesignicons.min.css";
2023-08-29 21:33:59 +02:00
link rel="shortcut icon" type="image/svg+xml" href="/favicon.svg";
2023-05-08 22:31:01 +02:00
script { (include_str!(concat!(env!("CARGO_MANIFEST_DIR"),"/js/app.js"))) }
}
2023-08-29 21:33:59 +02:00
body
hx-boost="true"
{
2023-05-08 22:31:01 +02:00
header
2023-08-29 21:33:59 +02:00
."h-full"
2023-05-08 22:31:01 +02:00
."bg-gray-200"
."p-5"
."flex"
."flex-row"
."flex-nowrap"
."justify-between"
."items-center"
{
2023-08-29 21:33:59 +02:00
span
."text-xl"
."font-semibold"
."flex"
."flex-row"
."items-center"
."gap-3"
{
img ."h-12" src="/assets/luggage.svg";
2023-05-08 22:31:01 +02:00
a href="/" { "Packager" }
}
2023-08-29 21:33:59 +02:00
nav
."grow"
."flex"
."flex-row"
."justify-center"
."gap-x-10"
."content-stretch"
{
a href="/inventory/"
."h-full"
."text-lg"
."font-bold"[matches!(active_page, TopLevelPage::Inventory)]
."underline"[matches!(active_page, TopLevelPage::Inventory)]
{ "Inventory" }
a href="/trips/"
."h-full"
."text-lg"
."font-bold"[matches!(active_page, TopLevelPage::Trips)]
."underline"[matches!(active_page, TopLevelPage::Trips)]
{ "Trips" }
2023-05-08 22:31:01 +02:00
}
}
2023-08-29 21:33:59 +02:00
(body)
2023-05-08 22:31:01 +02:00
}
}
2023-08-29 21:33:59 +02:00
)
2023-05-08 00:05:45 +02:00
}
2023-08-29 21:33:59 +02:00
}
pub struct ErrorPage;
2023-05-08 00:05:45 +02:00
2023-08-29 21:33:59 +02:00
impl ErrorPage {
pub fn build(message: &str) -> Markup {
2023-08-29 21:33:59 +02:00
html!(
(DOCTYPE)
html {
head {
title { "Packager" }
}
body {
2023-08-29 21:33:59 +02:00
h1 { "Error" }
p { (message) }
2023-08-29 21:33:59 +02:00
}
}
2023-08-29 21:33:59 +02:00
)
2023-05-08 00:05:45 +02:00
}
}