Spaces:
Build error
Build error
File size: 1,472 Bytes
9b63060 | 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 |
import React, { useState } from 'react';
import { Play, X } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Textarea } from '@/components/ui/textarea';
interface ScriptPanelProps {
onInjectScript: (script: string) => void;
onClose?: () => void;
}
const ScriptPanel = ({ onInjectScript, onClose }: ScriptPanelProps) => {
const [script, setScript] = useState('');
const handleInject = () => {
if (!script.trim()) {
alert('Script is empty.');
return;
}
onInjectScript(script);
};
return (
<div className="fixed bottom-4 left-4 z-[9999] bg-white rounded-lg shadow-lg border border-gray-200 p-4 w-80">
<div className="font-semibold text-sm text-gray-700 mb-3 flex items-center justify-between">
<span className="flex items-center">
💡 User Script
</span>
{onClose && (
<Button variant="ghost" size="sm" onClick={onClose} className="p-1 h-auto">
<X className="w-4 h-4" />
</Button>
)}
</div>
<Textarea
value={script}
onChange={(e) => setScript(e.target.value)}
placeholder="Write JavaScript to run inside the iframe..."
className="font-mono text-xs resize-none h-24 mb-3"
/>
<Button onClick={handleInject} size="sm" className="w-full">
<Play className="w-4 h-4 mr-1" />
Inject Script
</Button>
</div>
);
};
export default ScriptPanel;
|