diff --git a/frontend/components/editor/sidebar/file.tsx b/frontend/components/editor/sidebar/file.tsx index 6d33039..79058b4 100644 --- a/frontend/components/editor/sidebar/file.tsx +++ b/frontend/components/editor/sidebar/file.tsx @@ -66,7 +66,7 @@ export default function SidebarFile({ > boolean }) { + const [creatingNew, setCreatingNew] = useState<"file" | "folder" | null>(null) + return (
Explorer
-
+
-
+ +
-
+ + {/* Todo: Implement file searching */} + {/*
+ */}
@@ -41,23 +52,31 @@ export default function Sidebar({
) : ( - files.map((child) => - child.type === "file" ? ( - + {files.map((child) => + child.type === "file" ? ( + + ) : ( + + ) + )} + {creatingNew !== null ? ( + setCreatingNew(null)} /> - ) : ( - - ) - ) + ) : null} + )}
diff --git a/frontend/components/editor/sidebar/new.tsx b/frontend/components/editor/sidebar/new.tsx new file mode 100644 index 0000000..3289e00 --- /dev/null +++ b/frontend/components/editor/sidebar/new.tsx @@ -0,0 +1,51 @@ +"use client" + +import Image from "next/image" +import { useEffect, useRef } from "react" + +export default function New({ + type, + stopEditing, +}: { + type: "file" | "folder" + stopEditing: () => void +}) { + const inputRef = useRef(null) + + const createFile = () => { + console.log("Create File") + stopEditing() + } + + useEffect(() => { + inputRef.current?.focus() + }, []) + + return ( +
+ File Icon +
{ + e.preventDefault() + createFile() + }} + > + createFile()} + /> +
+
+ ) +}