-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.html
More file actions
66 lines (57 loc) · 2.15 KB
/
example.html
File metadata and controls
66 lines (57 loc) · 2.15 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Hello World — Preview</title>
<!-- React 18 -->
<script crossorigin src="https://unpkg.com/react@18/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
<!-- Babel standalone (transpiles JSX in the browser) -->
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-50 min-h-screen flex items-center justify-center p-8">
<div id="root"></div>
<script type="text/babel">
const { useState } = React;
function App() {
const [count, setCount] = useState(0);
return (
<div className="bg-white rounded-2xl shadow-md p-10 text-center max-w-sm w-full">
<h1 className="text-3xl font-bold text-indigo-600 mb-2">Hello, World!</h1>
<p className="text-gray-500 mb-6">
This is an example React component preview.
</p>
<p className="text-5xl font-mono font-semibold text-gray-800 mb-6">
{count}
</p>
<div className="flex gap-3 justify-center">
<button
onClick={() => setCount(c => c - 1)}
className="px-4 py-2 rounded-lg bg-gray-100 hover:bg-gray-200 text-gray-700 font-medium transition"
>
−
</button>
<button
onClick={() => setCount(0)}
className="px-4 py-2 rounded-lg bg-gray-100 hover:bg-gray-200 text-gray-700 font-medium transition"
>
Reset
</button>
<button
onClick={() => setCount(c => c + 1)}
className="px-4 py-2 rounded-lg bg-indigo-600 hover:bg-indigo-700 text-white font-medium transition"
>
+
</button>
</div>
</div>
);
}
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<App />);
</script>
</body>
</html>