Skip to content

Commit da555e6

Browse files
authored
feat(practice): add option to practice missed biwords (@sanidhyas3s) (#5637)
also converts practice popup to a modal
1 parent f92e639 commit da555e6

11 files changed

Lines changed: 242 additions & 197 deletions

File tree

frontend/src/html/pages/test.html

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@
153153
aria-label="Restart Test"
154154
data-balloon-pos="down"
155155
class="text"
156-
onclick="this.blur();"
157156
>
158157
<i class="fas fa-fw fa-redo-alt"></i>
159158
</button>
@@ -375,11 +374,7 @@
375374
<div id="replayWords" class="words"></div>
376375
</div>
377376
</div>
378-
<button
379-
id="retrySavingResultButton"
380-
class="danger hidden"
381-
onclick="this.blur();"
382-
>
377+
<button id="retrySavingResultButton" class="danger hidden">
383378
<i class="fas fa-redo"></i>
384379
Retry saving result
385380
</button>
@@ -390,7 +385,6 @@
390385
aria-label="Next test"
391386
role="button"
392387
data-balloon-pos="down"
393-
onclick="this.blur();"
394388
>
395389
<i class="fas fa-fw fa-chevron-right"></i>
396390
</button>
@@ -400,7 +394,6 @@
400394
aria-label="Repeat test"
401395
role="button"
402396
data-balloon-pos="down"
403-
onclick="this.blur();"
404397
>
405398
<i class="fas fa-fw fa-sync-alt"></i>
406399
</button>
@@ -410,7 +403,6 @@
410403
aria-label="Practice words"
411404
role="button"
412405
data-balloon-pos="down"
413-
onclick="this.blur();"
414406
>
415407
<i class="fas fa-fw fa-exclamation-triangle"></i>
416408
</button>
@@ -420,7 +412,6 @@
420412
aria-label="Toggle words history"
421413
role="button"
422414
data-balloon-pos="down"
423-
onclick="this.blur();"
424415
>
425416
<i class="fas fa-fw fa-align-left"></i>
426417
</button>
@@ -430,7 +421,6 @@
430421
aria-label="Watch replay"
431422
role="button"
432423
data-balloon-pos="down"
433-
onclick="this.blur();"
434424
>
435425
<i class="fas fa-fw fa-backward"></i>
436426
</button>
@@ -440,7 +430,6 @@
440430
aria-label="Copy screenshot to clipboard"
441431
role="button"
442432
data-balloon-pos="down"
443-
onclick="this.blur();"
444433
>
445434
<i class="far fa-fw fa-image"></i>
446435
</button>
@@ -450,7 +439,6 @@
450439
aria-label="Watch video ad"
451440
role="button"
452441
data-balloon-pos="down"
453-
onclick="this.blur();"
454442
>
455443
<i class="fas fa-fw fa-ad"></i>
456444
</button> -->

frontend/src/html/popups.html

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -272,19 +272,44 @@
272272
</div>
273273
</dialog>
274274

275-
<div id="practiseWordsPopupWrapper" class="popupWrapper hidden" tabindex="-1">
276-
<div id="practiseWordsPopup" action="">
275+
<dialog id="practiseWordsModal" class="modalWrapper hidden">
276+
<div class="modal" actions="">
277277
<div class="title">Practice words</div>
278-
<div class="text">
279-
This will start a new test in custom mode. Words that you mistyped more
280-
often or words that you typed much slower will be weighted higher and
281-
appear more often.
278+
<!-- <div class="inputs"> -->
279+
<div class="group" data-id="missed">
280+
<div class="title">
281+
<i class="fas fa-times"></i>
282+
missed
283+
</div>
284+
<div class="sub">
285+
Include missed words or biwords (which include the previous word).
286+
</div>
287+
<div class="groupInputs">
288+
<div class="buttonGroup">
289+
<button class="missedOff" value="off">off</button>
290+
<button class="missedWords" value="words">words</button>
291+
<button class="missedBiwords" value="biwords">biwords</button>
292+
</div>
293+
</div>
294+
</div>
295+
<div class="group" data-id="slow">
296+
<div class="title">
297+
<i class="fas fa-tachometer-alt"></i>
298+
slow
299+
</div>
300+
<div class="sub">Include words which you typed slower than others.</div>
301+
<div class="groupInputs">
302+
<div class="buttonGroup">
303+
<button class="slowOff" value="false">off</button>
304+
<button class="slowOn" value="true">on</button>
305+
</div>
306+
</div>
282307
</div>
283-
<div class="button missed" tabindex="1">Practice missed</div>
284-
<div class="button slow" tabindex="1">Practice slow</div>
285-
<div class="button both" tabindex="1">Practice both</div>
308+
<div></div>
309+
<!-- </div> -->
310+
<button class="start">start</button>
286311
</div>
287-
</div>
312+
</dialog>
288313

289314
<dialog id="quoteRateModal" class="modalWrapper hidden">
290315
<div class="modal">

frontend/src/styles/popups.scss

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,39 @@ body.darkMode {
270270
}
271271
}
272272

273+
#practiseWordsModal {
274+
.modal {
275+
max-width: 400px;
276+
277+
.group {
278+
width: 100%;
279+
display: grid;
280+
.title {
281+
color: var(--sub-color);
282+
text-transform: lowercase;
283+
}
284+
.sub {
285+
color: var(--text-color);
286+
margin-top: 0.25rem;
287+
margin-bottom: 0.5rem;
288+
}
289+
.buttonGroup {
290+
display: flex;
291+
gap: 0.5rem;
292+
width: 100%;
293+
button {
294+
flex-grow: 1;
295+
}
296+
}
297+
}
298+
299+
.text {
300+
font-size: 1rem;
301+
color: var(--text-color);
302+
}
303+
}
304+
}
305+
273306
#savedTextsModal {
274307
.modal {
275308
max-width: 500px;
@@ -554,32 +587,6 @@ body.darkMode {
554587
}
555588
}
556589

