feedsignal/crates/web/src/app/mod.rs

33 lines
1 KiB
Rust
Raw Normal View History

mod article_row;
mod subscribe_form;
use crate::api;
use article_row::ArticleRow;
use dioxus::prelude::*;
use subscribe_form::SubscribeForm;
#[component]
pub fn App() -> Element {
let mut articles = use_server_future(api::articles::list_ranked_articles)?;
rsx! {
Stylesheet { href: asset!("/assets/app.css") }
Stylesheet { href: asset!("/assets/dx-components-theme.css") }
main {
h1 { "feedsignal" }
SubscribeForm { on_subscribed: move |_| { articles.restart(); } }
match articles.read().as_ref() {
Some(Ok(articles)) => rsx! {
ul { class: "article-list",
for article in articles.iter() {
ArticleRow { article: article.clone() }
}
}
},
Some(Err(err)) => rsx! { p { class: "error", "Failed to load articles: {err}" } },
None => rsx! { p { "Loading..." } },
}
}
}
}