Skip to content

Commit

Permalink
w
Browse files Browse the repository at this point in the history
  • Loading branch information
zombkit committed Apr 26, 2024
1 parent e0d00cf commit e6a23a1
Show file tree
Hide file tree
Showing 34 changed files with 64 additions and 45 deletions.
14 changes: 0 additions & 14 deletions examples/colors_web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,6 @@
<!-- The WASM code will resize the canvas dynamically -->
<!-- the id is hardcoded in main.rs . so, make sure both match. -->
<canvas id="colors"></canvas>

<!--Register Service Worker. this will cache the wasm / js scripts for offline use (for PWA functionality). -->
<!-- Force refresh (Ctrl + F5) to load the latest files instead of cached files -->
<script>
// We disable caching during development so that we always view the latest version.
if (
"serviceWorker" in navigator &&
window.location.hash !== "#dev"
) {
window.addEventListener("load", function () {
navigator.serviceWorker.register("sw.js");
});
}
</script>
</body>
</html>

Expand Down
2 changes: 1 addition & 1 deletion examples/constraints_web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<body>
<!-- The WASM code will resize the canvas dynamically -->
<!-- the id is hardcoded in main.rs . so, make sure both match. -->
<canvas id="the_canvas_id"></canvas>
<canvas id="constraints"></canvas>
</body>
</html>

Expand Down
2 changes: 1 addition & 1 deletion examples/constraints_web/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl NewCC for HelloApp {
}
}
fn canvas_id() -> String {
"constraints_web".into()
"constraints".into()
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/demo2_web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<body>
<!-- The WASM code will resize the canvas dynamically -->
<!-- the id is hardcoded in main.rs . so, make sure both match. -->
<canvas id="the_canvas_id"></canvas>
<canvas id="demo2"></canvas>
</body>
</html>

Expand Down
3 changes: 3 additions & 0 deletions examples/demo2_web/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ impl NewCC for HelloApp {
last_tick,
}
}
fn canvas_id() -> String {
"demo2".into()
}
}

impl eframe::App for HelloApp {
Expand Down
2 changes: 1 addition & 1 deletion examples/demo_web/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 1 addition & 15 deletions examples/demo_web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,21 +118,7 @@
<body>
<!-- The WASM code will resize the canvas dynamically -->
<!-- the id is hardcoded in main.rs . so, make sure both match. -->
<canvas id="the_canvas_id"></canvas>

<!--Register Service Worker. this will cache the wasm / js scripts for offline use (for PWA functionality). -->
<!-- Force refresh (Ctrl + F5) to load the latest files instead of cached files -->
<script>
// We disable caching during development so that we always view the latest version.
if (
"serviceWorker" in navigator &&
window.location.hash !== "#dev"
) {
window.addEventListener("load", function () {
navigator.serviceWorker.register("sw.js");
});
}
</script>
<canvas id="demo"></canvas>
</body>
</html>

Expand Down
3 changes: 3 additions & 0 deletions examples/demo_web/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ impl NewCC for DemoApp {
last_tick: Instant::now(),
}
}
fn canvas_id() -> String {
"demo".into()
}
}

impl Default for DemoApp {
Expand Down
2 changes: 1 addition & 1 deletion examples/flex_web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<body>
<!-- The WASM code will resize the canvas dynamically -->
<!-- the id is hardcoded in main.rs . so, make sure both match. -->
<canvas id="the_canvas_id"></canvas>
<canvas id="flex"></canvas>
</body>
</html>

Expand Down
3 changes: 3 additions & 0 deletions examples/flex_web/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ impl NewCC for HelloApp {
last_tick,
}
}
fn canvas_id() -> String {
"flex".into()
}
}

impl eframe::App for HelloApp {
Expand Down
2 changes: 1 addition & 1 deletion examples/gauge_web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<body>
<!-- The WASM code will resize the canvas dynamically -->
<!-- the id is hardcoded in main.rs . so, make sure both match. -->
<canvas id="the_canvas_id"></canvas>
<canvas id="gauge"></canvas>
</body>
</html>

Expand Down
3 changes: 3 additions & 0 deletions examples/gauge_web/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ impl NewCC for HelloApp {
last_tick,
}
}
fn canvas_id() -> String {
"gauge".into()
}
}

impl eframe::App for HelloApp {
Expand Down
4 changes: 4 additions & 0 deletions examples/hello_world_web/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ impl NewCC for HelloApp {
let mut terminal = Terminal::new(backend).unwrap();
Self { terminal: terminal }
}
//matches index.html
fn canvas_id() -> String {
"the_canvas_id".into()
}
}

impl eframe::App for HelloApp {
Expand Down
2 changes: 1 addition & 1 deletion examples/layout_web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<body>
<!-- The WASM code will resize the canvas dynamically -->
<!-- the id is hardcoded in main.rs . so, make sure both match. -->
<canvas id="the_canvas_id"></canvas>
<canvas id="layout"></canvas>
</body>
</html>

Expand Down
3 changes: 3 additions & 0 deletions examples/layout_web/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ impl NewCC for HelloApp {
let mut terminal = Terminal::new(backend).unwrap();
Self { terminal: terminal }
}
fn canvas_id() -> String {
"layout".into()
}
}

impl eframe::App for HelloApp {
Expand Down
2 changes: 1 addition & 1 deletion examples/list_web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<body>
<!-- The WASM code will resize the canvas dynamically -->
<!-- the id is hardcoded in main.rs . so, make sure both match. -->
<canvas id="the_canvas_id"></canvas>
<canvas id="list"></canvas>
</body>
</html>

Expand Down
3 changes: 3 additions & 0 deletions examples/list_web/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ impl NewCC for HelloApp {
last_tick,
}
}
fn canvas_id() -> String {
"list".into()
}
}