557-
#practiseWordsPopupWrapper {
558-
#practiseWordsPopup {
559-
background: var(--bg-color);
560-
border-radius: var(--roundness);
561-
padding: 2rem;
562-
display: grid;
563-
gap: 1rem;
564-
width: 400px;
565-
566-
.title {
567-
font-size: 1.5rem;
568-
color: var(--sub-color);
569-
}
570-
571-
.tip {
572-
font-size: 0.75rem;
573-
color: var(--sub-color);
574-
}
575-
576-
.text {
577-
font-size: 1rem;
578-
color: var(--text-color);
579-
}
580-
}
581-
}
582-
583590
#googleSignUpModal {
584591
.modal {
585592
max-width: 425px;

frontend/src/ts/commandline/commandline.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ function handleInputSubmit(): void {
467467
throw new Error("Can't handle input submit - command is null");
468468
}
469469
inputModeParams.command.exec?.({
470+
commandlineModal: modal,
470471
input: inputValue,
471472
});
472473
void AnalyticsController.log("usedCommandLine", {

frontend/src/ts/commandline/lists/result-screen.ts

Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,11 @@
11
import * as TestLogic from "../../test/test-logic";
22
import * as TestUI from "../../test/test-ui";
3-
import * as PractiseWords from "../../test/practise-words";
3+
import * as PractiseWordsModal from "../../modals/practise-words";
44
import * as Notifications from "../../elements/notifications";
55
import * as TestInput from "../../test/test-input";
66
import * as TestWords from "../../test/test-words";
77
import Config from "../../config";
88

9-
const practiceSubgroup: MonkeyTypes.CommandsSubgroup = {
10-
title: "Practice words...",
11-
list: [
12-
{
13-
id: "practiseWordsMissed",
14-
display: "missed",
15-
exec: (): void => {
16-
PractiseWords.init(true, false);
17-
TestLogic.restart({
18-
practiseMissed: true,
19-
});
20-
},
21-
},
22-
{
23-
id: "practiseWordsSlow",
24-
display: "slow",
25-
exec: (): void => {
26-
PractiseWords.init(false, true);
27-
TestLogic.restart({
28-
practiseMissed: true,
29-
});
30-
},
31-
},
32-
{
33-
id: "practiseWordsBoth",
34-
display: "both",
35-
exec: (): void => {
36-
PractiseWords.init(true, true);
37-
TestLogic.restart({
38-
practiseMissed: true,
39-
});
40-
},
41-
},
42-
],
43-
};
44-
459
const commands: MonkeyTypes.Command[] = [
4610
{
4711
id: "nextTest",
@@ -70,9 +34,15 @@ const commands: MonkeyTypes.Command[] = [
7034
},
7135
{
7236
id: "practiseWords",
73-
display: "Practice words...",
37+
display: "Practice words",
7438
icon: "fa-exclamation-triangle",
75-
subgroup: practiceSubgroup,
39+
opensModal: true,
40+
exec: (options): void => {
41+
PractiseWordsModal.show({
42+
animationMode: "modalOnly",
43+
modalChain: options.commandlineModal,
44+
});
45+
},
7646
available: (): boolean => {
7747
return TestUI.resultVisible;
7848
},

frontend/src/ts/commandline/lists/tags.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,7 @@ function update(): void {
101101
shouldFocusTestUI: false,
102102
opensModal: true,
103103
exec: ({ commandlineModal }): void => {
104-
EditTagsPopup.show(
105-
"add",
106-
undefined,
107-
undefined,
108-
commandlineModal as AnimatedModal
109-
);
104+
EditTagsPopup.show("add", undefined, undefined, commandlineModal);
110105
},
111106
});
112107
}

frontend/src/ts/event-handlers/test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { getCommandline } from "../utils/async-modules";
22
import * as CustomWordAmount from "../modals/custom-word-amount";
3+
import Config from "../config";
34
import * as DB from "../db";
45
import * as EditResultTagsModal from "../modals/edit-result-tags";
56
import * as MobileTestConfigModal from "../modals/mobile-test-config";
@@ -10,6 +11,7 @@ import * as QuoteRateModal from "../modals/quote-rate";
1011
import * as QuoteReportModal from "../modals/quote-report";
1112
import * as QuoteSearchModal from "../modals/quote-search";
1213
import * as CustomTextModal from "../modals/custom-text";
14+
import * as PractiseWordsModal from "../modals/practise-words";
1315

1416
$(".pageTest").on("click", "#testModesNotice .textButton", async (event) => {
1517
const attr = $(event.currentTarget).attr("commands");
@@ -74,3 +76,11 @@ $(".pageTest").on("click", "#testConfig .quoteLength .textButton", (e) => {
7476
$(".pageTest").on("click", "#testConfig .customText .textButton", () => {
7577
CustomTextModal.show();
7678
});
79+
80+
$(".pageTest").on("click", "#practiseWordsButton", () => {
81+
if (Config.mode === "zen") {
82+
Notifications.add("Practice words is unsupported in zen mode", 0);
83+
return;
84+
}
85+
PractiseWordsModal.show();
86+
});

0 commit comments

Comments
 (0)