-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
new-react.ts
65 lines (62 loc) · 1.6 KB
/
new-react.ts
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
import React from "react";
import "./styles.css";
const levels = [
{
name: "ground level",
description: "Welcome to the ground level. Explore the surroundings.",
levels: [
{
name: "grass level",
description: "You are now at the grass level, full of greenery.",
levels: [
{
name: "bug level",
description:
"This is the bug level. Watch out for the tiny creatures!",
levels: [
{
name: "sky level",
description:
"You've reached the sky level. Enjoy the view!",
levels: [
{
name: "space level",
description:
"Welcome to the space level. The universe is yours to explore!",
levels: [], // Further nesting can be added
},
],
},
],
},
],
},
],
},
];
const Level = ({ level, depth = 0 }) => {
return (
<div
className={`level-container`}
style={{ transform: `scale(${1 - depth * 0.1})` }}
>
<h2>{level.name}</h2>
<p>{level.description}</p>
{level.levels && level.levels.length > 0 && (
<div>
{level.levels.map((subLevel, index) => (
<Level key={index} level={subLevel} depth={depth + 1} />
))}
</div>
)}
</div>
);
};
export default function App() {
return (
<div className="App">
<h1>Hello CodeSandbox</h1>
<Level level={levels[0]} />
</div>
);
}