Skip to content

Commit d004ad9

Browse files
committed
Add: "ignore" to word comfort levels.
1 parent 613d3d9 commit d004ad9

File tree

4 files changed

+36
-18
lines changed

4 files changed

+36
-18
lines changed

src/app/renderer/components.cljs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,18 +263,21 @@
263263
:on-change (fn [e] (swap! form assoc :translation (-> e .-target .-value)))}]
264264

265265
;; radio button
266-
[:div.my-2.flex.md:flex-col.xl:flex-row.xl:justify-between
266+
[:div.my-2.flex.md:flex-col.lg:flex-row.xl:justify-between.flex-wrap
267267
(doall ;; needed for deref (@) in lazy for loop.
268268
(for [[comfort-int comfort-data] u/comfort-text-and-col
269-
:let [{:keys [name text-col]} comfort-data]]
270-
[:span.flex.xl:justify-between.items-center.mr-2 {:key comfort-int}
269+
:let [{:keys [name text-col help-text]} comfort-data]]
270+
[:span {:class "flex items-center lg:w-1/2 xl:w-1/3"
271+
:key comfort-int}
271272
[:input {:id name
272273
:type "radio"
273274
:value comfort-int
274275
:name "group-1"
275276
:checked (= (@form :comfort) comfort-int)
276277
:on-change (fn [e] (swap! form assoc :comfort (-> e .-target .-value int)))}]
277-
[:label {:for name :class (str "text-sm p-0.5 pl-1 " text-col)} (str name "(" (+ 1 comfort-int) ")")]]))]
278+
[:label {:for name
279+
:title help-text
280+
:class (str "text-sm p-0.5 pl-1 pr-2 " text-col)} (str name "(" (+ 1 comfort-int) ")")]]))]
278281

279282
;; submit update
280283
[:div.mt-4 [button {:type "submit"

src/app/renderer/events.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
(r-fx :key-pressed-num
145145
(fn [{:keys [db]} event]
146146
(let [last-key (-> event last last)
147-
key->comfort-val {49 0 50 1 51 2 52 3 53 4}
147+
key->comfort-val {49 0 50 1 51 2 52 3 53 4 54 5}
148148
current-word (-> db :current-word)
149149
new-word-with-comfort (assoc current-word :comfort (get key->comfort-val (last-key :keyCode)))]
150150
(when (u/curr-word-view-open? db)

src/app/renderer/re_pressed.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@
285285
:event-keys [[[:key-pressed-right] [{:keyCode 39}]] ;; right arrow pressed once.
286286
[[:key-pressed-left] [{:keyCode 37}]] ;; left arrow pressed
287287
[[:key-pressed-shift] [{:keyCode 16}]]
288-
[[:key-pressed-num] [{:keyCode 49}] [{:keyCode 50}] [{:keyCode 51}] [{:keyCode 52}] [{:keyCode 53}]]
288+
[[:key-pressed-num] [{:keyCode 49}] [{:keyCode 50}] [{:keyCode 51}] [{:keyCode 52}] [{:keyCode 53}] [{:keyCode 54}]]
289289
]
290290
:clear-keys [] ;; takes a collection of key combos that, if pressed, will clear the recorded keys [{:keycode 27}]
291291
:always-listen-keys [] ;; takes a collection of keys that will always be recorded (regardless if the user is typing in an input, select, or textarea)

src/app/shared/util.cljs

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,37 @@
1515
(apply prn args)))
1616

1717
(def comfort-text-and-col
18-
{0 {:name "Unknown" :text-col "text-gray-800 dark:text-gray-200" :bg-col "bg-gray-300 dark:bg-gray-800"}
19-
1 {:name "Hard" :text-col "text-red-500" :bg-col "bg-red-300"}
20-
2 {:name "Medium" :text-col "text-yellow-500" :bg-col "bg-yellow-300"}
21-
3 {:name "Easy" :text-col "text-green-600" :bg-col "bg-green-300"}
22-
4 {:name "Known" :text-col "text-black dark:text-gray-500" :bg-col "bg-white dark:bg-gray-900"}})
18+
{0 {:name "Unknown"
19+
:text-col "text-gray-800 dark:text-gray-200"
20+
:bg-col "bg-gray-300 dark:bg-gray-800"
21+
:help-text "A word with no comfort or translation assigned."}
22+
1 {:name "Hard"
23+
:text-col "text-red-500"
24+
:bg-col "bg-red-300"
25+
:help-text "A difficult word you are in the process of learning."}
26+
2 {:name "Medium"
27+
:text-col "text-yellow-500"
28+
:bg-col "bg-yellow-300"
29+
:help-text "A word you know fairly well."}
30+
3 {:name "Easy"
31+
:text-col "text-green-600"
32+
:bg-col "bg-green-300"
33+
:help-text "A word that you almost always remember."}
34+
4 {:name "Known"
35+
:text-col "text-black dark:text-gray-200"
36+
:bg-col "bg-white dark:bg-gray-900"
37+
:help-text "A well known word that you don't need to study."}
38+
5 {:name "Ignore"
39+
:text-col "text-gray-500 dark:text-gray-400"
40+
:bg-col "bg-gray-50 dark:bg-gray-900"
41+
:help-text "Ignore this word (ex: proper nouns, untranslateable words etc.)"}})
2342

2443
(defn get-comfort-level-name [idx]
2544
(-> idx comfort-text-and-col :name))
2645

2746
(defn get-comfort-bg-col [idx]
2847
(-> idx comfort-text-and-col :bg-col))
2948

30-
3149
(defn split-article
3250
"Splits a string by whitespace and punctuation"
3351
[string]
@@ -113,13 +131,11 @@
113131
(when ts
114132
(-> ts js/Date. (.toLocaleDateString))))
115133

116-
117134
;; class light + dark
118135
(defn twld
119136
"Takes two strings, and adds dark mode to the end class"
120137
[a b]
121-
(let [
122-
with-dark (->> (str/split b " ")
138+
(let [with-dark (->> (str/split b " ")
123139
(map (fn [s] (str "dark:" s)))
124140
(str/join " "))]
125141
(str a " " with-dark)))
@@ -146,7 +162,6 @@
146162
(assoc :capture-buffer []))
147163
(-> acc
148164
(assoc :out (into [] (concat (acc :out) (acc :capture-buffer) [curr])))
149-
(assoc :capture-buffer [])))
150-
)))
151-
{:out [] :capture-buffer [] } word-data)]
165+
(assoc :capture-buffer []))))))
166+
{:out [] :capture-buffer []} word-data)]
152167
(res :out)))

0 commit comments

Comments
 (0)