examples: fix hackernews examples oops

This commit is contained in:
Greg Johnston 2023-09-29 13:36:13 -04:00
parent fb914e1a50
commit f7adf6f73d
3 changed files with 7 additions and 13 deletions

View file

@ -16,10 +16,7 @@ actix-web = { version = "4", optional = true, features = ["macros"] }
console_log = "1" console_log = "1"
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
cfg-if = "1" cfg-if = "1"
leptos = { path = "../../leptos", features = [ leptos = { path = "../../leptos", features = ["nightly"] }
"nightly",
"experimental-islands",
] }
leptos_meta = { path = "../../meta", features = ["nightly"] } leptos_meta = { path = "../../meta", features = ["nightly"] }
leptos_actix = { path = "../../integrations/actix", optional = true } leptos_actix = { path = "../../integrations/actix", optional = true }
leptos_router = { path = "../../router", features = ["nightly"] } leptos_router = { path = "../../router", features = ["nightly"] }

View file

@ -41,13 +41,11 @@ pub fn Stories() -> impl IntoView {
}; };
view! { view! {
<div class="news-view"> <div class="news-view">
<div class="news-list-nav"> <div class="news-list-nav">
<span> <span>
{move || if page() > 1 { {move || if page() > 1 {
view! { view! {
<a class="page-link" <a class="page-link"
href=move || format!("/{}?page={}", story_type(), page() - 1) href=move || format!("/{}?page={}", story_type(), page() - 1)
attr:aria_label="Previous Page" attr:aria_label="Previous Page"
@ -57,7 +55,6 @@ pub fn Stories() -> impl IntoView {
}.into_any() }.into_any()
} else { } else {
view! { view! {
<span class="page-link disabled" aria-hidden="true"> <span class="page-link disabled" aria-hidden="true">
"< prev" "< prev"
</span> </span>
@ -79,12 +76,12 @@ pub fn Stories() -> impl IntoView {
<main class="news-list"> <main class="news-list">
<div> <div>
<Transition <Transition
fallback=move || view! { <p>"Loading..."</p> } fallback=move || view! { <p>"Loading..."</p> }
set_pending set_pending
> >
{move || match stories.get() { {move || match stories.get() {
None => None, None => None,
Some(None) => Some(view! { <p>"Error loading stories."</p> }.into_any()), Some(None) => Some(view! { <p>"Error loading stories."</p> }.into_any()),
Some(Some(stories)) => { Some(Some(stories)) => {
Some(view! { Some(view! {
<ul> <ul>
@ -123,7 +120,7 @@ fn Story(story: api::Story) -> impl IntoView {
}.into_view() }.into_view()
} else { } else {
let title = story.title.clone(); let title = story.title.clone();
view! { <A href=format!("/stories/{}", story.id)>{title.clone()}</A> }.into_view() view! { <A href=format!("/stories/{}", story.id)>{title.clone()}</A> }.into_view()
}} }}
</span> </span>
<br /> <br />
@ -132,7 +129,7 @@ fn Story(story: api::Story) -> impl IntoView {
view! { view! {
<span> <span>
{"by "} {"by "}
{story.user.map(|user| view ! { <A href=format!("/users/{user}")>{user.clone()}</A>})} {story.user.map(|user| view ! { <A href=format!("/users/{user}")>{user.clone()}</A>})}
{format!(" {} | ", story.time_ago)} {format!(" {} | ", story.time_ago)}
<A href=format!("/stories/{}", story.id)> <A href=format!("/stories/{}", story.id)>
{if story.comments_count.unwrap_or_default() > 0 { {if story.comments_count.unwrap_or_default() > 0 {
@ -145,7 +142,7 @@ fn Story(story: api::Story) -> impl IntoView {
}.into_view() }.into_view()
} else { } else {
let title = story.title.clone(); let title = story.title.clone();
view! { <A href=format!("/item/{}", story.id)>{title.clone()}</A> }.into_view() view! { <A href=format!("/item/{}", story.id)>{title.clone()}</A> }.into_view()
}} }}
</span> </span>
{(story.story_type != "link").then(|| view! { {(story.story_type != "link").then(|| view! {

View file

@ -70,7 +70,7 @@ pub fn Stories() -> impl IntoView {
> >
<a href=move || format!("/{}?page={}", story_type(), page() + 1) <a href=move || format!("/{}?page={}", story_type(), page() + 1)
aria-label="Next Page" aria-label="Next Page"
>= >
"more >" "more >"
</a> </a>
</span> </span>