about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-07-27T20·07+0300
committertazjin <tazjin@tvl.su>2022-07-27T21·54+0000
commit5134a4809f7dfe2b7e10b08f2b90881ec2f34648 (patch)
tree88e082448da253c0b74d4fb83c7883317e702c4d
parent134efdab2541eb505e6f6fedc2fb48f94e1ab3be (diff)
feat(predlozhnik): wire up the actual предлог/вопрос matching r/4329
with this commit the application is sort of functional-ish as
intended.

users can select either cases or prepositions, have the remaining
choices appropriately constrained, and get the right question (i.e.
case) matching when selecting both.

there should be some explanatory translations and it needs to be
prettier, but this kind of does what I wanted.

Change-Id: If5bdaa7f93235dc267bf38cf13c2029f44d68415
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5984
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
-rw-r--r--users/tazjin/predlozhnik/src/main.rs21
1 files changed, 14 insertions, 7 deletions
diff --git a/users/tazjin/predlozhnik/src/main.rs b/users/tazjin/predlozhnik/src/main.rs
index 65c11f07db..0e5f7204e5 100644
--- a/users/tazjin/predlozhnik/src/main.rs
+++ b/users/tazjin/predlozhnik/src/main.rs
@@ -30,12 +30,12 @@ impl Падеж {
     fn вопрос(&self) -> &str {
         use Падеж::*;
         match self {
-            Именительный => "Кто? Что?",
-            Родительный => "Кого? Чего?",
-            Дательный => "Кому? Чему?",
-            Винительный => "Кого? Что?",
-            Творительный => "Кем? Чем?",
-            Предложный => "О ком? О чём?",
+            Именительный => "кто? Что?",
+            Родительный => "кого? Чего?",
+            Дательный => "кому? Чему?",
+            Винительный => "кого? Что?",
+            Творительный => "кем? Чем?",
+            Предложный => "о ком? О чём?",
         }
     }
 }
@@ -142,7 +142,7 @@ struct Вывод {
 
 fn объяснить(падеж: Падеж, предлог: &str) -> Html {
     html! {
-        {"NYI"}
+        {format!("{} {}", предлог, падеж.вопрос())}
     }
 }
 
@@ -260,6 +260,11 @@ impl Component for Модель {
             .map(|п| покажи_падеж(link, self, &вв, *п))
             .collect::<Html>();
 
+        let объяснение = вв
+            .объяснение
+            .map(|s| html! {{s}})
+            .unwrap_or_else(|| html! {});
+
         html! {
             <>
                 <link rel="stylesheet"
@@ -275,6 +280,8 @@ impl Component for Модель {
                   {кнапки_падежов}
                 </div>
                 <hr/>
+
+                {объяснение}
             </>
         }
     }