|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="UTF-8"> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 6 | + <title>ObjectQL Server (Debug Mode)</title> |
| 7 | + <script src="https://cdn.tailwindcss.com"></script> |
| 8 | + |
| 9 | + <!-- React Dependencies --> |
| 10 | + <script crossorigin src="https://unpkg.com/react@18/umd/react.development.js"></script> |
| 11 | + <script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script> |
| 12 | + |
| 13 | + <!-- Babel for in-browser JSX compilation --> |
| 14 | + <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> |
| 15 | +</head> |
| 16 | +<body class="bg-gray-100 min-h-screen"> |
| 17 | + <div id="root" class="p-8"></div> |
| 18 | + |
| 19 | + <script type="text/babel"> |
| 20 | + const { useState, useEffect } = React; |
| 21 | +
|
| 22 | + // --- Inline Components for Debugging --- |
| 23 | + |
| 24 | + function Button({ children, onClick, className }) { |
| 25 | + return ( |
| 26 | + <button |
| 27 | + onClick={onClick} |
| 28 | + className={`px-4 py-2 bg-stone-900 text-white rounded hover:bg-stone-800 transition ${className}`} |
| 29 | + > |
| 30 | + {children} |
| 31 | + </button> |
| 32 | + ); |
| 33 | + } |
| 34 | +
|
| 35 | + function FieldWrapper({ label, description, children }) { |
| 36 | + return ( |
| 37 | + <div className="mb-4 space-y-1.5"> |
| 38 | + <label className="block text-sm font-medium leading-none">{label}</label> |
| 39 | + {children} |
| 40 | + {description && <p className="text-[0.8rem] text-stone-500">{description}</p>} |
| 41 | + </div> |
| 42 | + ); |
| 43 | + } |
| 44 | +
|
| 45 | + function StringField({ label, description, value, onChange }) { |
| 46 | + return ( |
| 47 | + <FieldWrapper label={label} description={description}> |
| 48 | + <input |
| 49 | + type="text" |
| 50 | + value={value} |
| 51 | + onChange={(e) => onChange(e.target.value)} |
| 52 | + className="flex h-10 w-full rounded-md border border-stone-200 bg-white px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-stone-950" |
| 53 | + /> |
| 54 | + </FieldWrapper> |
| 55 | + ); |
| 56 | + } |
| 57 | +
|
| 58 | + function NumberField({ label, description, value, onChange }) { |
| 59 | + return ( |
| 60 | + <FieldWrapper label={label} description={description}> |
| 61 | + <input |
| 62 | + type="number" |
| 63 | + value={value} |
| 64 | + onChange={(e) => onChange(Number(e.target.value))} |
| 65 | + className="flex h-10 w-full rounded-md border border-stone-200 bg-white px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-stone-950" |
| 66 | + /> |
| 67 | + </FieldWrapper> |
| 68 | + ); |
| 69 | + } |
| 70 | +
|
| 71 | + function BooleanField({ label, description, value, onChange }) { |
| 72 | + return ( |
| 73 | + <div className="flex flex-row items-center justify-between rounded-lg border p-4"> |
| 74 | + <div className="space-y-0.5"> |
| 75 | + <label className="text-base font-medium">{label}</label> |
| 76 | + {description && <p className="text-sm text-stone-500">{description}</p>} |
| 77 | + </div> |
| 78 | + <input |
| 79 | + type="checkbox" |
| 80 | + checked={value} |
| 81 | + onChange={(e) => onChange(e.target.checked)} |
| 82 | + className="h-4 w-4" |
| 83 | + /> |
| 84 | + </div> |
| 85 | + ); |
| 86 | + } |
| 87 | +
|
| 88 | + // --- Main App --- |
| 89 | +
|
| 90 | + function App() { |
| 91 | + const [name, setName] = useState('My Project'); |
| 92 | + const [budget, setBudget] = useState(5000); |
| 93 | + const [isPublic, setIsPublic] = useState(true); |
| 94 | +
|
| 95 | + return ( |
| 96 | + <div className="max-w-md mx-auto bg-white p-6 rounded-lg shadow-lg border space-y-6"> |
| 97 | + <div> |
| 98 | + <h1 className="text-2xl font-bold">New Project</h1> |
| 99 | + <p className="text-stone-500">Create a new project using Inline Components</p> |
| 100 | + </div> |
| 101 | +
|
| 102 | + <div className="space-y-4"> |
| 103 | + <StringField |
| 104 | + label="Project Name" |
| 105 | + description="Public display name" |
| 106 | + value={name} |
| 107 | + onChange={setName} |
| 108 | + /> |
| 109 | + |
| 110 | + <NumberField |
| 111 | + label="Budget" |
| 112 | + description="Total budget in USD" |
| 113 | + value={budget} |
| 114 | + onChange={setBudget} |
| 115 | + /> |
| 116 | + |
| 117 | + <BooleanField |
| 118 | + label="Public Access" |
| 119 | + description="Anyone can view this project" |
| 120 | + value={isPublic} |
| 121 | + onChange={setIsPublic} |
| 122 | + /> |
| 123 | +
|
| 124 | + <div className="pt-4 flex justify-end"> |
| 125 | + <Button onClick={() => alert(JSON.stringify({ name, budget, isPublic }, null, 2))}> |
| 126 | + Create Project |
| 127 | + </Button> |
| 128 | + </div> |
| 129 | + </div> |
| 130 | + </div> |
| 131 | + ); |
| 132 | + } |
| 133 | +
|
| 134 | + const root = ReactDOM.createRoot(document.getElementById('root')); |
| 135 | + root.render(<App />); |
| 136 | + </script> |
| 137 | +</body> |
| 138 | +</html> |
| 139 | + |
0 commit comments