Skip to content

Commit

Permalink
chore(sycamore-template): update sycamore to v0.9 (#839)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukechu10 authored Nov 4, 2024
1 parent 7576288 commit 7e5013d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
6 changes: 6 additions & 0 deletions .changes/update-sycamore.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"create-tauri-app": patch
"create-tauri-app-js": patch
---

Update `sycamore` template to `v0.9`
5 changes: 2 additions & 3 deletions templates/template-sycamore/Cargo.toml.lte
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
sycamore = { version = "0.8", features = ["suspense"] }
sycamore = { version = "0.9", features = ["suspense"] }
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"
js-sys = "0.3"
serde-wasm-bindgen = "0.4"
serde-wasm-bindgen = "0.6"
serde = { version = "1", features = ["derive"] }
console_error_panic_hook = "0.1.7"

Expand Down
35 changes: 19 additions & 16 deletions templates/template-sycamore/src/app.rs.lte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use serde::{Deserialize, Serialize};
use sycamore::futures::spawn_local_scoped;
use sycamore::prelude::*;
use sycamore::rt::Event;
use sycamore::web::events::SubmitEvent;
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
Expand All @@ -16,46 +16,49 @@ struct GreetArgs<'a> {
}

#[component]
pub fn App<G: Html>(cx: Scope) -> View<G> {
let name = create_signal(cx, String::new());
let greet_msg = create_signal(cx, String::new());
pub fn App() -> View {
let name = create_signal(String::new());
let greet_msg = create_signal(String::new());

let greet = move |e: Event| {
let greet = move |e: SubmitEvent| {
e.prevent_default();
spawn_local_scoped(cx, async move {
spawn_local_scoped(async move {
// Learn more about Tauri commands at {% if v2 %}https://tauri.app/develop/calling-rust/{% else %}https://v1.tauri.app/v1/guides/features/command{% endif %}
let args = serde_wasm_bindgen::to_value(&GreetArgs { name: &name.get() }).unwrap();
let args = serde_wasm_bindgen::to_value(&GreetArgs {
name: &name.get_clone()
})
.unwrap();
let new_msg = invoke("greet", args).await;
greet_msg.set(new_msg.as_string().unwrap());
})
};

view! { cx,
view! {
main(class="container") {
h1 {
"Welcome to Tauri + Sycamore"
}

div(class="row") {
a(href="https://tauri.app",target="_blank") {
img(src="public/tauri.svg",class="logo tauri",alt="Tauri logo")
a(href="https://tauri.app", target="_blank") {
img(src="public/tauri.svg", class="logo tauri", alt="Tauri logo")
}
a(href="https://sycamore-rs.netlify.app",target="_blank") {
img(src="public/sycamore.svg",class="logo sycamore",alt="Sycamore logo")
a(href="https://sycamore.dev", target="_blank") {
img(src="public/sycamore.svg", class="logo sycamore", alt="Sycamore logo")
}
}
p {
"Click on the Tauri and Sycamore logos to learn more."
}

form(class="row",on:submit=greet) {
input(id="greet-input",bind:value=name,placeholder="Enter a name...")
button(type="submit") {
form(class="row", on:submit=greet) {
input(id="greet-input", bind:value=name, placeholder="Enter a name...")
button(r#type="submit") {
"Greet"
}
}
p {
(greet_msg.get())
(greet_msg)
}
}
}
Expand Down

0 comments on commit 7e5013d

Please sign in to comment.