fix formatted strings in components

This commit is contained in:
Evan Almloff committed 2024-01-16 12:47:23 -06:00
1 parent 407a82588a
commit 90d0164b9e
8 files changed
+41 -59

No files matched your search

+12 -44
View File
@@ -44,38 +44,22 @@ fn app() -> Element {
style { {STYLE} }
div { id: "wrapper",
div { class: "app",
div { class: "calculator", onkeypress: move |evt| state.write().handle_keydown(evt),
div {
class: "calculator",
onkeypress: move |evt| state.write().handle_keydown(evt),
div { class: "calculator-display", {state.read().formatted_display()} }
div { class: "calculator-keypad",
div { class: "input-keys",
div { class: "function-keys",
CalculatorKey {
name: "key-clear",
onclick: move |_| state.write().clear_display(),
CalculatorKey { name: "key-clear", onclick: move |_| state.write().clear_display(),
if state.read().display_value == "0" { "C" } else { "AC" }
}
CalculatorKey {
name: "key-sign",
onclick: move |_| state.write().toggle_sign(),
"±"
}
CalculatorKey {
name: "key-percent",
onclick: move |_| state.write().toggle_percent(),
"%"
}
CalculatorKey { name: "key-sign", onclick: move |_| state.write().toggle_sign(), "±" }
CalculatorKey { name: "key-percent", onclick: move |_| state.write().toggle_percent(), "%" }
}
div { class: "digit-keys",
CalculatorKey {
name: "key-0",
onclick: move |_| state.write().input_digit(0),
"0"
}
CalculatorKey {
name: "key-dot",
onclick: move |_| state.write().input_dot(),
"●"
}
CalculatorKey { name: "key-0", onclick: move |_| state.write().input_digit(0), "0" }
CalculatorKey { name: "key-dot", onclick: move |_| state.write().input_dot(), "●" }
for k in 1..10 {
CalculatorKey {
key: "{k}",
@@ -102,16 +86,8 @@ fn app() -> Element {
onclick: move |_| state.write().set_operator(Operator::Sub),
"−"
}
CalculatorKey {
name: "key-add",
onclick: move |_| state.write().set_operator(Operator::Add),
"+"
}
CalculatorKey {
name: "key-equals",
onclick: move |_| state.write().perform_operation(),
"="
}
CalculatorKey { name: "key-add", onclick: move |_| state.write().set_operator(Operator::Add), "+" }
CalculatorKey { name: "key-equals", onclick: move |_| state.write().perform_operation(), "=" }
}
}
}
@@ -121,17 +97,9 @@ fn app() -> Element {
}
#[component]
fn CalculatorKey(
#[props(into)] name: String,
onclick: EventHandler<MouseEvent>,
children: Element,
) -> Element {
fn CalculatorKey(name: String, onclick: EventHandler<MouseEvent>, children: Element) -> Element {
render! {
button {
class: "calculator-key {name}",
onclick: move |e| onclick.call(e),
{&children}
}
button { class: "calculator-key {name}", onclick: move |e| onclick.call(e), {&children} }
}
}
+1 -4
View File
@@ -22,10 +22,7 @@ fn app() -> Element {
render! {
div {
h1 { "Current count: {count}" }
button {
onclick: move |_| count.set(0),
"Reset the count"
}
button { onclick: move |_| count.set(0), "Reset the count" }
}
}
}
+1 -1
View File
@@ -120,7 +120,7 @@ pub fn TodoEntry(mut todos: Signal<HashMap<u32, TodoItem>>, id: u32) -> Element
let contents = use_selector(move || todos.read().get(&id).unwrap().contents.clone());
render! {
li { class: if checked() { "completed" }, class: if is_editing() { "editing"},
li { class: if checked() { "completed" }, class: if is_editing() { "editing" },
div { class: "view",
input {
class: "toggle",