Spaces:
Build error
Build error
| import { useState } from 'react' | |
| import { Upload, FileText } from 'lucide-react' | |
| export default function ContentInput({ onContentSubmit }) { | |
| const [content, setContent] = useState('') | |
| const handleSubmit = (e) => { | |
| e.preventDefault() | |
| if (content.trim()) { | |
| onContentSubmit(content) | |
| } | |
| } | |
| const handleFileUpload = (e) => { | |
| const file = e.target.files[0] | |
| if (file) { | |
| const reader = new FileReader() | |
| reader.onload = (event) => { | |
| setContent(event.target.result) | |
| } | |
| reader.readAsText(file) | |
| } | |
| } | |
| return ( | |
| <div className="bg-white rounded-xl shadow-lg p-6"> | |
| <div className="flex items-center space-x-3 mb-6"> | |
| <FileText className="h-6 w-6 text-blue-600" /> | |
| <h2 className="text-xl font-semibold text-gray-900">Add Your Content</h2> | |
| </div> | |
| <div className="space-y-4"> | |
| <div className="border-2 border-dashed border-gray-300 rounded-lg p-6 text-center"> | |
| <Upload className="h-8 w-8 text-gray-400 mx-auto mb-2" /> | |
| <p className="text-sm text-gray-600 mb-2">Upload a text file</p> | |
| <input | |
| type="file" | |
| accept=".txt,.md" | |
| onChange={handleFileUpload} | |
| className="block w-full text-sm text-gray-500 file:mr-4 file:py-2 file:px-4 file:rounded-full file:border-0 file:text-sm file:font-semibold file:bg-blue-50 file:text-blue-700 hover:file:bg-blue-100" | |
| /> | |
| </div> | |
| <div className="text-sm text-gray-500 text-center">- OR -</div> | |
| <form onSubmit={handleSubmit} className="space-y-4"> | |
| <textarea | |
| value={content} | |
| onChange={(e) => setContent(e.target.value)} | |
| placeholder="Paste your content here, or upload a file above..." | |
| className="w-full h-64 p-4 border border-gray-300 rounded-lg resize-none focus:ring-2 focus:ring-blue-500 focus:border-transparent" | |
| /> | |
| <button | |
| type="submit" | |
| disabled={!content.trim()} | |
| className="w-full bg-blue-600 text-white py-3 px-4 rounded-lg font-semibold hover:bg-blue-700 disabled:bg-gray-300 disabled:cursor-not-allowed transition-colors" | |
| > | |
| Create Interactive Book | |
| </button> | |
| </form> | |
| </div> | |
| </div> | |
| ) | |
| } |