Skip to content

Commit 2e3525a

Browse files
author
AvidDollars
committed
improve highlighting of errors during typing session
1 parent 4b6aa28 commit 2e3525a

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

frontend/src/app/main-area/main-area.component.html

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,18 @@
3838
class="opacity-50"
3939
>
4040
@for (char of text; track $index) {
41-
<!-- use typoo in order to match background with the foreground text (except Enter) -->
41+
<!-- use typoo in order to match background with the foreground text (except Enter or Space) -->
4242
@let typoo = activeTypoos.get($index);
43-
@let replacement = (typoo === "Enter") ? char : typoo;
44-
<span [class]="{'bg-red-500': typoo}">{{ (typoo) ? replacement : char }}</span>
43+
@let charIsInvisible = char === " " || char === "Enter";
44+
@let typooIsInvisible = typoo === " " || typoo === "Enter";
45+
@let replacement = (typooIsInvisible) ? char : (charIsInvisible) ? char : typoo;
46+
47+
<!-- TODO: if mistake is made at the end of line: no highlighting -->
48+
<span [class]="{
49+
'bg-invalid': typoo,
50+
'text-invisible-typoo': typooIsInvisible,
51+
}"
52+
>{{ (typoo) ? replacement : char }}</span>
4553
}
4654
</div>
4755

frontend/src/app/main-area/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ export class SessionState {
114114
return ((this.#charArray.length + this.#errorCounter) / 5) / durationMinutes;
115115
}
116116

117+
// TODO: high error rate -> negative value
117118
/**
118119
* gross_wpm - (uncorrected_errors / time_in_minutes)
119120
*/

frontend/src/styles.scss

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
--secondary-color: rgb(112, 112, 34);
1919
--secondary-color-dark: rgb(58, 58, 17);
2020

21-
--color-invalid: rgb(211, 75, 75);
21+
--color-invalid: rgb(228, 89, 89);
2222
--color-valid: rgb(66, 153, 45);
23+
--color-invisible-typoo: rgb(0, 0, 0);
2324
}
2425

2526
[data-theme="light"] {
@@ -38,8 +39,9 @@
3839
--secondary-color-dark: rgb(85, 85, 28);
3940
--secondary-color-light: rgb(160, 160, 77);
4041

41-
--color-invalid: rgb(214, 109, 109);
42+
--color-invalid: rgb(209, 68, 68);
4243
--color-valid: rgb(63, 194, 63);
44+
--color-invisible-typoo: rgb(255, 255, 255);
4345
}
4446

4547
[data-theme="blues"] {
@@ -58,7 +60,7 @@
5860
--secondary-color-dark: rgb(59, 109, 53);
5961
--secondary-color-light: rgb(154, 206, 147);
6062

61-
--color-invalid: rgb(214, 109, 109);
63+
--color-invalid: rgb(209, 157, 177);
6264
--color-valid: rgb(63, 194, 63);
6365
}
6466

@@ -89,6 +91,7 @@
8991

9092
--color-light: var(--bg-color-light);
9193
--color-text: var(--text-color);
94+
--color-invisible-typoo: var(--color-invisible-typoo); // if typoo is "space" / "enter
9295
}
9396

9497
// FOR SUBMITTING FORMS

0 commit comments

Comments
 (0)