diff --git a/src/components/react/fs.ts b/src/components/react/fs.ts new file mode 100644 index 0000000..fead9dc --- /dev/null +++ b/src/components/react/fs.ts @@ -0,0 +1,17 @@ +const user = { + ["about_me"]: {}, + ["services"]: {} +} +const home = { + ["user"]: user +} +const root = { + ["bin"]: {}, + ["home"]: {} +} + +const fs = { + ["/"]: root +} + +export { fs } \ No newline at end of file diff --git a/src/components/react/shell.tsx b/src/components/react/shell.tsx new file mode 100644 index 0000000..6b27fcf --- /dev/null +++ b/src/components/react/shell.tsx @@ -0,0 +1,45 @@ +import { TermEvents } from "./terminal" + +let working_fs_dir = "user" +function GetWorkingDir(): string { + if (working_fs_dir === "user") { + return "~" + } + return working_fs_dir +} + +function ls() { + +} + +function Prompt() { + const cyan_user = user + const green_dir = {GetWorkingDir()} + return

{cyan_user}@host {green_dir}{"> "}

+} + +function ShellEvents() { + const shell_input = document.getElementById("shell-input") + if (shell_input) { + shell_input.addEventListener("keydown", (keyboard_event) => { + if (keyboard_event.key === "Enter") { + console.log("woah its the enter key") + } + }) + } +} + +function ShellPrompt() { + return
+ + +
+} + +export default function Shell() { + const shell_prompt = ShellPrompt() + TermEvents() + ShellEvents() + + return shell_prompt +} \ No newline at end of file diff --git a/src/components/react/terminal.ts b/src/components/react/terminal.ts new file mode 100644 index 0000000..351c920 --- /dev/null +++ b/src/components/react/terminal.ts @@ -0,0 +1,10 @@ +const terminal_window = document.querySelector("main"); + +export function TermEvents() { + if (terminal_window) { + terminal_window.addEventListener("click", (_event) => { + const shell_input = document.getElementById("shell-input") + if (shell_input) { shell_input.focus() } + }) + } +} \ No newline at end of file