fix-wasm-foo #2

Merged
tristan merged 5 commits from fix-wasm-foo into main 2025-02-10 14:52:32 +00:00
6 changed files with 4 additions and 136 deletions
Showing only changes of commit ee89aa55d7 - Show all commits

View file

@ -23,7 +23,7 @@ lto = "fat"
panic = "abort" panic = "abort"
[workspace] [workspace]
members = ["frozen_llama", "llama_proxy_man", "redvault_el_rs", "garnix"] members = ["llama_proxy_man", "redvault_el_rs", "garnix"]
resolver = "2" resolver = "2"
[workspace.package] [workspace.package]
@ -36,8 +36,8 @@ repository = "https://git.vlt81.de/oekonzept/oeko-mono"
version = "0.1.1" version = "0.1.1"
edition = "2021" edition = "2021"
[workspace.dependencies] # [workspace.dependencies]
# iced = { git = "https://github.com/iced-rs/iced.git", branch = "master" } # iced = { git = "https://github.com/iced-rs/iced.git", branch = "master" }
[workspace.metadata.cargo-all-features] # [workspace.metadata.cargo-all-features]
skip_feature_sets = [["csr", "ssr"], ["csr", "hydrate"], ["ssr", "hydrate"]] # skip_feature_sets = [["csr", "ssr"], ["csr", "hydrate"], ["ssr", "hydrate"]]

View file

@ -1,12 +0,0 @@
[package]
name = "frozen_llama"
version.workspace=true
authors.workspace=true
edition.workspace=true
publish.workspace=true
[dependencies]
iced = { version = "0.13", features = [ "markdown", "highlighter" ]}
[target.'cfg(target_arch = "wasm32")'.dependencies]
iced = { version = "0.13", features = [ "markdown", "highlighter", "webgl" ]}

View file

@ -1,24 +0,0 @@
## Counter
The classic counter example explained in the [`README`](../../README.md).
The __[`main`]__ file contains all the code of the example.
<div align="center">
<img src="https://iced.rs/examples/counter.gif">
</div>
You can run it with `cargo run`:
```
cargo run --package counter
```
The web version can be run with [`trunk`]:
```
cd examples/counter
trunk serve
```
[`main`]: src/main.rs
[`trunk`]: https://trunkrs.dev/

View file

@ -1,12 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Counter - Iced</title>
<base data-trunk-public-url />
</head>
<body>
<link data-trunk rel="rust" href="Cargo.toml" data-wasm-opt="z" data-bin="frozen_llama" />
</body>
</html>

View file

@ -1,45 +0,0 @@
use iced::widget::{button, column, text, Column};
use iced::Center;
mod markdown;
use markdown::*;
pub fn main() -> iced::Result {
let md = markdown::Markdown::new();
// iced::run("A cool counter", Counter::update, Counter::view)
iced::run("", markdown::Markdown::update, markdown::Markdown::view)
}
#[derive(Default)]
struct Counter {
value: i64,
}
#[derive(Debug, Clone, Copy)]
enum Message {
Increment,
Decrement,
}
impl Counter {
fn update(&mut self, message: Message) {
match message {
Message::Increment => {
self.value += 1;
}
Message::Decrement => {
self.value -= 1;
}
}
}
fn view(&self) -> Column<Message> {
column![
button("Increment").on_press(Message::Increment),
text(self.value).size(50),
button("Decrement").on_press(Message::Decrement),
]
.padding(20)
.align_x(Center)
}
}

View file

@ -1,39 +0,0 @@
use iced::widget::markdown;
use iced::Element;
use iced::Theme;
#[derive(Debug, Clone, Default)]
pub struct Markdown {
markdown: Vec<markdown::Item>,
}
#[derive(Debug)]
pub enum Message {
LinkClicked(markdown::Url),
}
impl Markdown {
pub fn new() -> Self {
Self {
markdown: markdown::parse("This is some **Markdown**!").collect(),
}
}
pub fn view(&self) -> Element<'_, Message> {
markdown::view(
&self.markdown,
markdown::Settings::default(),
markdown::Style::from_palette(Theme::TokyoNightStorm.palette()),
)
.map(Message::LinkClicked)
.into()
}
pub fn update(_state: &mut Self, message: Message) {
match message {
Message::LinkClicked(url) => {
println!("The following url was clicked: {url}");
}
}
}
}