Skip to content

Commit

Permalink
stable todomvc example (#2489)
Browse files Browse the repository at this point in the history
  • Loading branch information
mahmoud-eltahawy authored Apr 2, 2024
1 parent c750f57 commit 8686d5a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/todomvc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ codegen-units = 1
lto = true

[dependencies]
leptos = { path = "../../leptos", features = ["nightly", "serde"] }
leptos = { path = "../../leptos", features = ["serde"] }
log = "0.4"
console_log = "1"
console_error_panic_hook = "0.1.7"
Expand Down
2 changes: 1 addition & 1 deletion examples/todomvc/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"
20 changes: 10 additions & 10 deletions examples/todomvc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ pub fn TodoMVC() -> impl IntoView {
window_event_listener(ev::hashchange, move |_| {
let new_mode =
location_hash().map(|hash| route(&hash)).unwrap_or_default();
set_mode(new_mode);
set_mode.set(new_mode);
});

// Callback to add a todo on pressing the `Enter` key, if the field isn't empty
Expand Down Expand Up @@ -256,9 +256,9 @@ pub fn TodoMVC() -> impl IntoView {
" left"
</span>
<ul class="filters">
<li><a href="#/" class="selected" class:selected={move || mode() == Mode::All}>"All"</a></li>
<li><a href="#/active" class:selected={move || mode() == Mode::Active}>"Active"</a></li>
<li><a href="#/completed" class:selected={move || mode() == Mode::Completed}>"Completed"</a></li>
<li><a href="#/" class="selected" class:selected={move || mode.get() == Mode::All}>"All"</a></li>
<li><a href="#/active" class:selected={move || mode.get() == Mode::Active}>"Active"</a></li>
<li><a href="#/completed" class:selected={move || mode.get() == Mode::Completed}>"Completed"</a></li>
</ul>
<button
class="clear-completed hidden"
Expand Down Expand Up @@ -293,7 +293,7 @@ pub fn Todo(todo: Todo) -> impl IntoView {
} else {
todo.title.set(value.to_string());
}
set_editing(false);
set_editing.set(false);
};

view! {
Expand All @@ -307,14 +307,14 @@ pub fn Todo(todo: Todo) -> impl IntoView {
node_ref=todo_input
class="toggle"
type="checkbox"
prop:checked={move || (todo.completed)()}
prop:checked={move || todo.completed.get()}
on:input={move |ev| {
let checked = event_target_checked(&ev);
todo.completed.set(checked);
}}
/>
<label on:dblclick=move |_| {
set_editing(true);
set_editing.set(true);

if let Some(input) = todo_input.get() {
_ = input.focus();
Expand All @@ -324,18 +324,18 @@ pub fn Todo(todo: Todo) -> impl IntoView {
</label>
<button class="destroy" on:click=move |_| set_todos.update(|t| t.remove(todo.id))/>
</div>
{move || editing().then(|| view! {
{move || editing.get().then(|| view! {
<input
class="edit"
class:hidden={move || !(editing)()}
class:hidden={move || !editing.get()}
prop:value={move || todo.title.get()}
on:focusout=move |ev: web_sys::FocusEvent| save(&event_target_value(&ev))
on:keyup={move |ev: web_sys::KeyboardEvent| {
let key_code = ev.key_code();
if key_code == ENTER_KEY {
save(&event_target_value(&ev));
} else if key_code == ESCAPE_KEY {
set_editing(false);
set_editing.set(false);
}
}}
/>
Expand Down

0 comments on commit 8686d5a

Please sign in to comment.