forked from PinSpace-Org/GistPin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddGistModal.tsx
More file actions
75 lines (69 loc) 路 2.41 KB
/
Copy pathAddGistModal.tsx
File metadata and controls
75 lines (69 loc) 路 2.41 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
63
64
65
66
67
68
69
70
71
72
73
74
75
'use client';
import { useState } from 'react';
import { motion, AnimatePresence } from 'framer-motion';
interface AddGistModalProps {
isOpen: boolean;
onClose: () => void;
onAddGist: (content: string) => void;
}
export default function AddGistModal({
isOpen,
onClose,
onAddGist,
}: AddGistModalProps) {
const [content, setContent] = useState('');
const [isLoading, setIsLoading] = useState(false);
const handleSubmit = () => {
if (!content.trim()) return;
setIsLoading(true);
setTimeout(() => {
onAddGist(content);
setContent('');
setIsLoading(false);
onClose();
}, 2000);
};
return (
<AnimatePresence>
{isOpen && (
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
className="absolute inset-0 z-[1000] flex items-end justify-center bg-black/60"
onClick={onClose}
>
<motion.div
initial={{ y: '100%' }}
animate={{ y: '0%' }}
exit={{ y: '100%' }}
transition={{ type: 'spring', stiffness: 300, damping: 30 }}
className="w-full max-w-lg p-6 bg-white dark:bg-gray-800 rounded-t-2xl shadow-lg"
onClick={(e) => e.stopPropagation()}
>
<h2 className="text-xl font-bold mb-4 text-gray-900 dark:text-white">
Pin a New Gist
</h2>
<textarea
value={content}
onChange={(e) => setContent(e.target.value)}
placeholder="What's the gist? (max 280 characters)"
maxLength={280}
className="w-full p-3 border rounded-lg h-28 bg-gray-50 dark:bg-gray-700 dark:text-white dark:border-gray-600 focus:outline-none focus:ring-2 focus:ring-blue-500"
/>
<button
onClick={handleSubmit}
disabled={isLoading}
className="w-full mt-4 px-6 py-3 text-lg font-semibold text-white rounded-lg bg-gradient-to-r from-purple-600 via-blue-600 to-pink-400
bg-[size:200%_auto]
hover:bg-[position:100%_center]
transition-all duration-500 ease-in-out disabled:bg-blue-400 disabled:cursor-not-allowed"
>
{isLoading ? 'Pinning...' : 'Pin Gist'}
</button>
</motion.div>
</motion.div>
)}
</AnimatePresence>
);
}