forked from microsoft/github-copilot-vibe-coding-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNameInputModal.jsx
More file actions
62 lines (58 loc) · 1.92 KB
/
Copy pathNameInputModal.jsx
File metadata and controls
62 lines (58 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { useState } from 'react';
const NameInputModal = ({ onClose, onSubmit }) => {
const [username, setUsername] = useState('');
const [error, setError] = useState('');
const handleSubmit = (e) => {
e.preventDefault();
setError('');
if (!username) {
setError('Username is required.');
return;
}
onSubmit(username);
setUsername('');
onClose();
};
return (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-40">
<div className="bg-white rounded-2xl shadow-lg w-full max-w-md p-8 relative">
<button
className="absolute top-4 right-4 text-gray-400 hover:text-gray-600 text-xl"
aria-label="Close modal"
onClick={onClose}
>
×
</button>
<h2 className="text-xl font-bold mb-4 text-[#222]">Enter Your Name</h2>
<form onSubmit={handleSubmit} className="flex flex-col gap-4">
<input
type="text"
className="border rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-[#0D8ABC]"
placeholder="Your name"
value={username}
onChange={e => setUsername(e.target.value)}
aria-label="Username"
required
/>
{error && <div className="text-red-500 text-sm">{error}</div>}
<div className="flex gap-3 mt-2">
<button
type="submit"
className="bg-[#0D8ABC] text-white px-4 py-2 rounded-lg font-semibold shadow hover:bg-[#0971a3] transition flex-1"
>
Confirm
</button>
<button
type="button"
className="bg-gray-200 text-gray-700 px-4 py-2 rounded-lg font-semibold flex-1"
onClick={onClose}
>
Cancel
</button>
</div>
</form>
</div>
</div>
);
};
export default NameInputModal;