From 53dca5aae6014d4c63ad7503a0839be971c66b7a Mon Sep 17 00:00:00 2001 From: Prozilla Date: Sat, 29 Jul 2023 15:28:15 +0200 Subject: [PATCH] Updated docu for file explorer and media viewer --- docs/features/applications/README.md | 34 ++++++++++++------- .../applications/file-explorer/README.md | 5 +++ .../applications/media-viewer/README.md | 5 +++ src/features/applications/application.js | 7 ++-- src/features/applications/applications.js | 1 + src/hooks/virtual-drive/VirtualRootContext.js | 1 + 6 files changed, 38 insertions(+), 15 deletions(-) create mode 100644 docs/features/applications/file-explorer/README.md create mode 100644 docs/features/applications/media-viewer/README.md diff --git a/docs/features/applications/README.md b/docs/features/applications/README.md index 219790a..9bfe4c3 100644 --- a/docs/features/applications/README.md +++ b/docs/features/applications/README.md @@ -6,24 +6,15 @@ Applications (sometimes shortened to apps) are processes that open a window when ## Table of Contents -- [ Terminal](./terminal/README.md) +- [ Terminal](terminal/README.md) +- [ File Explorer](file-explorer/README.md) +- [ Media Viewer](media-viewer/README.md) ## Examples ### Adding a new application ```js -// src/features/applications/applications.js - -export default class ApplicationsManager { - static APPLICATIONS = [ - // ... - new Application("Example App", "example", ), - ] - - // ... -} - // src/components/applications/example/Example.jsx export function Example() { @@ -33,15 +24,32 @@ export function Example() { } ``` +```js +// src/features/applications/applications.js + +import { Example } from "../../components/applications/example/Example.jsx"; + +export default class ApplicationsManager { + static APPLICATIONS = [ + // ... + new Application("Example App", "example", Example), + ] + + // ... +} +``` + ### Turning a webpage into an application ```js // src/features/applications/applications.js +import { WebView } from "../../components/applications/templates/WebView.jsx"; + export default class ApplicationsManager { static APPLICATIONS = [ // ... - new Application("Web App", "web-app", ), + new Application("Web App", "web-app", WebView, { source: "https://prozilla.dev/" }), ] // ... diff --git a/docs/features/applications/file-explorer/README.md b/docs/features/applications/file-explorer/README.md new file mode 100644 index 0000000..7653d86 --- /dev/null +++ b/docs/features/applications/file-explorer/README.md @@ -0,0 +1,5 @@ +[← Back](../README.md) + +# File Explorer + +A tool for exploring and managing files with a user interface. \ No newline at end of file diff --git a/docs/features/applications/media-viewer/README.md b/docs/features/applications/media-viewer/README.md new file mode 100644 index 0000000..cfb26a8 --- /dev/null +++ b/docs/features/applications/media-viewer/README.md @@ -0,0 +1,5 @@ +[← Back](../README.md) + +# Media Viewer + +An application for viewing media like images and videos. \ No newline at end of file diff --git a/src/features/applications/application.js b/src/features/applications/application.js index 4af341a..46f6584 100644 --- a/src/features/applications/application.js +++ b/src/features/applications/application.js @@ -1,18 +1,21 @@ export default class Application { /** * @param {String} name - * @param {String} id + * @param {String} id * @param {React.ReactElement} windowContent + * @param {Object|null} windowOptions - Default window options */ constructor(name, id, windowContent, windowOptions) { Object.assign(this, { name, id, windowContent, windowOptions }); + + if (this.windowContent == null) + console.warn(`App (${this.id}) is missing the windowContent property.`); } WindowContent = (props) => { props = {...props, ...this.windowOptions}; if (this.windowContent == null) { - console.warn(`App (${this.id}) is missing the windowContent property.`); return null; } diff --git a/src/features/applications/applications.js b/src/features/applications/applications.js index 0d38b1d..01a26b9 100644 --- a/src/features/applications/applications.js +++ b/src/features/applications/applications.js @@ -35,6 +35,7 @@ export default class ApplicationsManager { } /** + * Get the application associated with a file extension * @param {String} fileExtension * @returns {Application} */ diff --git a/src/hooks/virtual-drive/VirtualRootContext.js b/src/hooks/virtual-drive/VirtualRootContext.js index fbfa972..7a1f265 100644 --- a/src/hooks/virtual-drive/VirtualRootContext.js +++ b/src/hooks/virtual-drive/VirtualRootContext.js @@ -4,6 +4,7 @@ import { VirtualRoot } from "../../features/virtual-drive/virtual-root.js"; const VirtualRootContext = createContext(); /** + * Initializes the virtual root with folders and files * @param {VirtualRoot} virtualRoot */ function initVirtualRoot(virtualRoot) {