Remove load button

main
Elnu 1 year ago
parent e58fca9fa6
commit 127639355f

@ -104,8 +104,7 @@ fn KeyboardFromFile(
let file_input = create_node_ref::<Input>(cx);
let (file, set_file) = create_signal(cx, Option::<File>::None);
let (result_message, set_result_message) = create_signal(cx, Option::<ResultMessageData>::None);
let on_submit = move |e: SubmitEvent| {
e.prevent_default();
let on_submit = move || {
spawn_local(async move {
match read_kle_from_file(&file).await {
Ok(keyboard) => {
@ -119,7 +118,8 @@ fn KeyboardFromFile(
}));
set_keyboard(Some(keyboard));
}
Err(err) => set_result_message(Some(ResultMessageData {
Err(err) => {
set_result_message(Some(ResultMessageData {
message: view! { cx,
{
err.to_string()
@ -128,25 +128,25 @@ fn KeyboardFromFile(
.into_view(cx),
title: <ReadKleError as Into<&str>>::into(err).to_string(),
colorway: Colorway::Bad,
})),
}));
file_input().unwrap().set_value("");
},
}
});
};
view! { cx,
<h3>"Load KLE JSON from file"</h3>
<ResultMessage message=result_message />
<form class="f-row align-items:center" on:submit=on_submit>
<form class="f-row align-items:center">
<input
type="file"
accept="application/json"
node_ref=file_input
on:change=move |_| {
set_file(file_input().unwrap().files().map(|files| files.get(0)).flatten());
on_submit();
}
/>
<Show when=move || file().is_some() fallback=move |_| {}>
<input type="submit" value="Load" />
</Show>
</form>
}
}

Loading…
Cancel
Save