based/examples/ui.rs
2025-01-14 22:56:07 +01:00

42 lines
817 B
Rust

use based::request::{RequestContext, StringResponse};
use based::ui::{Shell, render_page};
use maud::Render;
use maud::html;
use rocket::get;
use rocket::routes;
use based::ui::appbar::AppBar;
#[get("/")]
pub async fn index_page(ctx: RequestContext) -> StringResponse {
let content = AppBar("MyApp", None).render();
let content = html!(
h1 { "Hello World!" };
(content)
);
render_page(
content,
"Hello World",
ctx,
&Shell::new(
html! {
script src="https://cdn.tailwindcss.com" {};
},
html! {},
Some(String::new()),
),
)
.await
}
#[rocket::launch]
async fn launch() -> _ {
// Logging
env_logger::init();
rocket::build().mount("/", routes![index_page])
}