diff --git a/package-lock.json b/package-lock.json index 290c65f6..737d6d39 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "@material-ui/icons": "^4.11.3", "asciidoctor-emoji": "^0.5.0", "i18n": "^0.15.1", + "react-countdown": "^2.3.5", "react-router-dom": "^6.22.1" } }, @@ -663,6 +664,18 @@ "node": ">=0.10.0" } }, + "node_modules/react-countdown": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/react-countdown/-/react-countdown-2.3.5.tgz", + "integrity": "sha512-K26ENYEesMfPxhRRtm1r+Pf70SErrvW3g4CArLi/x6MPFjgfDFYePT4UghEj8p2nI0cqVV7/JjDgjyr//U60Og==", + "dependencies": { + "prop-types": "^15.7.2" + }, + "peerDependencies": { + "react": ">= 15", + "react-dom": ">= 15" + } + }, "node_modules/react-dom": { "version": "17.0.2", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-17.0.2.tgz", diff --git a/package.json b/package.json index a508ec7e..37679c9a 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "@material-ui/icons": "^4.11.3", "asciidoctor-emoji": "^0.5.0", "i18n": "^0.15.1", + "react-countdown": "^2.3.5", "react-router-dom": "^6.22.1" } } diff --git a/webapp/src/components/GameMenu/GameMenu.css b/webapp/src/components/GameMenu/GameMenu.css new file mode 100644 index 00000000..f56fd2d4 --- /dev/null +++ b/webapp/src/components/GameMenu/GameMenu.css @@ -0,0 +1,33 @@ +.menuButton { + width: 40%; + height: 45px; + background: darkblue; + border: none; + outline: none; + border-radius: 40px; + box-shadow: 0 0 10px black; + cursor:pointer; + font-size: 16px; + color: white; + font-weight: 700; + margin: 0.5em; + text-align: center; +} + +.countdown { + font-weight: 500; + margin: 3em; +} + +.topPanel{ + display: flex; + flex-direction: row; + align-items: center; +} +.divMenu { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + height: 100vh; +} \ No newline at end of file diff --git a/webapp/src/components/GameMenu/GameMenu.js b/webapp/src/components/GameMenu/GameMenu.js index d9961bdc..ed5a392c 100644 --- a/webapp/src/components/GameMenu/GameMenu.js +++ b/webapp/src/components/GameMenu/GameMenu.js @@ -1,28 +1,32 @@ import "../../custom.css"; import { Link } from "react-router-dom"; +import {useTranslation} from "react-i18next"; + export default function GameMenu() { + const[t, i18n] = useTranslation("global"); + return (
-

Game Menu

- - +

{t("gameMenu.title")}

+ +
); } - function ButtonHistoricalData() { + function ButtonHistoricalData({ t }) { function handleClick() { //ir a la vista de historical data alert("Historical Data"); } - return ; + return ; } - function ButtonNewGame() { + function ButtonNewGame({t}) { return ( <> - - + +

{t("gameMenu.new_game_button")}

); diff --git a/webapp/src/components/questionView/QuestionView.js b/webapp/src/components/questionView/QuestionView.js index 2686ae44..69692e61 100644 --- a/webapp/src/components/questionView/QuestionView.js +++ b/webapp/src/components/questionView/QuestionView.js @@ -1,12 +1,15 @@ import QuestionGenerator from './QuestionGenerator'; import { useEffect, useState } from 'react'; import "../../custom.css"; - +import React from "react"; +import Countdown from "react-countdown"; +import {useTranslation} from "react-i18next"; function QuestionView(){ const questionGenerator = new QuestionGenerator(); const [numQuestion, setnumQuestion] = useState(-1); const [questions, setQuestions] = useState([]); + const[t, i18n] = useTranslation("global"); const generateQuestions = async (numQuestion) => { if (numQuestion < 0) { @@ -32,23 +35,36 @@ function QuestionView(){
{/*Nav*/} {numQuestion >= 0 ? - : + :

Please Wait a bit...

} - -
); } -function QuestionComponent({questions, numQuestion, handleClick}){ +function QuestionComponent({questions, numQuestion, handleClick, t}){ + const renderer = ({seconds, completed }) => { + if (completed) { + + return {t("questionView.end_countdown")}; // Rendered when countdown completes + } else { + return {seconds} {t("questionView.seconds")}; // Render countdown + } + }; + return ( <> +

{questions[numQuestion].getQuestion()}

-
- {questions[numQuestion].getAnswers().map((item, index) => ( - - ))} -

Question counter: {numQuestion}

+
+
+
+
+ {questions[numQuestion].getAnswers().map((item, index) => ( + + ))} + +
+

{t("questionView.question_counter")} {numQuestion}

); } diff --git a/webapp/src/locales/en/messages_en.properties b/webapp/src/locales/en/messages_en.properties new file mode 100644 index 00000000..970112c4 --- /dev/null +++ b/webapp/src/locales/en/messages_en.properties @@ -0,0 +1,18 @@ +# messages_en.properties +navbar.title = Know and Win! +button.language = Español +instructionsTitle=WIQ Instructions +objective=Objective: +objectiveDescription=The objective of the game is to answer as many questions correctly as possible. +howToPlay=How to Play: +howToPlayDescription1=The game consists of a series of questions. +howToPlayDescription2=Read each question carefully. +howToPlayDescription3=Choose the correct answer from the options provided. +howToPlayDescription4=Click or tap on your selected answer to submit it. +scoring=Scoring: +scoringDescription1=Each correct answer earns you x points. +scoringDescription2=Incorrect answers do not deduct points. +timeLimit=Time Limit: +timeLimitDescription=Some game modes may have a time limit for answering each question. Be quick and accurate to maximize your score. +haveFun=Have Fun!: +haveFunDescription=Enjoy the game and test your knowledge. Good luck! diff --git a/webapp/src/translations/en/global.json b/webapp/src/translations/en/global.json index 30b70e9b..b7f7248d 100644 --- a/webapp/src/translations/en/global.json +++ b/webapp/src/translations/en/global.json @@ -41,6 +41,16 @@ "repeat_password_placeholder": "Repeat password", "register_button": "Register", "login_link": "Do you have an account? Login here." + }, + "gameMenu":{ + "history_button":"View Historical Data", + "new_game_button":"Create New Game", + "title":"Game Menu" + }, + "questionView":{ + "seconds":"seconds", + "question_counter":"Question counter :", + "end_countdown":"Time's up!" } } diff --git a/webapp/src/translations/es/global.json b/webapp/src/translations/es/global.json index d43e113f..3277d13a 100644 --- a/webapp/src/translations/es/global.json +++ b/webapp/src/translations/es/global.json @@ -45,6 +45,15 @@ "repeat_password_placeholder": "Repetir contraseña", "register_button": "Registrarse", "login_link": "¿Ya tienes una cuenta? Inicia sesión aquí." + }, + "gameMenu":{ + "history_button":"Ver Historial", + "new_game_button":"Crear nuevo juego", + "title":"Menú del Juego" + },"questionView":{ + "seconds":"segundos", + "question_counter":"Número de pregunta : ", + "end_countdown":"¡Se acabó el tiempo!" }