Skip to content

Commit

Permalink
Update onboarding modal and add new welcome messages in multiple lang…
Browse files Browse the repository at this point in the history
…uages
  • Loading branch information
codergautam committed Jan 6, 2025
1 parent 12d0c79 commit 804a669
Show file tree
Hide file tree
Showing 10 changed files with 249 additions and 97 deletions.
64 changes: 32 additions & 32 deletions components/gameUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,38 +245,38 @@ export default function GameUI({ inCoolMathGames, miniMapShown, setMiniMapShown,

useEffect(() => {
if(onboarding) {
setOnboardingTextShown(true);
if( onboarding.round === 1) {
setOnboardingWords([
text("welcomeToWorldguessr")+"!",
text("onboarding2"),
text("onboarding3"),
text("onboarding4"),
])
} else if(onboarding.round === 2) {
if(window.location.search.includes("crazygames")) {
setOnboardingWords([
text("greatJob"),
])
} else {
setOnboardingWords([
text("greatJob"),
text("onboarding5"),
])
}
} else if(onboarding.round === 3) {
setOnboardingWords([
text("astounding"),
])
} else if(onboarding.round === 4) {
setOnboardingWords([
text("onboarding10")
])
} else if(onboarding.round === 5) {
setOnboardingWords([
text("finalRound"),
])
}
// setOnboardingTextShown(true);
// if( onboarding.round === 1) {
// setOnboardingWords([
// text("welcomeToWorldguessr")+"!",
// text("onboarding2"),
// text("onboarding3"),
// text("onboarding4"),
// ])
// } else if(onboarding.round === 2) {
// if(window.location.search.includes("crazygames")) {
// setOnboardingWords([
// text("greatJob"),
// ])
// } else {
// setOnboardingWords([
// text("greatJob"),
// text("onboarding5"),
// ])
// }
// } else if(onboarding.round === 3) {
// setOnboardingWords([
// text("astounding"),
// ])
// } else if(onboarding.round === 4) {
// setOnboardingWords([
// text("onboarding10")
// ])
// } else if(onboarding.round === 5) {
// setOnboardingWords([
// text("finalRound"),
// ])
// }
}
}, [onboarding?.round])

Expand Down
9 changes: 7 additions & 2 deletions components/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export default function Home({ }) {
const [loginQueued, setLoginQueued] = useState(false);
const [options, setOptions] = useState({
});
const [onboardingModalShown, setOnboardingModalShown] = useState(false);
const [multiplayerError, setMultiplayerError] = useState(null);
const [miniMapShown, setMiniMapShown] = useState(false)

Expand Down Expand Up @@ -504,6 +505,7 @@ while (locations.length < 5) {
locations.push(loc)
}
}
setOnboardingModalShown(true);

setOnboarding({
round: 1,
Expand Down Expand Up @@ -551,6 +553,10 @@ setShowCountryButtons(false)
}
}, [onboarding?.round])

useEffect(() => {
console.log("onboarding", onboardingModalShown)
}, [onboardingModalShown])

useEffect(() => {
if(onboarding?.completed) {
setOnboardingCompleted(true)
Expand Down Expand Up @@ -2141,7 +2147,7 @@ setShowCountryButtons(false)

</div>

<InfoModal shown={false} />
<InfoModal shown={onboardingModalShown} onClose={() => setOnboardingModalShown(false)}/>
<MapsModal shown={mapModal || gameOptionsModalShown} session={session} onClose={() => {setMapModal(false);setGameOptionsModalShown(false)}} text={text}
customChooseMapCallback={(gameOptionsModalShown&&screen==="singleplayer")?(map)=> {
console.log("map", map)
Expand Down Expand Up @@ -2169,7 +2175,6 @@ setShowCountryButtons(false)
{screen === "onboarding" && onboarding?.round && <div className="home__onboarding">
<GameUI
inCoolMathGames={inCoolMathGames}

miniMapShown={miniMapShown} setMiniMapShown={setMiniMapShown}
inCrazyGames={inCrazyGames} showPanoOnResult={showPanoOnResult} setShowPanoOnResult={setShowPanoOnResult} countryGuesserCorrect={countryGuesserCorrect} setCountryGuesserCorrect={setCountryGuesserCorrect} showCountryButtons={showCountryButtons} setShowCountryButtons={setShowCountryButtons} otherOptions={otherOptions} onboarding={onboarding} countryGuesser={false} setOnboarding={setOnboarding} options={options} countryStreak={countryStreak} setCountryStreak={setCountryStreak} xpEarned={xpEarned} setXpEarned={setXpEarned} hintShown={hintShown} setHintShown={setHintShown} pinPoint={pinPoint} setPinPoint={setPinPoint} showAnswer={showAnswer} setShowAnswer={setShowAnswer} loading={loading} setLoading={setLoading} session={session} gameOptionsModalShown={gameOptionsModalShown} setGameOptionsModalShown={setGameOptionsModalShown} latLong={latLong} streetViewShown={streetViewShown} setStreetViewShown={setStreetViewShown} loadLocation={loadLocation} gameOptions={gameOptions} setGameOptions={setGameOptions} />
</div>}
Expand Down
228 changes: 180 additions & 48 deletions components/infoModal.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,185 @@
import {Modal} from "react-responsive-modal";
import { useTranslation } from '@/components/useTranslations'
import { useState } from "react";
import { Modal } from "react-responsive-modal";
import { useTranslation } from '@/components/useTranslations';

export default function InfoModal({ shown, onClose }) {
const { t: text } = useTranslation("common");

// State to handle screen navigation
const [currentScreen, setCurrentScreen] = useState(1);

const handleNextClick = () => {
setCurrentScreen(2);
};

const handleLetsGoClick = () => {
onClose();
};

return (
<div className="infoModal" style={{
display: 'none'
}}>

<h1 style={{
marginBottom: '20px',
fontSize: '24px',
fontWeight: 'bold'
}}>{text("howToPlay")}</h1>

<p style={{
fontSize: '16px',
marginBottom: '10px'
}}>
🧐 {text("info1")}
</p>
<p style={{
fontSize: '16px',
marginBottom: '10px'
}}>
🗺️ {text("info2")}
</p>
<p style={{
fontSize: '16px',
marginBottom: '20px'
}}>
🎓 {text("info3")}
</p>

<button className="toggleMap" style={{
fontSize: '16px',
fontWeight: 'bold',
color: 'white',
background: 'green',
border: 'none',
borderRadius: '5px',
padding: '10px 20px',
cursor: 'pointer'
}} onClick={() => {
onClose();
}}>
{text("close")}
</button>
</div>
)
}
<Modal
open={shown}
onClose={onClose}
center
styles={{
modal: {
backgroundColor: '#2d2d2d',
padding: '20px',
borderRadius: '10px',
color: 'white',
maxWidth: '600px',
},
closeButton: {
scale: 0.5,
backgroundColor: 'red',
borderRadius: '50%',
padding: '5px 10px',
},
}}
>
<center>
{currentScreen === 1 ? (
<>
<h1
style={{
fontSize: '24px',
fontWeight: 'bold',
color: 'lime',
marginBottom: '10px'
}}
>
{text("welcomeToWorldGuessr")}!
</h1>

<p
style={{
fontSize: '16px',
marginBottom: '5px',
}}
>
🧐 {text("info1")}
</p>

<p
style={{
fontSize: '16px',
marginBottom: '5px',
}}
>
🗺️ {text("info2")}
</p>

<img
src="/tutorial1.png"
alt="Tutorial 1"
style={{
maxWidth: '100%',
borderRadius: '10px',
}}
/>

<div
style={{
marginTop: '20px', // Adds spacing between the content and button
}}
>
<button
className="nextButton"
style={{
fontSize: '16px',
fontWeight: 'bold',
color: 'white',
background: '#4CAF50',
border: 'none',
borderRadius: '5px',
padding: '10px 20px',
cursor: 'pointer',
transition: 'all 0.3s ease',
display: 'block', // Forces the button to be on a new line
width: '100%', // Ensures the button takes the full width
}}
onClick={handleNextClick}
>
{text("next")}
</button>
</div>
</>
) : (
<>
<h1
style={{
fontSize: '24px',
fontWeight: 'bold',
color: 'lime',
marginBottom: '10px'

}}
>
{text("welcomeToWorldGuessr")}!
</h1>

<p
style={{
fontSize: '16px',
marginBottom: '5px',
}}
>
🎓 {text("info3")}
</p>

<p
style={{
fontSize: '16px',
marginBottom: '5px',
}}
>
🌍 {text("info4")}
</p>

<img
src="/tutorial2.png"
alt="Tutorial 2"
style={{
maxWidth: '100%',
borderRadius: '10px',
}}
/>

<div
style={{
marginTop: '20px', // Adds spacing between the content and button
}}
>
<button
className="letsGoButton"
style={{
fontSize: '16px',
fontWeight: 'bold',
color: 'white',
background: '#4CAF50',
border: 'none',
borderRadius: '5px',
padding: '10px 20px',
cursor: 'pointer',
transition: 'all 0.3s ease',
display: 'block', // Forces the button to be on a new line
width: '100%', // Ensures the button takes the full width
}}
onClick={handleLetsGoClick}
>
{text("letsGo")}
</button>
</div>
</>
)}
</center>

<style jsx>{`
.nextButton:hover, .letsGoButton:hover {
background-color: #45a049;
transform: scale(1.05);
}
`}</style>
</Modal>
);
}
9 changes: 6 additions & 3 deletions public/locales/de/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@
"enterUsername": "Bitte geben Sie einen Benutzernamen ein, um fortzufahren",
"enterUsernameBox": "Benutzernamen eingeben",
"save": "Speichern",
"info1": "Erkunden Sie Ihre Umgebung und versuchen Sie zu erraten, wo in der Welt Sie sich befinden",
"info2": "Verwenden Sie die Karte, um Ihre Vermutung zu platzieren, und überprüfen Sie Ihre Genauigkeit",
"info3": "Lernen Sie Geographie durch Spielen und haben Sie Spaß!",
"info1": "Dies ist ein Spiel, bei dem du die Welt durch Street View erkundest!",
"info2": "Erkunde den Ort und suche nach Hinweisen",
"info3": "Nutze die Karte, um zu erraten, wo du denkst, dass du bist, und sieh, wie nah du warst",
"info4": "Lerne Geografie durch Spielen und habe Spaß!",
"welcomeToWorldGuessr": "Willkommen bei WorldGuessr",
"next": "Weiter",
"letsGo": "Los geht's",
"close": "Schließen",
"howToPlay": "Spielanleitung",
Expand Down
9 changes: 6 additions & 3 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@
"enterUsername": "Please enter a username to continue",
"enterUsernameBox": "Enter a username",
"save": "Save",
"info1": "Free geography game where you explore your surroundings, and try to guess where in the World you are",
"info2": "Use the map to place your guess and check your accuracy.",
"info3": "Learn geography through play, and have fun!",
"info1": "This is a game about exploring the world through street view!",
"info2": "Explore the location and look for clues",
"info3": "Use the map to guess where you think you are, and see how close you were",
"info4": "Learn geography through play, and have fun!",
"welcomeToWorldGuessr": "Welcome to WorldGuessr",
"next": "Next",
"letsGo": "Let's Go",
"close": "Close",
"howToPlay": "How to Play",
Expand Down
9 changes: 6 additions & 3 deletions public/locales/es/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@
"enterUsername": "Por favor ingresa un nombre de usuario para continuar",
"enterUsernameBox": "Ingresa un nombre de usuario",
"save": "Guardar",
"info1": "Explora tus alrededores e intenta adivinar dónde en el mundo estás",
"info2": "Usa el mapa para colocar tu suposición y verifica tu precisión",
"info3": "¡Aprende geografía jugando y diviértete!",
"info1": "¡Este es un juego sobre explorar el mundo a través de Street View!",
"info2": "Explora el lugar y busca pistas",
"info3": "Usa el mapa para adivinar dónde crees que estás, y ver qué tan cerca estuviste",
"info4": "¡Aprende geografía jugando y diviértete!",
"welcomeToWorldGuessr": "Bienvenido a WorldGuessr",
"next": "Siguiente",
"letsGo": "¡Vamos!",
"close": "Cerrar",
"howToPlay": "Cómo jugar",
Expand Down
Loading

0 comments on commit 804a669

Please sign in to comment.