From e905b2b3ca44b83bd85d2fbc31c2f1fb44768016 Mon Sep 17 00:00:00 2001 From: Prozilla Date: Sun, 23 Jul 2023 20:35:52 +0200 Subject: [PATCH] Updated docs with examples --- docs/features/applications/README.md | 42 ++++++++++++++++++- docs/features/applications/terminal/README.md | 2 + docs/features/virtual-drive/README.md | 19 ++++++++- 3 files changed, 61 insertions(+), 2 deletions(-) diff --git a/docs/features/applications/README.md b/docs/features/applications/README.md index 4900f7a..219790a 100644 --- a/docs/features/applications/README.md +++ b/docs/features/applications/README.md @@ -6,4 +6,44 @@ Applications (sometimes shortened to apps) are processes that open a window when ## Table of Contents -- [ Terminal](./terminal/README.md) \ No newline at end of file +- [ Terminal](./terminal/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() { + return ( +

Application interface goes here.

+ ) +} +``` + +### Turning a webpage into an application + +```js +// src/features/applications/applications.js + +export default class ApplicationsManager { + static APPLICATIONS = [ + // ... + new Application("Web App", "web-app", ), + ] + + // ... +} +``` \ No newline at end of file diff --git a/docs/features/applications/terminal/README.md b/docs/features/applications/terminal/README.md index f9d590e..316eba8 100644 --- a/docs/features/applications/terminal/README.md +++ b/docs/features/applications/terminal/README.md @@ -11,6 +11,8 @@ See [src/features/applications/terminal/commands.js](../../../../src/features/ap ### Examples ```js +// src/features/applications/terminal/commands.js + new Command("cd", (args, { currentDirectory, setCurrentDirectory }) => { const path = args[0] ?? "~"; // Default to home directory const destination = currentDirectory.navigate(path); diff --git a/docs/features/virtual-drive/README.md b/docs/features/virtual-drive/README.md index 3f1a65e..0159709 100644 --- a/docs/features/virtual-drive/README.md +++ b/docs/features/virtual-drive/README.md @@ -2,9 +2,26 @@ # Virtual Drive -The virtual drive is a virtual file and directory system. +The virtual drive is a virtual file and directory system. The root directory is a virtual folder and the access point for all interactions with the virtual drive. ## Table of Contents - [Virtual File](./virtual-file/README.md) - [Virtual Folder](./virtual-folder/README.md) + +## Examples + +### Component interacting with virtual drive + +```js +// src/components/applications/example/Example.jsx + +export function Example() { + const virtualRoot = useVirtualRoot(); + const [currentDirectory, setCurrentDirectory] = useState(virtualRoot.navigate("~")); + + currentDirectory.createFile("example", "txt", (file) => { + file.setContent("Foo bar."); + }); +} +``` \ No newline at end of file