Skip to content

Commit

Permalink
hackernews island example migrated
Browse files Browse the repository at this point in the history
  • Loading branch information
Alt-iOS committed Apr 2, 2024
1 parent f11e21f commit fe5036e
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 23 deletions.
9 changes: 3 additions & 6 deletions examples/hackernews_islands_axum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@ codegen-units = 1
lto = true

[dependencies]
leptos_meta = { path = "../../meta" }
console_log = "1.0"
console_error_panic_hook = "0.1"
leptos = { path = "../../leptos", features = [
"nightly",
"experimental-islands",
] }
leptos = { path = "../../leptos", features = ["experimental-islands"] }
leptos_axum = { path = "../../integrations/axum", optional = true, features = [
"experimental-islands",
] }
leptos_meta = { path = "../../meta", features = ["nightly"] }
leptos_router = { path = "../../router", features = ["nightly"] }
leptos_router = { path = "../../router" }
log = "0.4"
simple_logger = "4.0"
serde = { version = "1.0", features = ["derive"] }
Expand Down
14 changes: 7 additions & 7 deletions examples/hackernews_islands_axum/index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<link data-trunk rel="rust" data-wasm-opt="z"/>
<link data-trunk rel="css" href="/style.css"/>
</head>
<body></body>
</html>
<head>
<link data-trunk rel="rust" data-wasm-opt="z" />
<link data-trunk rel="css" href="./style.css" />
</head>
<body></body>
</html>
2 changes: 1 addition & 1 deletion examples/hackernews_islands_axum/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "nightly-2024-03-31"
channel = "stable"
6 changes: 3 additions & 3 deletions examples/hackernews_islands_axum/src/error_template.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use leptos::{view, Errors, For, IntoView, RwSignal, View};
use leptos::{view, Errors, For, IntoView, RwSignal, SignalGet, View};

// A basic function to display errors served by the error boundaries. Feel free to do more complicated things
// here than just displaying them
Expand All @@ -11,11 +11,11 @@ pub fn error_template(errors: Option<RwSignal<Errors>>) -> View {
<h1>"Errors"</h1>
<For
// a function that returns the items we're iterating over; a signal is fine
each=errors
each={move || errors.get()}
// a unique key for each item as a reference
key=|(key, _)| key.clone()
// renders each item to a view
children= move | (_, error)| {
children=move | (_, error)| {
let error_string = error.to_string();
view! {

Expand Down
2 changes: 1 addition & 1 deletion examples/hackernews_islands_axum/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(lazy_cell)]
#![cfg_attr(feature = "nightly", feature(Lazy_cell))]

use leptos::*;
use leptos_meta::*;
Expand Down
2 changes: 1 addition & 1 deletion examples/hackernews_islands_axum/src/routes/stories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn Stories() -> impl IntoView {
let (pending, set_pending) = create_signal(false);

let hide_more_link = move || {
pending()
pending.get()
|| stories
.map(|stories| {
stories.as_ref().map(|s| s.len() < 28).unwrap_or_default()
Expand Down
6 changes: 3 additions & 3 deletions examples/hackernews_islands_axum/src/routes/story.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub async fn fetch_story(
pub fn Story() -> impl IntoView {
let params = use_params_map();
let story = create_resource(
move || params().get("id").cloned().unwrap_or_default(),
move || params.get().get("id").cloned().unwrap_or_default(),
move |id| async move {
if id.is_empty() {
Ok(RefCell::new(None))
Expand Down Expand Up @@ -94,7 +94,7 @@ pub fn Toggle(children: Children) -> impl IntoView {
view! {
<div class="toggle" class:open=open>
<a on:click=move |_| set_open.update(|n| *n = !*n)>
{move || if open() {
{move || if open.get() {
"[-]"
} else {
"[+] comments collapsed"
Expand All @@ -103,7 +103,7 @@ pub fn Toggle(children: Children) -> impl IntoView {
</div>
<ul
class="comment-children"
style:display=move || if open() {
style:display=move || if open.get() {
"block"
} else {
"none"
Expand Down
2 changes: 1 addition & 1 deletion examples/hackernews_islands_axum/src/routes/users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub async fn fetch_user(
pub fn User() -> impl IntoView {
let params = use_params_map();
let user = create_resource(
move || params().get("id").cloned().unwrap_or_default(),
move || params.get().get("id").cloned().unwrap_or_default(),
move |id| async move {
if id.is_empty() {
Ok(None)
Expand Down

0 comments on commit fe5036e

Please sign in to comment.