Spaces:
Sleeping
Sleeping
add same different
Browse files- src/App.tsx +25 -3
src/App.tsx
CHANGED
@@ -17,6 +17,8 @@ function App() {
|
|
17 |
const [gameStep, setGameStep] = useState<GameStep>('step1');
|
18 |
const [feedback, setFeedback] = useState('');
|
19 |
const [showFeedback, setShowFeedback] = useState(false);
|
|
|
|
|
20 |
|
21 |
// Emoji pools for different categories
|
22 |
const emojiCategories = {
|
@@ -27,6 +29,22 @@ function App() {
|
|
27 |
stars: ['⭐', '🌟', '💫', '✨', '🌠', '⚡', '🔥', '❄️', '☀️', '🌙']
|
28 |
};
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
// Generate a random question
|
31 |
const generateQuestion = (): ComparisonQuestion => {
|
32 |
const categories = Object.keys(emojiCategories) as (keyof typeof emojiCategories)[];
|
@@ -53,6 +71,10 @@ function App() {
|
|
53 |
// Determine second step question type
|
54 |
const secondStepQuestion: 'more' | 'fewer' = Math.random() < 0.5 ? 'more' : 'fewer';
|
55 |
|
|
|
|
|
|
|
|
|
56 |
return {
|
57 |
leftSide,
|
58 |
rightSide,
|
@@ -188,7 +210,7 @@ function App() {
|
|
188 |
{gameStep === 'step1' || gameStep === 'correct-step1' ? (
|
189 |
// Step 1: Are they equal?
|
190 |
<>
|
191 |
-
<h1 className="question-title">
|
192 |
|
193 |
<div className="comparison-container">
|
194 |
<div className="side-container">
|
@@ -210,13 +232,13 @@ function App() {
|
|
210 |
className="answer-btn equal-btn"
|
211 |
onClick={() => handleStep1Answer('equal')}
|
212 |
>
|
213 |
-
|
214 |
</button>
|
215 |
<button
|
216 |
className="answer-btn not-equal-btn"
|
217 |
onClick={() => handleStep1Answer('not-equal')}
|
218 |
>
|
219 |
-
|
220 |
</button>
|
221 |
</div>
|
222 |
)}
|
|
|
17 |
const [gameStep, setGameStep] = useState<GameStep>('step1');
|
18 |
const [feedback, setFeedback] = useState('');
|
19 |
const [showFeedback, setShowFeedback] = useState(false);
|
20 |
+
const [buttonLabels, setButtonLabels] = useState({ equal: 'Equal', notEqual: 'Not Equal' });
|
21 |
+
const [questionTitle, setQuestionTitle] = useState('Are they equal?');
|
22 |
|
23 |
// Emoji pools for different categories
|
24 |
const emojiCategories = {
|
|
|
29 |
stars: ['⭐', '🌟', '💫', '✨', '🌠', '⚡', '🔥', '❄️', '☀️', '🌙']
|
30 |
};
|
31 |
|
32 |
+
// Generate random button labels and question title
|
33 |
+
const generateButtonLabels = () => {
|
34 |
+
const equalOptions = ['Equal', 'Same'];
|
35 |
+
const notEqualOptions = ['Not Equal', 'Different'];
|
36 |
+
|
37 |
+
return {
|
38 |
+
equal: equalOptions[Math.floor(Math.random() * equalOptions.length)],
|
39 |
+
notEqual: notEqualOptions[Math.floor(Math.random() * notEqualOptions.length)]
|
40 |
+
};
|
41 |
+
};
|
42 |
+
|
43 |
+
const generateQuestionTitle = () => {
|
44 |
+
const titleOptions = ['Are they equal?', 'Are they same?'];
|
45 |
+
return titleOptions[Math.floor(Math.random() * titleOptions.length)];
|
46 |
+
};
|
47 |
+
|
48 |
// Generate a random question
|
49 |
const generateQuestion = (): ComparisonQuestion => {
|
50 |
const categories = Object.keys(emojiCategories) as (keyof typeof emojiCategories)[];
|
|
|
71 |
// Determine second step question type
|
72 |
const secondStepQuestion: 'more' | 'fewer' = Math.random() < 0.5 ? 'more' : 'fewer';
|
73 |
|
74 |
+
// Generate new button labels and question title for this question
|
75 |
+
setButtonLabels(generateButtonLabels());
|
76 |
+
setQuestionTitle(generateQuestionTitle());
|
77 |
+
|
78 |
return {
|
79 |
leftSide,
|
80 |
rightSide,
|
|
|
210 |
{gameStep === 'step1' || gameStep === 'correct-step1' ? (
|
211 |
// Step 1: Are they equal?
|
212 |
<>
|
213 |
+
<h1 className="question-title">{questionTitle}</h1>
|
214 |
|
215 |
<div className="comparison-container">
|
216 |
<div className="side-container">
|
|
|
232 |
className="answer-btn equal-btn"
|
233 |
onClick={() => handleStep1Answer('equal')}
|
234 |
>
|
235 |
+
{buttonLabels.equal}
|
236 |
</button>
|
237 |
<button
|
238 |
className="answer-btn not-equal-btn"
|
239 |
onClick={() => handleStep1Answer('not-equal')}
|
240 |
>
|
241 |
+
{buttonLabels.notEqual}
|
242 |
</button>
|
243 |
</div>
|
244 |
)}
|