impl eframe::App for HelloApp {
Expand Down
2 changes: 1 addition & 1 deletion examples/modifiers_web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<body>
<!-- The WASM code will resize the canvas dynamically -->
<!-- the id is hardcoded in main.rs . so, make sure both match. -->
<canvas id="the_canvas_id"></canvas>
<canvas id="modifiers"></canvas>
</body>
</html>

Expand Down
3 changes: 3 additions & 0 deletions examples/modifiers_web/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ impl NewCC for HelloApp {
let mut terminal = Terminal::new(backend).unwrap();
Self { terminal: terminal }
}
fn canvas_id() -> String {
"modifiers".into()
}
}

impl eframe::App for HelloApp {
Expand Down
2 changes: 1 addition & 1 deletion examples/paragraph_web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<body>
<!-- The WASM code will resize the canvas dynamically -->
<!-- the id is hardcoded in main.rs . so, make sure both match. -->
<canvas id="the_canvas_id"></canvas>
<canvas id="paragraph"></canvas>
</body>
</html>

Expand Down
3 changes: 3 additions & 0 deletions examples/paragraph_web/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ impl NewCC for HelloApp {
last_tick,
}
}
fn canvas_id() -> String {
"paragraph".into()
}
}

impl eframe::App for HelloApp {
Expand Down
2 changes: 1 addition & 1 deletion examples/popup_web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<body>
<!-- The WASM code will resize the canvas dynamically -->
<!-- the id is hardcoded in main.rs . so, make sure both match. -->
<canvas id="the_canvas_id"></canvas>
<canvas id="popup"></canvas>
</body>
</html>

Expand Down
3 changes: 3 additions & 0 deletions examples/popup_web/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ impl NewCC for HelloApp {
last_tick,
}
}
fn canvas_id() -> String {
"popup".into()
}
}

impl eframe::App for HelloApp {
Expand Down
2 changes: 1 addition & 1 deletion examples/ratatui_logo_web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<body>
<!-- The WASM code will resize the canvas dynamically -->
<!-- the id is hardcoded in main.rs . so, make sure both match. -->
<canvas id="the_canvas_id"></canvas>
<canvas id="ratatui_logo"></canvas>
</body>
</html>

Expand Down
3 changes: 3 additions & 0 deletions examples/ratatui_logo_web/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ impl NewCC for HelloApp {
let mut terminal = Terminal::new(backend).unwrap();
Self { terminal: terminal }
}
fn canvas_id() -> String {
"ratatui_logo".into()
}
}

impl eframe::App for HelloApp {
Expand Down
2 changes: 1 addition & 1 deletion examples/scrollbar_web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<body>
<!-- The WASM code will resize the canvas dynamically -->
<!-- the id is hardcoded in main.rs . so, make sure both match. -->
<canvas id="the_canvas_id"></canvas>
<canvas id="scrollbar"></canvas>
</body>
</html>

Expand Down
3 changes: 3 additions & 0 deletions examples/scrollbar_web/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ impl NewCC for HelloApp {
last_tick,
}
}
fn canvas_id() -> String {
"scrollbar".into()
}
}

impl eframe::App for HelloApp {
Expand Down
2 changes: 1 addition & 1 deletion examples/sparkline_web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<body>
<!-- The WASM code will resize the canvas dynamically -->
<!-- the id is hardcoded in main.rs . so, make sure both match. -->
<canvas id="the_canvas_id"></canvas>
<canvas id="sparkline"></canvas>
</body>
</html>

Expand Down
3 changes: 3 additions & 0 deletions examples/sparkline_web/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ impl NewCC for HelloApp {
last_tick,
}
}
fn canvas_id() -> String {
"sparkline".into()
}
}

impl eframe::App for HelloApp {
Expand Down
2 changes: 1 addition & 1 deletion examples/table_web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<body>
<!-- The WASM code will resize the canvas dynamically -->
<!-- the id is hardcoded in main.rs . so, make sure both match. -->
<canvas id="the_canvas_id"></canvas>
<canvas id="table"></canvas>
</body>
</html>

Expand Down
3 changes: 3 additions & 0 deletions examples/table_web/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ impl NewCC for HelloApp {
last_tick,
}
}
fn canvas_id() -> String {
"table".into()
}
}

impl eframe::App for HelloApp {
Expand Down
2 changes: 1 addition & 1 deletion examples/tabs_web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<body>
<!-- The WASM code will resize the canvas dynamically -->
<!-- the id is hardcoded in main.rs . so, make sure both match. -->
<canvas id="the_canvas_id"></canvas>
<canvas id="tabs"></canvas>
</body>
</html>

Expand Down
3 changes: 3 additions & 0 deletions examples/tabs_web/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ impl NewCC for HelloApp {
last_tick,
}
}
fn canvas_id() -> String {
"tabs".into()
}
}

impl eframe::App for HelloApp {
Expand Down
1 change: 1 addition & 0 deletions src/wasm_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

/// Implement this trait when you want to setup ratatui to use custom fonts
/// Otherwise it will use the default egui font which is missing extra unicode characters
/// .Implement canvas_id() for a custom canvas id
pub trait NewCC {
fn new(cc: &eframe::CreationContext<'_>) -> Self;
///set this to the same canvas id as in the index.html
Expand Down

0 comments on commit e6a23a1

Please sign in to comment.