This commit is contained in:
JMARyA 2025-01-14 22:56:07 +01:00
parent 4a537cd933
commit 8208fa8899
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
20 changed files with 944 additions and 15 deletions

View file

@ -1,7 +1,7 @@
use based::request::{RequestContext, StringResponse};
use based::{
get_pg,
page::{Shell, render_page},
ui::{Shell, render_page},
};
use maud::html;
use rocket::get;

42
examples/ui.rs Normal file
View file

@ -0,0 +1,42 @@
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])
}