Skip to content

Commit 49c4ba3

Browse files
committed
Refactor ScoreLabel to StatusLabel
1 parent 29fa649 commit 49c4ba3

File tree

5 files changed

+20
-16
lines changed

5 files changed

+20
-16
lines changed

src/assets/locales/en/translation.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"hit": "Correct guess!",
2121
"miss": "{{distance}} km from the actual location"
2222
},
23-
"scorelabel": {
23+
"statuslabel": {
2424
"totalDistance": "{{distance}} km of accumulated error"
2525
},
2626
"gameovermodal": {

src/assets/locales/gl/translation.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"hit": "Localización correcta!",
2121
"miss": "A {{distance}} km da localización correcta"
2222
},
23-
"scorelabel": {
23+
"statuslabel": {
2424
"totalDistance": "{{distance}} km de erro acumulado"
2525
},
2626
"gameovermodal": {

src/components/GuessLocationQuiz.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import { LngLat, type MapLayerMouseEvent } from "maplibre-gl";
1111
import { useMemo, useRef, useState } from "react";
1212
import { useTranslation } from 'react-i18next';
1313
import Map, { Layer, Marker, Source, type MapRef, type StyleSpecification } from "react-map-gl/maplibre";
14-
import DistanceLabel from "../components/DistanceLabel";
15-
import GameOverModal from "../components/GameOverModal";
16-
import QuestionLabel from "../components/QuestionLabel";
17-
import ScoreLabel from "../components/ScoreLabel";
1814
import { Mode } from "../enums";
1915
import { shuffle } from "../utils/ArrayUtils";
2016
import { clampLat, clampLng, getDistanceToCurrentFeature } from "../utils/MapUtils";
17+
import DistanceLabel from "./DistanceLabel";
18+
import GameOverModal from "./GameOverModal";
2119
import { hoverLineLayerStyle, hoverPointLayerStyle, hoverPolygonLayerStyle, outlinePolygonLayerStyle } from "./mapstyle";
20+
import QuestionLabel from "./QuestionLabel";
21+
import StatusLabel from "./StatusLabel";
2222
import styles from "./styles.module.css";
2323

2424
import mapstylejson from "../assets/main-map-style.json";
@@ -134,16 +134,20 @@ export default function GuessLocationQuiz({ data, datasetName, onResetGame }: Pr
134134
</>
135135
)}
136136
</Map>
137-
<div className="absolute bottom-[90%] sm:bottom-[15%] left-50 sm:left-[10%]">
137+
<div className="absolute bottom-[85%] sm:bottom-[15%] left-50 sm:left-[10%]">
138138
<QuestionLabel
139139
textToDisplay={features[features.length - 1]?.properties?.name as string}
140140
disabled={userGuess != null}
141141
/>
142+
<StatusLabel
143+
current={data.features.length - features.length + 1}
144+
total={data.features.length}
145+
/>
142146
</div>
143147
{userGuess && (
144148
<div className="absolute bottom-[6%] sm:bottom-[10%] flex flex-col items-center gap-2 text-2xl pointer-events-none">
145149
<DistanceLabel distance={currentDistanceKm} />
146-
<ScoreLabel
150+
<StatusLabel
147151
distance={totalDistanceKm + currentDistanceKm}
148152
/>
149153
<button className={styles.quizbutton}

src/components/StandardQuiz.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import GameOverModal from "./GameOverModal";
1515
import MapView from "./MapView";
1616
import QuestionHistory, { type QuestionHistoryEntry } from "./QuestionHistory";
1717
import QuestionLabel from "./QuestionLabel";
18-
import ScoreLabel from "./ScoreLabel";
18+
import StatusLabel from "./StatusLabel";
1919
import TextInput from "./TextInput";
2020

2121
interface Props {
@@ -89,8 +89,8 @@ export default function StandardQuiz({ data, mode, datasetName, onResetGame }: P
8989
<QuestionLabel
9090
textToDisplay={data.features.find(feature => feature.id === featureIds[featureIds.length - 1])?.properties?.name as string}
9191
/>
92-
<ScoreLabel
93-
score={rightGuessFeatureIds.length}
92+
<StatusLabel
93+
current={data.features.length - featureIds.length + 1}
9494
total={data.features.length}
9595
/>
9696
</div>

src/components/ScoreLabel.tsx renamed to src/components/StatusLabel.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@
88
import { useTranslation } from 'react-i18next';
99

1010
interface Props {
11-
score?: number;
11+
current?: number;
1212
total?: number;
1313
distance?: number;
1414
};
1515

16-
export default function ScoreLabel({ score, total, distance }: Props) {
16+
export default function StatusLabel({ current, total, distance }: Props) {
1717
const { t } = useTranslation();
1818
return (
1919
<div>
2020
{distance != null && (
2121
<label
2222
className="flex items-center justify-center text-base sm:text-lg h-10 sm:h-12 px-4 sm:px-5 sm:min-w-44 font-[family-name:var(--font-geist-mono)]"
2323
>
24-
{t("scorelabel.totalDistance", { distance: distance.toFixed(2) })}
24+
{t("statuslabel.totalDistance", { distance: distance.toFixed(2) })}
2525
</label>
2626
)}
27-
{score != null && total && (
27+
{current != null && total && (
2828
<label
2929
className="flex items-center justify-center text-base sm:text-lg h-10 sm:h-12 px-4 sm:px-5 sm:min-w-44 font-[family-name:var(--font-geist-mono)]"
3030
>
31-
{String(score) + "/" + String(total)}
31+
{String(current) + "/" + String(total)}
3232
</label>
3333
)}
3434
</div>

0 commit comments

Comments
 (0)