Skip to content

Commit

Permalink
Merge pull request #11 from MunschThomas/pauffine
Browse files Browse the repository at this point in the history
Pauffine
  • Loading branch information
MunschThomas authored Mar 18, 2022
2 parents 0c268cb + fe9c2d6 commit d37b21e
Show file tree
Hide file tree
Showing 12 changed files with 375 additions and 289 deletions.
Binary file added src/assets/buttonEnergie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/buttonHomme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/fonts/Enedis-Bold.ttf
Binary file not shown.
Binary file added src/assets/fonts/Enedis-Bold.woff
Binary file not shown.
10 changes: 7 additions & 3 deletions src/components/ModalQ.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ button {
.wrapQuest {
width: 50%;
min-width: 350px;
max-width: 560px;
background-color: blue;
height: 400px;
display: flex;
Expand All @@ -52,6 +53,9 @@ button {
color: white;
}


.visible {visibility: visible;}
.hidden {visibility: hidden;}
.visible {
visibility: visible;
}
.hidden {
visibility: hidden;
}
128 changes: 71 additions & 57 deletions src/components/ModalQ.js
Original file line number Diff line number Diff line change
@@ -1,103 +1,117 @@
import { useEffect, useState, useRef } from "react";
import "./ModalQ.css";
import { useEffect, useState, useRef } from 'react'
import './ModalQ.css'

const ModalQ = ({ pause, dataQuestion, setDataQuestion, launchNewGame , rightAnswer, setRightAnswer}) => {
const ModalQ = ({
pause,
dataQuestion,
setDataQuestion,
launchNewGame,
rightAnswer,
setRightAnswer,
}) => {
const focus1 = useRef(null)
const [isAsked, setIsAsked] = useState([]);
const [clk, setClk] = useState(false);

const [isAsked, setIsAsked] = useState([])
const [clk, setClk] = useState(false)

// const onFoc = () => {
// focus.current.focus()

// }

const [answerCorrect, setAnswerCorrect] = useState(null);
const [selectedAnswer, setSelectedAnswer] = useState(null);

const [answerCorrect, setAnswerCorrect] = useState(null)
const [selectedAnswer, setSelectedAnswer] = useState(null)

const checkKey = (choice) => {
focus1.current.focus()
setSelectedAnswer(choice);
setSelectedAnswer(choice)
if (choice === isAsked.reponse) {
const showTrue = document.getElementById("correctAnswerReavel");
showTrue.style.visibility = "visible";
const showTrue = document.getElementById('correctAnswerReavel')
showTrue.style.visibility = 'visible'
setRightAnswer((rightAnswer) => rightAnswer + 1)
} else {
const showTrue = document.getElementById("wrongAnswerReavel");
showTrue.style.visibility = "visible";
const showTrue = document.getElementById('wrongAnswerReavel')
showTrue.style.visibility = 'visible'
}
};
}
const launch = (e) => {
console.log("keyboardEvent", e);
console.log('keyboardEvent', e)
// let wrapper = document.getElementById("wrapper");

if (e.key === " ") {
launchNewGame();
if (e.key === ' ') {
launchNewGame()
}
if (e.key === "ArrowLeft") {
checkKey("Vrai");
console.log('efefef');
if (e.key === 'ArrowLeft') {
checkKey('Vrai')
console.log('efefef')
}
if (e.key === "ArrowRight") {
checkKey("Faux");
if (e.key === 'ArrowRight') {
checkKey('Faux')
}
};
}

useEffect(() => {console.log(rightAnswer); },[rightAnswer])
useEffect(() => {
console.log(rightAnswer)
}, [rightAnswer])

const handleListItemClick = (event) => {
console.log("CONTENT", event.target.textContent);
setSelectedAnswer(event.target.textContent);
console.log('CONTENT', event.target.textContent)
setSelectedAnswer(event.target.textContent)
if (event.target.textContent === isAsked.reponse) {
const showTrue = document.getElementById("correctAnswerReavel");
showTrue.style.visibility = "visible";
setRightAnswer(rightAnswer => rightAnswer + 1)
const showTrue = document.getElementById('correctAnswerReavel')
showTrue.style.visibility = 'visible'
setRightAnswer((rightAnswer) => rightAnswer + 1)
} else {
const showTrue = document.getElementById("wrongAnswerReavel");
showTrue.style.visibility = "visible";
const showTrue = document.getElementById('wrongAnswerReavel')
showTrue.style.visibility = 'visible'
}
};
}
useEffect(() => {
const quest = Math.floor(Math.random() * dataQuestion.length);

console.log("dataQuestion", dataQuestion, "quest", quest);
const quest = Math.floor(Math.random() * dataQuestion.length)

const chosenQuest = dataQuestion.filter(
(dataQuestion, i) => i !== quest
);
const newTab = dataQuestion.filter((el) => el.id !== chosenQuest[0].id);
console.log("newTab", newTab);
setDataQuestion(newTab);
setIsAsked(...chosenQuest);
console.log('dataQuestion', dataQuestion, 'quest', quest)
const chosenQuest = dataQuestion.filter((dataQuestion, i) => i === quest)


}, [clk]);
const newTab = dataQuestion.filter((el) => el.id !== chosenQuest[0].id)
console.log('newTab', newTab)
setDataQuestion(newTab)
setIsAsked(...chosenQuest)
}, [clk])

useEffect(() => {
console.log("in use effext", dataQuestion);
}, [dataQuestion]);
console.log('in use effext', dataQuestion)
}, [dataQuestion])

