Clone in a terminal:
Commit feeb091
Johan Mattsson - 2026-06-02T11:10:17+00:00
feeb09134ddcb7938176287b314ec367a79ae7d3johan.mattsson.m@gmail.com

Color in example

Changed files (3)

Diff

diff --git a/examples/callbacks/Cargo.toml b/examples/callbacks/Cargo.tomlindex 62c87c8..88d7b80 100644--- a/examples/callbacks/Cargo.toml+++ b/examples/callbacks/Cargo.toml@@ -10,7 +10,7 @@ crate-type = ["cdylib"] wasm-bindgen = "0.2.122" kaja-web = { path = "../.." } js-sys = "0.3"-web-sys = { version = "0.3.99", features = ["Element", "HtmlElement", "NodeList"] }+web-sys = { version = "0.3.99", features = ["Element", "HtmlElement", "NodeList", "CssStyleDeclaration"] } gloo = "0.12" kaja-html-macro = "1.0.3" serde = { version = "1.0.228", features = ["derive"] }diff --git a/examples/callbacks/src/lib.rs b/examples/callbacks/src/lib.rsindex 33f42a2..579ddbe 100644--- a/examples/callbacks/src/lib.rs+++ b/examples/callbacks/src/lib.rs@@ -1,4 +1,3 @@-#![cfg(target_arch = "wasm32")] use kaja_web::prelude::*; use serde::Deserialize; @@ -17,7 +16,7 @@ fn update() {             Test 1         </button> -        <button onclick="test2({test_parameter: 'just a test'}, 'string_param')">+        <button onclick="test2({test_parameter: 'just a test'}, 'string_param'">             Test 2         </button> @@ -33,14 +32,24 @@ fn update() {     } } +fn set_color(color: &str) {+    let main = get_element("#main-view");++    if let Some(main) = main {+        let _ = main.style().set_property("background-color", color);+    }+}+ #[callback(test0)] pub fn test0() {     log!("test0 called");+    set_color("red"); }  #[callback(test1)] pub fn test1(arg0_rust: Test1Data) {     log!("test1 called with parameter: {}", arg0_rust.test_parameter);+    set_color("blue"); }  #[callback(test2)]@@ -50,11 +59,13 @@ pub fn test2(arg0_rust: Test1Data, arg1_rust: String) {         arg0_rust.test_parameter,         arg1_rust     );+    set_color("green"); }  #[callback(test3)] pub fn test3(a: u32, b: u32, c: u32) {     log!("test3 {}, {} and {}", a, b, c);+    set_color("pink"); }  #[wasm_bindgen(start)]diff --git a/examples/callbacks/styles.css b/examples/callbacks/styles.cssindex cd7d9d0..6b596ec 100644--- a/examples/callbacks/styles.css+++ b/examples/callbacks/styles.css@@ -14,3 +14,7 @@ body {     justify-content: center;     padding: 40px 20px; }++#main-view {+    padding: 20px 20px 20px 20px;+}

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112