Skip to content

Commit 96476a0

Browse files
committed
added an option to increase the test words font size
1 parent f8eeef9 commit 96476a0

5 files changed

Lines changed: 134 additions & 4 deletions

File tree

public/css/style.scss

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,21 @@ a:hover {
306306
// transition: 0.05s;
307307
}
308308

309+
#caret.size125{
310+
height: 2rem;
311+
width: 2px;
312+
}
313+
314+
#caret.size15{
315+
height: 2.25rem;
316+
width: 3px;
317+
}
318+
319+
#caret.size2{
320+
height: 3rem;
321+
width: 4px;
322+
}
323+
309324
@keyframes caretFlash {
310325
0% {
311326
background: transparent;
@@ -700,12 +715,31 @@ key {
700715
}
701716

702717
.word {
703-
margin: 5px 5px;
718+
margin: .25rem;
704719
color: var(--sub-color);
705720
display: flex;
706721
// transition: 0.25s;
707722
/* margin-bottom: 1px; */
708723
border-bottom: 2px solid transparent;
724+
line-height: 1rem;
725+
}
726+
727+
#words.size125 .word{
728+
line-height: 1.25rem;
729+
font-size: 1.25rem;
730+
margin: .31rem;
731+
}
732+
733+
#words.size15 .word{
734+
line-height: 1.5rem;
735+
font-size: 1.5rem;
736+
margin: .37rem;
737+
}
738+
739+
#words.size2 .word{
740+
line-height: 2rem;
741+
font-size: 2rem;
742+
margin: .5rem;
709743
}
710744

711745
.word.error {
@@ -726,8 +760,8 @@ key {
726760

727761
.word letter {
728762
// transition: .1s;
729-
height: 1rem;
730-
line-height: 1rem;
763+
// height: 1rem;
764+
// line-height: 1rem;
731765
/* margin: 0 1px; */
732766
}
733767

public/index.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,16 @@ <h1>show key tips</h1>
231231
<div class="text">Shows the keybind tips at the bottom of the page.</div>
232232
<div class="buttons"><div class="button on" tabindex="0">show</div><div class="button off" tabindex="0">hide</div></div>
233233
</div>
234+
<div class="section fontSize">
235+
<h1>font size</h1>
236+
<div class="text">Change the font size of the test words</div>
237+
<div class="buttons">
238+
<div class="button" fontsize="1" tabindex="0">1</div>
239+
<div class="button" fontsize="125" tabindex="0">1.25</div>
240+
<div class="button" fontsize="15" tabindex="0">1.5</div>
241+
<div class="button" fontsize="2" tabindex="0">2</div>
242+
</div>
243+
</div>
234244
<div class="section" style="grid-column: 1/3;">
235245
<h1>languages</h1>
236246
<div class="languages">

public/js/commandline.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ let commands = {
6060
showCommandLine();
6161
}
6262
},
63+
{
64+
id: "changeFontSize",
65+
display: "Change font size...",
66+
subgroup: true,
67+
exec: () => {
68+
currentCommands = commandsFontSize;
69+
showCommandLine();
70+
}
71+
},
6372
{
6473
id: "changeMode",
6574
display: "Change mode...",
@@ -242,6 +251,40 @@ let commandsTimeConfig = {
242251
]
243252
};
244253

254+
let commandsFontSize = {
255+
title: "Change font size...",
256+
list: [
257+
{
258+
id: "changeFontSize1",
259+
display: "1x",
260+
exec: () => {
261+
changeFontSize(1)
262+
}
263+
},
264+
{
265+
id: "changeFontSize125",
266+
display: "1.25x",
267+
exec: () => {
268+
changeFontSize(125)
269+
}
270+
},
271+
{
272+
id: "changeFontSize15",
273+
display: "1.5x",
274+
exec: () => {
275+
changeFontSize(15)
276+
}
277+
},
278+
{
279+
id: "changeFontSize2",
280+
display: "2x",
281+
exec: () => {
282+
changeFontSize(2)
283+
}
284+
}
285+
]
286+
};
287+
245288
let themesList;
246289

247290
$.getJSON("themes/list.json", function(data) {

public/js/settings.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function updateSettingsPage(){
1717

1818
setActiveThemeButton();
1919
setActiveLanguageButton();
20+
setActiveFontSizeButton();
2021

2122
if (config.showKeyTips) {
2223
$(".pageSettings .tip").removeClass('hidden');
@@ -32,6 +33,11 @@ function setActiveThemeButton() {
3233
$(`.pageSettings .section .themes .theme[theme=${config.theme}]`).addClass('active');
3334
}
3435

36+
function setActiveFontSizeButton() {
37+
$(`.pageSettings .section.fontSize .buttons .button`).removeClass('active');
38+
$(`.pageSettings .section.fontSize .buttons .button[fontsize=`+config.fontSize+`]`).addClass('active');
39+
}
40+
3541
function setActiveLanguageButton() {
3642
$(`.pageSettings .section .languages .language`).removeClass('active');
3743
$(`.pageSettings .section .languages .language[language=${config.language}]`).addClass('active');
@@ -126,6 +132,15 @@ $(document).on("mouseleave",".pageSettings .section .themes", (e) => {
126132
$(document).on("click",".pageSettings .section .languages .language", (e) => {
127133
let language = $(e.currentTarget).attr('language');
128134
changeLanguage(language);
135+
showNotification('Language changed', 1000);
129136
restartTest();
130137
setActiveLanguageButton();
138+
})
139+
140+
//fontsize
141+
$(document).on("click",".pageSettings .section.fontSize .button", (e) => {
142+
let fontSize = $(e.currentTarget).attr('fontsize');
143+
changeFontSize(fontSize);
144+
showNotification('Font size changed', 1000);
145+
setActiveFontSizeButton();
131146
})

public/js/userconfig.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ let config = {
88
words: 50,
99
time: 30,
1010
mode: "words",
11-
language: "english"
11+
language: "english",
12+
fontSize: 1
1213
}
1314

1415
//cookies
@@ -31,6 +32,7 @@ function loadConfigFromCookie() {
3132
changeWordCount(newConfig.words);
3233
changeMode(newConfig.mode);
3334
changeLanguage(newConfig.language);
35+
changeFontSize(newConfig.fontSize);
3436
config = newConfig;
3537
restartTest();
3638
}
@@ -154,3 +156,29 @@ function changeLanguage(language) {
154156
});
155157
saveConfigToCookie();
156158
}
159+
160+
function changeFontSize(fontSize) {
161+
if (fontSize == null || fontSize == undefined) {
162+
fontSize = 1;
163+
}
164+
config.fontSize = fontSize;
165+
$("#words").removeClass('size125');
166+
$("#caret").removeClass('size125');
167+
$("#words").removeClass('size15');
168+
$("#caret").removeClass('size15');
169+
$("#words").removeClass('size2');
170+
$("#caret").removeClass('size2');
171+
172+
if (fontSize == 125) {
173+
$("#words").addClass('size125');
174+
$("#caret").addClass('size125');
175+
} else if (fontSize == 15) {
176+
$("#words").addClass('size15');
177+
$("#caret").addClass('size15');
178+
} else if (fontSize == 2) {
179+
$("#words").addClass('size2');
180+
$("#caret").addClass('size2');
181+
}
182+
updateCaretPosition();
183+
saveConfigToCookie();
184+
}

0 commit comments

Comments
 (0)