diff --git a/components/editor/sidebar.tsx b/components/editor/sidebar.tsx
deleted file mode 100644
index 3703471..0000000
--- a/components/editor/sidebar.tsx
+++ /dev/null
@@ -1,65 +0,0 @@
-import {
- File,
- FilePlus,
- Folder,
- FolderOpen,
- FolderPlus,
- Search,
-} from "lucide-react"
-import Image from "next/image"
-import { getIconForFile } from "vscode-icons-js"
-
-export default function Sidebar() {
- return (
-
-
-
-
- {getIconForFile("index.html") ? (
-
- ) : (
-
- )}
- index.html
-
-
- {getIconForFile("index.html") ? (
-
- ) : (
-
- )}
- style.css
-
-
-
- styles
-
-
-
- )
-}
diff --git a/components/editor/sidebar/file.tsx b/components/editor/sidebar/file.tsx
new file mode 100644
index 0000000..3c9b390
--- /dev/null
+++ b/components/editor/sidebar/file.tsx
@@ -0,0 +1,20 @@
+"use client"
+
+import Image from "next/image"
+import { getIconForFile } from "vscode-icons-js"
+import { TFile } from "./types"
+
+export default function SidebarFile({ data }: { data: TFile }) {
+ return (
+
+
+ {data.name}
+
+ )
+}
diff --git a/components/editor/sidebar/folder.tsx b/components/editor/sidebar/folder.tsx
new file mode 100644
index 0000000..fdb764e
--- /dev/null
+++ b/components/editor/sidebar/folder.tsx
@@ -0,0 +1,46 @@
+"use client"
+
+import Image from "next/image"
+import { useState } from "react"
+import { getIconForFolder, getIconForOpenFolder } from "vscode-icons-js"
+import { TFolder } from "./types"
+import SidebarFile from "./file"
+
+export default function SidebarFolder({ data }: { data: TFolder }) {
+ const [isOpen, setIsOpen] = useState(false)
+ const folder = isOpen
+ ? getIconForOpenFolder(data.name)
+ : getIconForFolder(data.name)
+
+ return (
+ <>
+ setIsOpen((prev) => !prev)}
+ className="w-full flex items-center h-7 px-1 transition-colors hover:bg-secondary rounded-sm cursor-pointer"
+ >
+
+ {data.name}
+
+ {isOpen ? (
+
+
+
+ {data.children.map((child) =>
+ child.type === "file" ? (
+
+ ) : (
+
+ )
+ )}
+
+
+ ) : null}
+ >
+ )
+}
diff --git a/components/editor/sidebar/index.tsx b/components/editor/sidebar/index.tsx
new file mode 100644
index 0000000..c92913b
--- /dev/null
+++ b/components/editor/sidebar/index.tsx
@@ -0,0 +1,95 @@
+import { FilePlus, FolderPlus, Search } from "lucide-react"
+import SidebarFile from "./file"
+import SidebarFolder from "./folder"
+import { TFile, TFolder } from "./types"
+
+const data: (TFile | TFolder)[] = [
+ {
+ id: "index.tsx",
+ type: "file",
+ name: "index.tsx",
+ },
+ {
+ id: "components",
+ type: "folder",
+ name: "components",
+ children: [
+ {
+ id: "navbar.tsx",
+ type: "file",
+ name: "navbar.tsx",
+ },
+ {
+ id: "ui",
+ type: "folder",
+ name: "ui",
+ children: [
+ {
+ id: "Button.tsx",
+ type: "file",
+ name: "Button.tsx",
+ },
+ {
+ id: "Input.tsx",
+ type: "file",
+ name: "Input.tsx",
+ },
+ ],
+ },
+ ],
+ },
+ {
+ id: "App.tsx",
+ type: "file",
+ name: "App.tsx",
+ },
+ {
+ id: "styles",
+ type: "folder",
+ name: "styles",
+ children: [
+ {
+ id: "style.css",
+ type: "file",
+ name: "style.css",
+ },
+ {
+ id: "index.css",
+ type: "file",
+ name: "index.css",
+ },
+ ],
+ },
+]
+
+export default function Sidebar() {
+ return (
+
+
+
+ {/*
+ */}
+ {data.map((child) =>
+ child.type === "file" ? (
+
+ ) : (
+
+ )
+ )}
+
+
+ )
+}
diff --git a/components/editor/sidebar/types.ts b/components/editor/sidebar/types.ts
new file mode 100644
index 0000000..b8e3eae
--- /dev/null
+++ b/components/editor/sidebar/types.ts
@@ -0,0 +1,12 @@
+export type TFolder = {
+ id: string
+ type: "folder"
+ name: string
+ children: (TFile | TFolder)[]
+}
+
+export type TFile = {
+ id: string
+ type: "file"
+ name: string
+}