about summary refs log tree commit diff
path: root/users/tazjin/predlozhnik/src
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-07-27T11·04+0300
committertazjin <tazjin@tvl.su>2022-07-27T21·54+0000
commitd795a05c0719dd75b67327cb7cfdaaf6aded16dd (patch)
tree1fdb4464690e39c254034a1b7498c48322067ae3 /users/tazjin/predlozhnik/src
parent38d01f7f3b3f5679e704456fe3ec51c768a7a052 (diff)
feat(tazjin/predlozhnik): bootstrap yew/wasm-based web UI r/4325
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>
Diffstat (limited to 'users/tazjin/predlozhnik/src')
-rw-r--r--users/tazjin/predlozhnik/src/main.rs38
1 files changed, 35 insertions, 3 deletions
diff --git a/users/tazjin/predlozhnik/src/main.rs b/users/tazjin/predlozhnik/src/main.rs
index 73b19201fbb4..ba9eed25cbbd 100644
--- a/users/tazjin/predlozhnik/src/main.rs
+++ b/users/tazjin/predlozhnik/src/main.rs
@@ -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>();
 }