@@ -9,51 +9,29 @@ description = "Just a simple calculator made with Rust + Iced"
99image = " thumbnail.png"
1010+++
1111
12- This is a Rust calculator built with Iced UI running in WebAssembly.
13-
14- <div style =" text-align : center ; margin : 40px 0 ;" >
15- <button id="calc-button" style="padding: 15px 30px; font-size: 18px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border: none; border-radius: 8px; cursor: pointer; box-shadow: 0 4px 15px rgba(0,0,0,0.2); transition: all 0.3s ease;">
16- Launch Calculator
17- </button>
18- </div >
19-
20- <div id =" calculator-container " style =" display : none ; width : 100% ; height : 600px ; border : 1px solid #ccc ; margin : 20px 0 ;" ></div >
12+ <div id =" calculator-frame " style =" width : 400px ; height : 500px ; border : 2px solid #ddd ; border-radius : 8px ; margin : 20px auto ; overflow : hidden ; box-shadow : 0 4px 6px rgba (0 ,0 ,0 ,0.1 ); background : white ;" ></div >
2113
2214<script type =" module " >
2315 import init , * as bindings from ' ./iced_test-7afbea151ae2bbad.js' ;
2416
25- let calcInitialized = false ;
26-
27- document .getElementById (' calc-button' ).addEventListener (' click' , async () => {
28- if (! calcInitialized) {
29- const container = document .getElementById (' calculator-container' );
30- container .style .display = ' block' ;
31-
32- try {
33- const wasm = await init ({ module_or_path: ' ./iced_test-7afbea151ae2bbad_bg.wasm' });
34- window .wasmBindings = bindings;
35- dispatchEvent (new CustomEvent (" TrunkApplicationStarted" , {detail: {wasm}}));
36- calcInitialized = true ;
37- } catch (error) {
38- console .error (' Failed to load calculator:' , error);
39- container .innerHTML = ' <p style="color: red; text-align: center;">Failed to load calculator. Please check console for details.</p>' ;
17+ // Initialize calculator immediately
18+ try {
19+ const wasm = await init ({ module_or_path: ' ./iced_test-7afbea151ae2bbad_bg.wasm' });
20+ window .wasmBindings = bindings;
21+ dispatchEvent (new CustomEvent (" TrunkApplicationStarted" , {detail: {wasm}}));
22+
23+ // Move the calculator canvas into our frame
24+ setTimeout (() => {
25+ const canvas = document .querySelector (' canvas' );
26+ const frame = document .getElementById (' calculator-frame' );
27+ if (canvas && frame) {
28+ frame .appendChild (canvas);
4029 }
41- }
42- });
43- </script >
44-
45- <style >
46- #calc-button :hover {
47- transform : translateY (-2px );
48- box-shadow : 0 6px 20px rgba (0 ,0 ,0 ,0.3 );
49- }
50-
51- #calc-button :active {
52- transform : translateY (0 );
30+ }, 100 );
31+ } catch (error) {
32+ console .error (' Failed to load calculator:' , error);
33+ document .getElementById (' calculator-frame' ).innerHTML = ' <p style="color: red; text-align: center; padding: 20px;">Failed to load calculator. Please check console for details.</p>' ;
5334 }
35+ </script >
5436
55- #calculator-container {
56- background : #f5f5f5 ;
57- border-radius : 8px ;
58- }
59- </style >
37+ This is a Rust calculator built with Iced UI running in WebAssembly.
0 commit comments