Updated docs with examples
This commit is contained in:
parent
80f6e8ea80
commit
e905b2b3ca
3 changed files with 61 additions and 2 deletions
|
|
@ -6,4 +6,44 @@ Applications (sometimes shortened to apps) are processes that open a window when
|
||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
|
|
||||||
- [<img src="../../../public/media/applications/icons/terminal.svg" width=20 height=20 style="vertical-align: middle; background: none;"/> Terminal](./terminal/README.md)
|
- [<img src="../../../public/media/applications/icons/terminal.svg" width=20 height=20 style="vertical-align: middle; background: none;"/> 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", <Example/>),
|
||||||
|
]
|
||||||
|
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
|
||||||
|
// src/components/applications/example/Example.jsx
|
||||||
|
|
||||||
|
export function Example() {
|
||||||
|
return (
|
||||||
|
<p>Application interface goes here.</p>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Turning a webpage into an application
|
||||||
|
|
||||||
|
```js
|
||||||
|
// src/features/applications/applications.js
|
||||||
|
|
||||||
|
export default class ApplicationsManager {
|
||||||
|
static APPLICATIONS = [
|
||||||
|
// ...
|
||||||
|
new Application("Web App", "web-app", <WebView source="https://prozilla.dev/"/>),
|
||||||
|
]
|
||||||
|
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
@ -11,6 +11,8 @@ See [src/features/applications/terminal/commands.js](../../../../src/features/ap
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
// src/features/applications/terminal/commands.js
|
||||||
|
|
||||||
new Command("cd", (args, { currentDirectory, setCurrentDirectory }) => {
|
new Command("cd", (args, { currentDirectory, setCurrentDirectory }) => {
|
||||||
const path = args[0] ?? "~"; // Default to home directory
|
const path = args[0] ?? "~"; // Default to home directory
|
||||||
const destination = currentDirectory.navigate(path);
|
const destination = currentDirectory.navigate(path);
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,26 @@
|
||||||
|
|
||||||
# Virtual Drive
|
# 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
|
## Table of Contents
|
||||||
|
|
||||||
- [Virtual File](./virtual-file/README.md)
|
- [Virtual File](./virtual-file/README.md)
|
||||||
- [Virtual Folder](./virtual-folder/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.");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
```
|
||||||
Loading…
Reference in a new issue