handling object class depending on answeerr type

This commit is contained in:
Antoine M 2024-03-19 16:33:43 +01:00
parent eed0314be7
commit e5eca230fe

View File

@ -11,10 +11,18 @@ export default function GameObjects({ blocks }) {
<> <>
{blocks.map((block, id) => { {blocks.map((block, id) => {
const hasAnswered = answers && answers[id]?.userAnswer; const hasAnswered = answers && answers[id]?.userAnswer;
return ( return (
<img <img
className={`lhoist-blocks-focus-object ${ className={`lhoist-blocks-focus-object ${
hasAnswered ? "lhoist-blocks-focus-object--inactive" : "" hasAnswered ? "lhoist-blocks-focus-object--inactive" : ""
} ${
hasAnswered && answers[id]?.userAnsweredCorrectly === true
? "lhoist-blocks-focus-object--answered-correctly"
: hasAnswered &&
answers[id]?.userAnsweredCorrectly === false
? "lhoist-blocks-focus-object--answered-incorrectly"
: "lhoist-blocks-focus-object--unanswered"
}`} }`}
style={{ style={{
height: `${block.attrs.objectScale}%`, height: `${block.attrs.objectScale}%`,