Merge branch 'master' into jk/coroutine-coroutineoverhaul

This commit is contained in:
Jonathan Kelley committed 2022-02-26 17:32:11 -05:00
commit 2b17717323
32 files changed
+860 -80

No files matched your search

+7 -5
View File
@@ -12,7 +12,7 @@ fn app(cx: Scope) -> Element {
let onsubmit = move |evt: FormEvent| {
cx.spawn(async move {
let resp = reqwest::Client::new()
.post("http://localhost/login")
.post("http://localhost:8080/login")
.form(&[
("username", &evt.values["username"]),
("password", &evt.values["password"]),
@@ -22,10 +22,12 @@ fn app(cx: Scope) -> Element {
match resp {
// Parse data from here, such as storing a response token
Ok(_data) => println!("Login successful"),
Ok(_data) => println!("Login successful!"),
//Handle any errors from the fetch here
Err(_err) => println!("Login failed"),
Err(_err) => {
println!("Login failed - you need a login server running on localhost:8080.")
}
}
});
};
@@ -36,10 +38,10 @@ fn app(cx: Scope) -> Element {
onsubmit: onsubmit,
prevent_default: "onsubmit", // Prevent the default behavior of <form> to post
input { "type": "text" }
input { "type": "text", id: "username", name: "username" }
label { "Username" }
br {}
input { "type": "password" }
input { "type": "password", id: "password", name: "password" }
label { "Password" }
br {}
button { "Login" }
+23
View File
@@ -0,0 +1,23 @@
// How to use textareas
use dioxus::prelude::*;
fn main() {
dioxus::desktop::launch(app);
}
fn app(cx: Scope) -> Element {
let (model, set_model) = use_state(&cx, || String::from("asd"));
println!("{}", model);
cx.render(rsx! {
textarea {
class: "border",
rows: "10",
cols: "80",
value: "{model}",
oninput: move |e| set_model(e.value.clone()),
}
})
}
+1 -1
View File
@@ -129,7 +129,6 @@ pub fn todo_entry<'a>(cx: Scope<'a, TodoEntryProps<'a>>) -> Element {
label {
r#for: "cbg-{todo.id}",
onclick: move |_| set_is_editing(true),
onfocusout: move |_| set_is_editing(false),
"{todo.contents}"
}
}
@@ -139,6 +138,7 @@ pub fn todo_entry<'a>(cx: Scope<'a, TodoEntryProps<'a>>) -> Element {
value: "{todo.contents}",
oninput: move |evt| cx.props.set_todos.make_mut()[&cx.props.id].contents = evt.value.clone(),
autofocus: "true",
onfocusout: move |_| set_is_editing(false),
onkeydown: move |evt| {
match evt.key.as_str() {
"Enter" | "Escape" | "Tab" => set_is_editing(false),