//! UI binary entrypoint for quotesdb.
//!
//! Compiled to WebAssembly via Trunk targeting `wasm32-unknown-unknown`.
//! Runs the Yew single-page application with client-side routing.
//!
//! All functional code is gated on `wasm32` — yew, web-sys, and wasm-bindgen
//! are wasm32-only crates unavailable on native targets.
#[cfg(target_arch = "wasm32")]
mod api;
#[cfg(target_arch = "wasm32")]
mod components;
#[cfg(target_arch = "wasm32")]
mod pages;
#[cfg(target_arch = "wasm32")]
mod storage;
#[cfg(target_arch = "wasm32")]
use yew::prelude::*;
#[cfg(target_arch = "wasm32")]
use yew_router::prelude::*;
/// Application routes matching the frontend route definitions in the design spec.
///
/// Routes map to page components. The `NotFound` variant catches all unmatched paths.
#[cfg(target_arch = "wasm32")]
#[derive(Clone, Routable, PartialEq)]
pub enum Route {
/// Home page — displays a random quote.
#[at("/")]
Home,
/// Browse page — paginated list of quotes with filters.
#[at("/browse")]
Browse,
/// Single quote view/edit/delete page.
#[at("/quotes/:id")]
QuoteDetail { id: String },
/// All quotes by a specific author.
#[at("/author/:name")]
Author { name: String },
/// New quote submission form.
#[at("/submit")]
Submit,
/// Admin panel for managing submissions lock and auth codes.
#[at("/admin")]
Admin,
/// Catch-all 404 page.
#[not_found]
#[at("/404")]
NotFound,
}
/// Route switch function — maps each `Route` variant to its page component.
#[cfg(target_arch = "wasm32")]
fn switch(routes: Route) -> Html {
match routes {
Route::Home => html! {