chore: clean up interpreter and bindings

This commit is contained in:
Jonathan Kelley committed 2022-12-05 16:47:04 -08:00
1 parent 7b1cdb7d85
commit b182a6ee75
17 files changed
+34 -108

No files matched your search

+2
View File
@@ -406,6 +406,8 @@ fn app(cx: Scope) -> Element {
wrap_through: "a",
writing_mode: "a",
z_index: "a",
"This example isn't quite useful yet"
}
})
}
+2 -6
View File
@@ -29,9 +29,7 @@ fn app(cx: Scope) -> Element {
cx.render(rsx! {
div {
Child1 {
text: first
}
Child1 { text: first }
}
})
}
@@ -59,9 +57,7 @@ struct C2Props<'a> {
fn Child2<'a>(cx: Scope<'a, C2Props<'a>>) -> Element {
cx.render(rsx! {
Child3 {
text: cx.props.text
}
Child3 { text: cx.props.text }
})
}
+5 -8
View File
@@ -22,10 +22,10 @@ pub struct TodoItem {
}
pub fn app(cx: Scope<()>) -> Element {
let todos = use_state(&cx, im_rc::HashMap::<u32, TodoItem>::default);
let filter = use_state(&cx, || FilterState::All);
let draft = use_state(&cx, || "".to_string());
let todo_id = use_state(&cx, || 0);
let todos = use_state(cx, im_rc::HashMap::<u32, TodoItem>::default);
let filter = use_state(cx, || FilterState::All);
let draft = use_state(cx, || "".to_string());
let todo_id = use_state(cx, || 0);
// Filter the todos based on the filter state
let mut filtered_todos = todos
@@ -58,7 +58,6 @@ pub fn app(cx: Scope<()>) -> Element {
value: "{draft}",
autofocus: "true",
oninput: move |evt| {
println!("calling oninput");
draft.set(evt.value.clone());
},
onkeydown: move |evt| {
@@ -117,15 +116,13 @@ pub struct TodoEntryProps<'a> {
}
pub fn TodoEntry<'a>(cx: Scope<'a, TodoEntryProps<'a>>) -> Element {
let is_editing = use_state(&cx, || false);
let is_editing = use_state(cx, || false);
let todos = cx.props.todos.get();
let todo = &todos[&cx.props.id];
let completed = if todo.checked { "completed" } else { "" };
let editing = if **is_editing { "editing" } else { "" };
println!("rendering todo entry");
cx.render(rsx!{
li {
class: "{completed} {editing}",