Skip to content

Commit 519ed78

Browse files
committed
improves mobile version, refactors
1 parent 798ee0a commit 519ed78

7 files changed

Lines changed: 51 additions & 20 deletions

File tree

source/data/signs.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ const signs = [
115115
{ img: "images/hungarian2.png", lang: "Hungarian", options: ["Hungarian", "Finnish", "Estonian", "Romanian"] },
116116
{ img: "images/hungarian3.png", lang: "Hungarian", options: ["Hungarian", "Finnish", "Estonian", "Romanian"] },
117117

118-
{ img: "images/slovakian1.png", lang: "Slovak", options: ["Slovak", "Czech", "Polish", "Slovenian"] },
119-
{ img: "images/slovakian2.png", lang: "Slovak", options: ["Slovak", "Czech", "Polish", "Slovenian"] },
120-
{ img: "images/slovakian3.png", lang: "Slovak", options: ["Slovak", "Czech", "Polish", "Slovenian"] },
118+
{ img: "images/slovak1.png", lang: "Slovak", options: ["Slovak", "Czech", "Polish", "Slovenian"] },
119+
{ img: "images/slovak2.png", lang: "Slovak", options: ["Slovak", "Czech", "Polish", "Slovenian"] },
120+
{ img: "images/slovak3.png", lang: "Slovak", options: ["Slovak", "Czech", "Polish", "Slovenian"] },
121121

122122
{ img: "images/czech1.png", lang: "Czech", options: ["Czech", "Slovak", "Polish", "Slovenian"] },
123123
{ img: "images/czech2.png", lang: "Czech", options: ["Czech", "Slovak", "Polish", "Slovenian"] },

source/index.html

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,21 @@
1414
<h1 class="game__title">whatlang?</h1>
1515

1616
<!-- ============================================================ -->
17-
<!-- Game bar: Score, Record, Rounds selector, Rounds counter -->
17+
<!-- Game bar: Score, Record, Settings -->
1818
<!-- ============================================================ -->
1919
<div class="game__bar game-bar">
20-
Score: <span id="score">0</span> • Record: <span id="record">0</span>
21-
<select id="rounds-select" class="game-bar__rounds-select">
22-
<option value="10">10 rounds</option>
23-
<option value="20">20 rounds</option>
24-
<option value="30">30 rounds</option>
25-
<option value="0" selected>no limit</option>
26-
</select>
27-
<span id="rounds-counter" class="game-bar__rounds-counter"></span>
20+
<div class="game-bar__points">
21+
Score: <output id="score">0</output> • Record: <output id="record">0</output>
22+
</div>
23+
<div class="game-bar__settings">
24+
<select id="rounds-select" class="game-bar__rounds-select">
25+
<option value="10">10 rounds</option>
26+
<option value="20">20 rounds</option>
27+
<option value="30">30 rounds</option>
28+
<option value="0" selected>no limit</option>
29+
</select>
30+
<span id="rounds-counter" class="game-bar__rounds-counter"></span>
31+
</div>
2832
</div>
2933

3034
<!-- ============================================================ -->

source/script.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const nextBtn = document.getElementById('next');
1212
const roundsSel = document.getElementById('rounds-select');
1313
const roundsCounter = document.getElementById('rounds-counter');
1414

15-
recordEl.textContent = record;
15+
recordEl.value = record;
1616

1717
let pool = [...signs].sort(() => Math.random() - 0.5);
1818
let index = 0;
@@ -24,7 +24,7 @@ let index = 0;
2424
function restartGame() {
2525
score = 0;
2626
used.clear();
27-
scoreEl.textContent = 0;
27+
scoreEl.value = 0;
2828

2929
roundsLimit = parseInt(roundsSel.value, 10);
3030
roundsLeft = roundsLimit === 0 ? Infinity : roundsLimit;
@@ -77,18 +77,18 @@ function checkAnswer(ans, correct, btn) {
7777
if (ans === correct) {
7878
score++;
7979
used.add(correct);
80-
scoreEl.textContent = score;
80+
scoreEl.value = score;
8181
btn.classList.add('correct');
8282
resultEl.textContent = 'Correct!';
8383

8484
if (score > record) {
8585
record = score;
86-
recordEl.textContent = record;
86+
recordEl.value = record;
8787
localStorage.setItem('whatlangRecord', record);
8888
}
8989
} else {
9090
score = 0;
91-
scoreEl.textContent = 0;
91+
scoreEl.value = 0;
9292
btn.classList.add('wrong');
9393
resultEl.innerHTML = `Wrong<br>This is <strong>${correct}</strong>`;
9494

source/styles.css

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,20 @@ body {
3333
}
3434

3535
.game__bar {
36-
text-align: center;
36+
display: flex;
37+
justify-content: center;
38+
align-items: center;
39+
gap: 12px;
3740
font-size: 1.1rem;
38-
margin-bottom: 35px;
3941
color: #333333;
42+
margin-bottom: 35px;
43+
}
44+
45+
@media (max-width: 480px) {
46+
.game__bar {
47+
font-size: 1.15rem;
48+
flex-direction: column;
49+
}
4050
}
4151

4252
.game-bar__rounds-select,
@@ -47,9 +57,9 @@ body {
4757
padding: 0 8px;
4858
line-height: 26px;
4959
border: 2px inset #dfdfdf;
60+
border-radius: 0;
5061
display: inline-block;
5162
vertical-align: middle;
52-
box-sizing: border-box;
5363
}
5464

5565
.game-bar__rounds-select {
@@ -96,6 +106,15 @@ body {
96106
border: 2px solid #000000;
97107
cursor: pointer;
98108
font-family: inherit;
109+
appearance: none;
110+
}
111+
112+
@media (max-width: 480px) {
113+
.game-answers__answer {
114+
font-size: 1rem;
115+
padding: 12px 10px;
116+
border-width: 1px;
117+
}
99118
}
100119

101120
.game-answers__answer:hover {
@@ -147,6 +166,14 @@ body {
147166
margin: 0;
148167
}
149168

169+
@media (max-width: 480px) {
170+
.game-footer__next-button {
171+
font-size: 1.05rem;
172+
padding: 10px 28px;
173+
border-width: 1px;
174+
}
175+
}
176+
150177
.game-footer__next-button:hover,
151178
.game-footer__next-button:active {
152179
background: #000000;

0 commit comments

Comments
 (0)