ghost613 commited on
Commit
a49e052
·
verified ·
1 Parent(s): 0cadb99

Update components/MathQuizApp.tsx

Browse files
Files changed (1) hide show
  1. components/MathQuizApp.tsx +56 -54
components/MathQuizApp.tsx CHANGED
@@ -63,62 +63,64 @@ const MathQuizApp = () => {
63
  };
64
 
65
  return (
66
- <div className="max-w-3xl mx-auto p-8 bg-white rounded-lg shadow-md">
67
- <h1 className="text-4xl font-bold mb-8 text-center">Math Quiz App</h1>
68
- <form onSubmit={handleSubmit} className="space-y-6">
69
- <div className="flex flex-col items-center gap-6">
70
- <div className="flex gap-8 items-center justify-center">
71
- <div className="text-xl font-bold">Correct: {score}</div>
72
- <div className="text-xl font-bold text-red-500">Wrong: {wrongAnswers}</div>
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  </div>
74
- <select
75
- value={difficulty}
76
- onChange={handleDifficultyChange}
77
- className="bg-gray-50 border border-gray-300 text-gray-900 text-lg rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2.5 w-48 text-center"
78
- >
79
- {difficulties.map((difficulty) => (
80
- <option key={difficulty} value={difficulty}>
81
- {difficulty.charAt(0).toUpperCase() + difficulty.slice(1)}
82
- </option>
83
- ))}
84
- </select>
85
- </div>
86
- <div className="text-center mt-8">
87
- <p className="text-3xl font-bold mb-6">
88
- What is {question.num1} {question.operation} {question.num2}?
89
- </p>
90
- <input
91
- type="number"
92
- value={userAnswer}
93
- onChange={(e) => setUserAnswer(e.target.value)}
94
- className="bg-gray-50 border border-gray-300 text-gray-900 text-xl rounded-lg focus:ring-blue-500 focus:border-blue-500 p-4 w-64 text-center"
95
- />
96
- </div>
97
- <div className="text-center">
98
- <button
99
- type="submit"
100
- className="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-lg px-8 py-3 text-center"
101
- >
102
- Submit
103
- </button>
104
- </div>
105
- {result && (
106
- <p
107
- className={`text-xl font-bold text-center ${
108
- result === 'Correct!' ? 'text-green-500' : 'text-red-500'
109
- }`}
110
- >
111
- {result}{' '}
112
- {result === 'Correct!' ? (
113
- <Check className="inline-block w-6 h-6" />
114
- ) : (
115
- <X className="inline-block w-6 h-6" />
116
- )}
117
- </p>
118
- )}
119
- </form>
120
  </div>
121
  );
122
  };
123
 
124
- export default MathQuizApp;
 
63
  };
64
 
65
  return (
66
+ <div className="bg-gray-50 min-h-screen flex items-center justify-center">
67
+ <div className="max-w-3xl mx-auto p-8 bg-white rounded-lg shadow-md mt-4">
68
+ <h1 className="text-4xl font-bold mb-8 text-center">Math Quiz App</h1>
69
+ <form onSubmit={handleSubmit} className="space-y-6">
70
+ <div className="flex flex-col items-center gap-6">
71
+ <div className="flex gap-8 items-center justify-center">
72
+ <div className="text-xl font-bold">Correct: {score}</div>
73
+ <div className="text-xl font-bold text-red-500">Wrong: {wrongAnswers}</div>
74
+ </div>
75
+ <select
76
+ value={difficulty}
77
+ onChange={handleDifficultyChange}
78
+ className="bg-gray-50 border border-gray-300 text-gray-900 text-lg rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2.5 w-48 text-center"
79
+ >
80
+ {difficulties.map((difficulty) => (
81
+ <option key={difficulty} value={difficulty}>
82
+ {difficulty.charAt(0).toUpperCase() + difficulty.slice(1)}
83
+ </option>
84
+ ))}
85
+ </select>
86
  </div>
87
+ <div className="text-center mt-8">
88
+ <p className="text-3xl font-bold mb-6">
89
+ What is {question.num1} {question.operation} {question.num2}?
90
+ </p>
91
+ <input
92
+ type="number"
93
+ value={userAnswer}
94
+ onChange={(e) => setUserAnswer(e.target.value)}
95
+ className="bg-gray-50 border border-gray-300 text-gray-900 text-xl rounded-lg focus:ring-blue-500 focus:border-blue-500 p-4 w-64 text-center"
96
+ />
97
+ </div>
98
+ <div className="text-center">
99
+ <button
100
+ type="submit"
101
+ className="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-lg px-8 py-3 text-center"
102
+ >
103
+ Submit
104
+ </button>
105
+ </div>
106
+ {result && (
107
+ <p
108
+ className={`text-xl font-bold text-center ${
109
+ result === 'Correct!' ? 'text-green-500' : 'text-red-500'
110
+ }`}
111
+ >
112
+ {result}{' '}
113
+ {result === 'Correct!' ? (
114
+ <Check className="inline-block w-6 h-6" />
115
+ ) : (
116
+ <X className="inline-block w-6 h-6" />
117
+ )}
118
+ </p>
119
+ )}
120
+ </form>
121
+ </div>
 
 
 
 
 
 
 
 
 
 
 
122
  </div>
123
  );
124
  };
125
 
126
+ export default MathQuizApp;