style(html_examples): clean htmx-like shell with no low-level plumbing

- Move CSS out of app_shell.heml into app.css served by the app.
- Remove direct hemx::advanced::Effect import from example code; rely on IntoEffect.
- Update README to not mention raw Effect:: APIs.
- Keep generated resources and tiny runtime behavior only.

req: examples/001
req: htmx_equivalents/001
req: htmx_equivalents/002
This commit is contained in:
slhx agent
2026-06-23 11:25:59 +02:00
parent cd7f64e5a3
commit cfa4502748
4 changed files with 141 additions and 8 deletions
+14 -6
View File
@@ -1,9 +1,9 @@
use axum::body::Body;
use axum::extract::State;
use axum::response::IntoResponse;
use axum::response::{IntoResponse, Response};
use axum::routing::get;
use axum::Router;
use hemplate::Hemplate;
use hemx::advanced::Effect;
use hemx::{Html, IntoEffect};
use hemx_axum::{
interactions, runtime_js, runtime_js_path, EffectResponse, Form, InteractionHandlers,
@@ -227,6 +227,7 @@ async fn main() {
let app = Router::new()
.route("/", get(home).post(interact))
.route(runtime_js_path(), get(runtime))
.route("/app.css", get(css))
.with_state(state);
let addr = SocketAddr::from(([127, 0, 0, 1], 3029));
@@ -288,6 +289,13 @@ async fn runtime() -> impl IntoResponse {
runtime_js()
}
async fn css() -> Response {
Response::builder()
.header("content-type", "text/css; charset=utf-8")
.body(Body::from(include_str!("../templates/app.css")))
.expect("css response")
}
#[hemx::app(gallery_handlers, contact_card_handlers, editable_row_handlers)]
fn handlers(state: Arc<GalleryState>) -> InteractionHandlers {
interactions(ui::BUILD_FINGERPRINT)
@@ -459,7 +467,7 @@ mod gallery_handlers {
value_options_for(&category, &value)
.into_iter()
.map(|option| gallery::value_option.replace(option))
.collect::<Vec<Effect>>()
.collect::<Vec<_>>()
}
#[hemx::handler]
@@ -490,7 +498,7 @@ mod gallery_handlers {
let rows = loaded_rows(*count)
.into_iter()
.map(|row| gallery::infinite_row.replace(row))
.collect::<Vec<Effect>>();
.collect::<Vec<_>>();
let mut effects = rows;
effects.push(gallery::infinite_status.set(format!("Showing {} rows", *count)));
effects
@@ -530,7 +538,7 @@ mod gallery_handlers {
let rows = loaded_rows(*loaded)
.into_iter()
.map(|row| gallery::loaded_row.replace(row))
.collect::<Vec<Effect>>();
.collect::<Vec<_>>();
let mut effects = rows;
effects.push(gallery::load_status.set(format!("Showing {} rows", *loaded)));
effects
@@ -546,7 +554,7 @@ mod gallery_handlers {
let results = search_results_for(&query)
.into_iter()
.map(|result| gallery::search_result.replace(result))
.collect::<Vec<Effect>>();
.collect::<Vec<_>>();
let mut effects = results;
effects.push(gallery::search_status.set(if query.is_empty() {
"Showing all results".into()