feat(tazjin/predlozhnik): bootstrap yew/wasm-based web UI

this commit is mostly to figure out hwo to build a yew application in
depot using the wasm toolchain. it's a bit finnicky, but could be a
lot worse.

Change-Id: I7804a774f1686a1f308ae1a3f549cd0ae7b5dbeb
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5980
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
Vincent Ambo 2022-07-27 14:04:02 +03:00 committed by tazjin
parent 38d01f7f3b
commit d795a05c07
5 changed files with 528 additions and 3 deletions

View file

@ -1,6 +1,9 @@
use yew::prelude::*;
use lazy_static::lazy_static;
use maplit::hashmap;
use std::collections::HashMap;
use std::fmt::Write;
#[derive(Debug, Hash, PartialEq, Eq)]
enum Падеж {
@ -95,11 +98,40 @@ lazy_static! {
};
}
fn main() {
fn example_output() -> String {
let mut out = String::new();
for (пд, пги) in &*ПОАДЕЖУ {
println!("Падеж: {:?}", пд);
write!(out, "Падеж: {:?}\n", пд).ok();
for п in пги {
println!("\t{}", п);
write!(out, "\t{}\n", п).ok();
}
}
out
}
struct Model(());
impl Component for Model {
type Message = ();
type Properties = ();
fn create(_ctx: &Context<Self>) -> Self {
Self(())
}
fn update(&mut self, _ctx: &Context<Self>, _msg: Self::Message) -> bool {
false
}
fn view(&self, _ctx: &Context<Self>) -> Html {
html! {
<pre>{example_output()}</pre>
}
}
}
fn main() {
yew::start_app::<Model>();
}