diff --git a/pease-portfolio/src/app/page.js b/pease-portfolio/src/app/page.js index c8b9f20..38c6744 100644 --- a/pease-portfolio/src/app/page.js +++ b/pease-portfolio/src/app/page.js @@ -1,15 +1,12 @@ +"use client" + import Projects from "./projects.json" -import moment from "moment" import LinkedInIcon from '@mui/icons-material/LinkedIn'; import GitHubIcon from '@mui/icons-material/GitHub'; import EmailIcon from '@mui/icons-material/Email'; import Link from "next/link" -export async function generateMetadata() { - return { - title: 'Home | nicholaspease.com' - } -} +import { Terminal } from "../components/terminal.js" function AboutMe() { @@ -27,20 +24,8 @@ function AboutMe() { -
-
-            MOTD: This website is still under construction
- about@npease:~$ uname -a
-
- Hello! My name is Nicholas Pease and I am currently a junior at the University of Maine pursuing a bachelors degree in - Computer Science with a minor in Military Science. This website is a collection of both project / homework completed as - required by my studies and as a showcase of some of the personal projects I have worked on. I will work to keep this up - to date to the best of my ability.
-
- about@npease:~$ timedatectl --lastupdated
- This website was last updated on {moment().format("dddd, MMMM Do YYYY")}.
- about@npease:~$ -
+
+
@@ -69,6 +54,7 @@ function NotableProject({name}) { function ProjectsHome() { return (
+ Home | nicholaspease.com
Notable Projects
diff --git a/pease-portfolio/src/components/terminal.js b/pease-portfolio/src/components/terminal.js new file mode 100644 index 0000000..e961424 --- /dev/null +++ b/pease-portfolio/src/components/terminal.js @@ -0,0 +1,67 @@ +import { useEffect, useState } from "react"; +import moment from "moment" + +var commands = { + "uname -a": "Hello! My name is Nicholas Pease and I am currently a junior at the University of Maine pursuing a bachelors degree in Computer Science with a minor in Military Science. This website is a collection of both project / homework completed as required by my studies and as a showcase of some of the personal projects I have worked on. I will work to keep this up to date to the best of my ability. ", + "timedatectl": `This website was last updated on ${moment().format("dddd, MMMM Do YYYY")}.` +} + +function Command({command, result}) { + return ( +
+ about@npease:~$ {command}
+
+ {result? result: commands[command]}
+
+
+ ) +} + +export function Terminal() { + const [text, setText] = useState("") + const [history, setHistory] = useState([,]) + const handleKeyDown = event => { + event.preventDefault() + if (event.code == "Backspace") {setText(text.slice(0, -1))} + else if (event.code == "Enter") { + if (text == "clear") { + setHistory([]) + } else { + commands[text] != null? setHistory([...history, ]): `Command '${text.split(" ")[0]}' not found.` + } + setText("") + } + else if (event.code == "ArrowUp") {history.length>0? setText(history[history.length-1].props.command): ""} + else if (event.code == "ArrowDown") {setText("")} + else if (event.code == "Minus") {setText(text + "-")} + else if (isValidKey(event)) {setText(text + event.key)} + }; + return ( +
+
+                {history}
+                
+ about@npease:~$ {text} +
+
+
+ ) +} + +function isValidKey(event) { + const charCodes = [ + 'KeyA', 'KeyB', 'KeyC', 'KeyD', 'KeyE', 'KeyF', 'KeyG', 'KeyH', 'KeyI', 'KeyJ', + 'KeyK', 'KeyL', 'KeyM', 'KeyN', 'KeyO', 'KeyP', 'KeyQ', 'KeyR', 'KeyS', 'KeyT', + 'KeyU', 'KeyV', 'KeyW', 'KeyX', 'KeyY', 'KeyZ', + 'KeyA', 'KeyB', 'KeyC', 'KeyD', 'KeyE', 'KeyF', 'KeyG', 'KeyH', 'KeyI', 'KeyJ', + 'KeyK', 'KeyL', 'KeyM', 'KeyN', 'KeyO', 'KeyP', 'KeyQ', 'KeyR', 'KeyS', 'KeyT', + 'KeyU', 'KeyV', 'KeyW', 'KeyX', 'KeyY', 'KeyZ', + 'Digit0', 'Digit1', 'Digit2', 'Digit3', 'Digit4', 'Digit5', 'Digit6', 'Digit7', 'Digit8', 'Digit9', + 'Space' + ]; + if (charCodes.includes(event.code)) { + return true; + } else { + return false; + } +} \ No newline at end of file