Skip to content

Commit d1a88a9

Browse files
committed
improves mobile version, refactors
1 parent 4ea9076 commit d1a88a9

5 files changed

Lines changed: 29 additions & 43 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const signs = [
1+
const questions = [
22
{ img: "images/russian1.png", lang: "Russian", options: ["Russian", "Ukrainian", "Belarusian", "Bulgarian"] },
33
{ img: "images/russian2.png", lang: "Russian", options: ["Russian", "Ukrainian", "Belarusian", "Bulgarian"] },
44
{ img: "images/russian3.png", lang: "Russian", options: ["Russian", "Ukrainian", "Belarusian", "Bulgarian"] },

source/index.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1">
66
<meta name="robots" content="index, follow">
7+
<meta property="og:title" content="whatlang — guess the language from a picture">
8+
<meta property="og:description" content="Guess the language from street signs, store names and random inscriptions">
9+
<meta property="og:image" content="https://whatlang.fun/opengraph-image.png">
10+
<meta property="og:url" content="https://whatlang.fun/">
711
<meta name="description" content="Guess the language from street signs, store names and random inscriptions">
812
<title>whatlang — guess the language from a picture</title>
13+
<link rel="canonical" href="https://whatlang.fun/">
914
<link rel="icon" href="favicon.svg" type="image/svg+xml">
1015
<link rel="stylesheet" href="styles.css">
1116
</head>
@@ -69,11 +74,11 @@ <h1 class="game__title">whatlang?</h1>
6974
<footer class="footer">
7075
<a class="footer__author" href="https://github.com/Inventoris" target="_blank">Alexey Nikitchenko</a>
7176
<p class="footer__inspired">
72-
Inspired by <a href="https://openguessr.com/" target="_blank">OpenGuessr</a> and Web 1.0
77+
Inspired by <a href="https://openguessr.com/" target="_blank">OpenGuessr</a> and&nbsp;Web&nbsp;1.0
7378
</p>
7479
</footer>
7580

76-
<script src="data/signs.js" defer></script>
81+
<script src="data/questions.js" defer></script>
7782
<script src="script.js" defer></script>
7883
</body>
7984
</html>

source/opengraph-image.png

21.8 KB
Loading

source/script.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const roundsCounter = document.getElementById('rounds-counter');
1414

1515
recordEl.value = record;
1616

17-
let pool = [...signs].sort(() => Math.random() - 0.5);
17+
let pool = [...questions].sort(() => Math.random() - 0.5);
1818
let index = 0;
1919

2020

@@ -32,7 +32,7 @@ function restartGame() {
3232
roundsCounter.textContent = roundsLimit === 0 ? '∞' : `1 / ${roundsLimit}`;
3333

3434
index = 0;
35-
pool = [...signs].sort(() => Math.random() - 0.5);
35+
pool = [...questions].sort(() => Math.random() - 0.5);
3636

3737
showQuestion();
3838
}
@@ -47,6 +47,7 @@ function showQuestion() {
4747

4848
while (true) {
4949
q = pool[index++];
50+
5051
if (index >= pool.length) index = 0;
5152

5253
if (!used.has(q.lang)) break;
@@ -113,6 +114,7 @@ nextBtn.onclick = () => {
113114

114115
if (roundsLeft <= 0) {
115116
restartGame();
117+
116118
return;
117119
}
118120
}

source/styles.css

Lines changed: 17 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ body {
5959
border: 2px inset #dfdfdf;
6060
border-radius: 0;
6161
display: inline-block;
62-
vertical-align: middle;
6362
}
6463

6564
.game-bar__rounds-select {
@@ -75,21 +74,13 @@ body {
7574
}
7675

7776
.game__image {
78-
width: 100%;
79-
height: 380px;
77+
aspect-ratio: 16 / 9;
78+
height: auto;
8079
object-fit: cover;
8180
object-position: center;
8281
margin-bottom: 35px;
8382
}
8483

85-
@media (max-width: 640px) {
86-
.game__image { height: 300px; }
87-
}
88-
89-
@media (max-width: 480px) {
90-
.game__image { height: 260px; }
91-
}
92-
9384
.game__answers {
9485
list-style: none;
9586
display: grid;
@@ -141,19 +132,28 @@ body {
141132
border-top: 3px double #000080;
142133
background: #f0f0f0;
143134
min-height: 64px;
144-
flex-wrap: wrap;
145135
gap: 12px;
146136
visibility: hidden;
147137
}
148138

139+
@media (max-width: 480px) {
140+
.game__footer {
141+
padding: 10px 16px;
142+
border-width: 1px;
143+
}
144+
}
145+
149146
.game-footer__result {
150147
margin: 0;
151148
font-size: 1.3rem;
152149
font-weight: bold;
153150
color: #000080;
154-
text-align: left;
155-
flex: 1;
156-
min-width: 200px;
151+
}
152+
153+
@media (max-width: 480px) {
154+
.game-footer__result {
155+
font-size: 1.05rem;
156+
}
157157
}
158158

159159
.game-footer__next-button {
@@ -169,7 +169,7 @@ body {
169169

170170
@media (max-width: 480px) {
171171
.game-footer__next-button {
172-
font-size: 1.05rem;
172+
font-size: 1rem;
173173
padding: 10px 28px;
174174
border-width: 1px;
175175
}
@@ -182,23 +182,6 @@ body {
182182
transform: translate(1px, 1px);
183183
}
184184

185-
@media (max-width: 640px) {
186-
.game__footer {
187-
flex-direction: column;
188-
text-align: center;
189-
padding: 20px 12px;
190-
}
191-
192-
.game-footer__result {
193-
text-align: center;
194-
}
195-
196-
.game-footer__next-button {
197-
width: 100%;
198-
max-width: 300px;
199-
}
200-
}
201-
202185
.footer {
203186
margin-top: 50px;
204187
padding-top: 30px;
@@ -218,15 +201,11 @@ body {
218201
text-decoration: underline;
219202
}
220203

221-
.footer a:hover {
222-
text-decoration: none;
223-
}
224-
225204
.footer::after {
226205
content: "★";
227206
color: #ffff00;
228207
font-weight: 900;
229-
text-shadow: 0 0 4px #000, 2px 2px 0 #000;
208+
text-shadow: 0 0 4px #000000, 2px 2px 0 #000000;
230209
animation: blink 1.3s steps(2, start) infinite;
231210
}
232211

0 commit comments

Comments
 (0)