From 716f21d3fb9d1b752af2904f7db7d1bbd4d18ad2 Mon Sep 17 00:00:00 2001 From: Prozilla Date: Wed, 26 Jul 2023 07:34:27 +0200 Subject: [PATCH] Added file explorer interface --- .../file-explorer/FileExplorer.jsx | 86 +++++++++++++ .../file-explorer/FileExplorer.module.css | 115 ++++++++++++++++++ src/features/applications/applications.js | 3 +- 3 files changed, 203 insertions(+), 1 deletion(-) create mode 100644 src/components/applications/file-explorer/FileExplorer.jsx create mode 100644 src/components/applications/file-explorer/FileExplorer.module.css diff --git a/src/components/applications/file-explorer/FileExplorer.jsx b/src/components/applications/file-explorer/FileExplorer.jsx new file mode 100644 index 0000000..3653c85 --- /dev/null +++ b/src/components/applications/file-explorer/FileExplorer.jsx @@ -0,0 +1,86 @@ +import { useState } from "react"; +import { useVirtualRoot } from "../../../hooks/virtual-drive/VirtualRootContext.js"; +import styles from "./FileExplorer.module.css"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { faArrowUp, faCaretLeft, faCaretRight, faCog, faDesktop, faFileLines, faHouse, faImage, faSearch } from "@fortawesome/free-solid-svg-icons"; + +export function FileExplorer() { + const virtualRoot = useVirtualRoot(); + const [currentDirectory, setCurrentDirectory] = useState(virtualRoot.navigate("~")); + const [path, setPath] = useState(currentDirectory.path); + + const changeDirectory = (path, absolute = false) => { + const directory = absolute ? virtualRoot.navigate(path) : currentDirectory.navigate(path); + + console.log(directory); + + if (directory) { + setCurrentDirectory(directory); + setPath(directory.path); + } + } + + const onPathChange = (event) => { + return setPath(event.target.value); + } + + const onKeyDown = (event) => { + const value = event.target.value; + + if (event.key === "Enter") { + setCurrentDirectory(virtualRoot.navigate(value)); + } + }; + + return ( +
+
+ + + + + + +
+
+
+ + + + +
+
+ +
+
+
+ ); +} \ No newline at end of file diff --git a/src/components/applications/file-explorer/FileExplorer.module.css b/src/components/applications/file-explorer/FileExplorer.module.css new file mode 100644 index 0000000..7afc90a --- /dev/null +++ b/src/components/applications/file-explorer/FileExplorer.module.css @@ -0,0 +1,115 @@ +.Container { + --header-height: 3.5rem; + --sidebar-width: 10rem; + + display: flex; + flex-direction: column; + width: 100%; + height: 100%; +} + +.Header { + display: flex; + gap: 1rem; + align-items: center; + width: 100%; + height: var(--header-height); + padding: 1rem; + background-color: var(--background-color-a); +} + +.Icon-button { + position: relative; + height: 1.25rem; + width: auto; + padding: 0; + color: var(--foreground-a); + background: none; + border: none; + outline: none; + aspect-ratio: 1; + cursor: pointer; +} + +.Icon-button::after { + content: ""; + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: rgba(255, 255, 255, 0%); + border-radius: 9999px; + transform: scale(100%); + transform-origin: center; + transition: all 200ms ease-in-out; +} + +.Icon-button:hover::after { + background-color: rgba(255, 255, 255, 10%); + transform: scale(150%); +} + +.Icon-button svg { + height: 100%; +} + +.Path-input { + flex: 1; + padding: 0.25rem 0.5rem; + background-color: var(--background-color-c); + border: none; + border-radius: 0.5rem; + outline: none; + font-family: inherit; + font-size: inherit; +} + +.Body { + flex: 1; + display: flex; + width: 100%; + background-color: var(--background-color-c); +} + +.Sidebar { + display: flex; + gap: 0.25rem; + flex-direction: column; + min-width: calc(var(--sidebar-width) / 2); + width: var(--sidebar-width); + height: 100%; + max-width: 50%; + padding: 0.5rem; + background-color: var(--background-color-b); + resize: horizontal; + overflow: hidden; +} + +.Nav-button { + display: flex; + gap: 0.5rem; + align-items: center; + width: 100%; + padding: 0.5rem; + background: none; + border: none; + border-radius: 0.5rem; + outline: none; + cursor: pointer; + transition: background-color 200ms ease-in-out; +} + +.Nav-button:hover { + background-color: rgba(255, 255, 255, 10%); +} + +.Nav-button svg { + height: 1.35rem; + aspect-ratio: 1; +} + +.Main { + flex: 1; + height: 100%; +} \ No newline at end of file diff --git a/src/features/applications/applications.js b/src/features/applications/applications.js index 7664cba..95fcd86 100644 --- a/src/features/applications/applications.js +++ b/src/features/applications/applications.js @@ -1,4 +1,5 @@ /* eslint-disable eqeqeq */ +import { FileExplorer } from "../../components/applications/file-explorer/FileExplorer.jsx"; import { WebView } from "../../components/applications/templates/WebView.jsx"; import { Terminal } from "../../components/applications/terminal/Terminal.jsx"; import Application from "./application.js"; @@ -8,7 +9,7 @@ export default class ApplicationsManager { new Application("Terminal", "terminal", ), // new Application("Browser", "browser"), new Application("Code Editor", "code-editor"), - new Application("File Explorer", "file-explorer"), + new Application("File Explorer", "file-explorer", ), new Application("Media Viewer", "media-viewer"), new Application("Wordle", "wordle", ), new Application("Balls", "balls", ),