diff --git a/src/App.jsx b/src/App.jsx
index 9e3f740..0910d0a 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -10,6 +10,8 @@ import RandomColor from "@/pages/RandomColor";
import StarRating from "@/pages/StarRating";
import ImageSlider from "@/pages/ImageSlider"
import LoadMoreData from "./pages/LoadMoreData";
+import TreeView from "./pages/tree-view/TreeView";
+import menus from "./pages/tree-view/data";
function App() {
return (
@@ -28,6 +30,8 @@ function App() {
} />
{/* load more data button */}
} />
+ {/* tree view */}
+ } />
{/* Error Page */}
} />
diff --git a/src/pages/Home.jsx b/src/pages/Home.jsx
index fe1b064..3641d03 100644
--- a/src/pages/Home.jsx
+++ b/src/pages/Home.jsx
@@ -10,6 +10,7 @@ function Home() {
star rating
image slider
load more button
+ tree view
);
}
diff --git a/src/pages/LoadMoreData.jsx b/src/pages/LoadMoreData.jsx
index e8f5bab..053098e 100644
--- a/src/pages/LoadMoreData.jsx
+++ b/src/pages/LoadMoreData.jsx
@@ -36,7 +36,7 @@ function LoadMoreData() {
if (loading) {
return
+
handleToggleChildren(item.label)}
+ >
+
{item.label}
+ {item && item.children && item.children.length ? (
+
+ {displayCurrentChildren[item.label] ? : }
+
+ ) : null}
+
+
+ {item &&
+ item.children &&
+ item.children.length > 0 &&
+ displayCurrentChildren[item.label] ? (
+
+ ) : null}
+
+ );
+}
+
+export default MenuItem;
diff --git a/src/pages/tree-view/MenuList.jsx b/src/pages/tree-view/MenuList.jsx
new file mode 100644
index 0000000..f0bce4c
--- /dev/null
+++ b/src/pages/tree-view/MenuList.jsx
@@ -0,0 +1,15 @@
+import MenuItem from "./MenuItem";
+
+function MenuList({ list = [] }) {
+ return (
+
+ {list && list.length
+ ? list.map((listItem, index) => (
+
+ ))
+ : null}
+
+ );
+}
+
+export default MenuList;
diff --git a/src/pages/tree-view/TreeView.jsx b/src/pages/tree-view/TreeView.jsx
new file mode 100644
index 0000000..808262c
--- /dev/null
+++ b/src/pages/tree-view/TreeView.jsx
@@ -0,0 +1,11 @@
+import MenuList from "./MenuList"
+
+function TreeView({menus = []}) {
+ return (
+
+
+
+ )
+}
+
+export default TreeView
diff --git a/src/pages/tree-view/data.js b/src/pages/tree-view/data.js
new file mode 100644
index 0000000..b5b88bf
--- /dev/null
+++ b/src/pages/tree-view/data.js
@@ -0,0 +1,60 @@
+export const menus = [
+ {
+ label: "Home",
+ to: "/",
+ },
+ {
+ label: "Profile",
+ to: "/profile",
+ children: [
+ {
+ label: "Details",
+ to: "details",
+ children: [
+ {
+ label: "Location",
+ to: "location",
+ children: [
+ {
+ label: "City",
+ to: "city",
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ },
+ {
+ label: "Settings",
+ to: "/settings",
+ children: [
+ {
+ label: "Account",
+ to: "account",
+ },
+ {
+ label: "Security",
+ to: "security",
+ children: [
+ {
+ label: "Login",
+ to: "login",
+ },
+ {
+ label: "Register",
+ to: "register",
+ children: [
+ {
+ label: "Random data",
+ to: "",
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ },
+];
+
+export default menus;