return (
<div ref={focus1} className="wrapper" id="wrapper" tabIndex="0" onKeyDown={(e) => launch(e)}>
<div className="wrapQuest">
<div
ref={focus1}
className='wrapper'
id='wrapper'
tabIndex='0'
onKeyDown={(e) => launch(e)}
>
<div className='wrapQuest'>
<h1>{isAsked.question}</h1>
<div className="AnswerButton">
<div className='AnswerButton'>
<button onClick={(e) => handleListItemClick(e)}>Vrai</button>
<button onClick={(e) => handleListItemClick(e)}>Faux</button>
</div>
<div className="ReavelCorrect">
<div id="correctAnswerReavel" className="AnswerReavel">
<div className='ReavelCorrect'>
<div id='correctAnswerReavel' className='AnswerReavel'>
<h2>Bravo</h2>
</div>
<div id="wrongAnswerReavel" className="AnswerReavel">
<div id='wrongAnswerReavel' className='AnswerReavel'>
<h2>Oh oh, {isAsked.correction}</h2>
</div>
<button className={selectedAnswer ? `visible` : `hidden`} onClick={() => launchNewGame()}>Continuer</button>
<button
className={selectedAnswer ? `visible` : `hidden`}
onClick={() => launchNewGame()}
>
Continuer
</button>
</div>
</div>
</div>
);
};
)
}

export default ModalQ;
export default ModalQ
32 changes: 21 additions & 11 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
@import url("https://fonts.googleapis.com/css2?family=Public+Sans:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");

@import url('https://fonts.googleapis.com/css2?family=Public+Sans:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
/* --------------------- */
/* Root */
/* --------------------- */

:root {
/******* colors *******/

Expand Down Expand Up @@ -48,7 +46,7 @@
--fs-body: 1.6rem;

/******* font-families *******/
--ff-body: "Public Sans, sans-serif";
/* --ff-body: 'Enedis, sans-serif'; */
}

/* --------------------- */
Expand All @@ -67,7 +65,21 @@
/******* Body *******/
body {
min-height: 100vh;
font-family: var(--ff-body);
font-family: 'Public';
}

h1,
h2,
h3,
h4,
h5 {
font-family: 'Enedis-Bold';
}

@font-face {
font-family: 'Enedis';
src: local('Enedis'), url('./assets/fonts/Enedis-Bold.ttf') format('truetype');
font-weight: bold;
}

/******* Images *******/
Expand All @@ -88,8 +100,8 @@ select {
}

/* Remove list styles on ul, ol elements with a list role, which suggests default styling will be removed */
ul[role="list"],
ol[role="list"] {
ul[role='list'],
ol[role='list'] {
list-style: none;
}

Expand All @@ -115,14 +127,12 @@ body {
padding: 0;
width: 100vw;
overflow: hidden;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
font-family: Enedis-bold;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
26 changes: 14 additions & 12 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
import React from "react";
import ReactDOM from "react-dom";
import { BrowserRouter } from "react-router-dom";
import "./index.css";
import App from "./App";
import reportWebVitals from "./reportWebVitals";
import { Auth0Provider } from "@auth0/auth0-react";
import React from 'react'
import ReactDOM from 'react-dom'
import '../src/assets/fonts/Enedis-Bold.woff'

import { BrowserRouter } from 'react-router-dom'
import './index.css'
import App from './App'
import reportWebVitals from './reportWebVitals'
import { Auth0Provider } from '@auth0/auth0-react'

ReactDOM.render(
<React.StrictMode>
<BrowserRouter>
<Auth0Provider
domain="dev-qtkc-hsd.eu.auth0.com"
clientId="hSKzbkTq6SqfvPJe56f8thzRagYLwU5J"
domain='dev-qtkc-hsd.eu.auth0.com'
clientId='hSKzbkTq6SqfvPJe56f8thzRagYLwU5J'
redirectUri={window.location.origin}
>
<App />
</Auth0Provider>
</BrowserRouter>
</React.StrictMode>,

document.getElementById("root")
);
document.getElementById('root')
)

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
reportWebVitals()
Loading

0 comments on commit d37b21e

Please sign in to comment.