diff --git a/src/app/term/page.tsx b/src/app/term/page.tsx index 4dcac02..29132de 100644 --- a/src/app/term/page.tsx +++ b/src/app/term/page.tsx @@ -2,7 +2,7 @@ import About from '@/components/About'; import { Contact } from '@/components/Contact'; -import Experience from '@/components/Experince'; +import Experience from '@/components/Experience'; import Projects from '@/components/Projects'; import React, { useState, useEffect, useRef } from 'react'; @@ -15,12 +15,10 @@ export default function Home() { ]); const [suggestion, setSuggestion] = useState(''); const inputRef = useRef(null); - const keyAudio = useRef(null); const enterAudio = useRef(null); useEffect(() => { - // Load the key press sound keyAudio.current = new Audio('/key.mp3'); keyAudio.current.volume = 0.1; enterAudio.current = new Audio('/enter.mp3'); @@ -42,7 +40,6 @@ export default function Home() { const { value } = e.target; setInput(value); - // Generate suggestion only if 3 or more characters are entered if (value.trim().length < 3) { setSuggestion(''); return; @@ -51,131 +48,58 @@ export default function Home() { const matchedCommand = commands.find((command) => command.startsWith(value.trim().toLowerCase()), ); - setSuggestion(matchedCommand ? matchedCommand : ''); + setSuggestion(matchedCommand || ''); }; - function processCommand(command: string) { + const processCommand = (command: string) => { switch (command.trim().toLowerCase()) { case 'help': setOutput((prevOutput) => [ ...prevOutput, 'Available commands (click to autocomplete):', -
- - {' - Display this help message'} -
, -
- - {' - Learn more about Sticks and his projects'} -
, -
- - {' - List of projects created by Sticks'} -
, -
- - {" - View Sticks's experience and past positions"} -
, -
- - {' - Get in touch with Sticks'} -
, -
- - {' - Return to the home page'} -
, -
- - {' - Clear the screen'} -
, + createCommandButton( + 'help', + 'Help (this command) - List available commands', + ), + createCommandButton( + 'about', + 'About - Learn more about Sticks and his projects', + ), + createCommandButton( + 'projects', + 'Projects - List of projects created by Sticks', + ), + createCommandButton( + 'experience', + "Experience - View Sticks's experience", + ), + createCommandButton( + 'contact', + 'Contact - Get in touch with Sticks', + ), + createCommandButton( + 'back', + 'Back - Return to the home page', + ), + createCommandButton('clear', 'Clear - Clear the screen'), ]); break; case 'about': setOutput((prevOutput) => [ ...prevOutput, -
- -
, + , ]); break; - case 'projects': setOutput((prevOutput) => [ ...prevOutput, -
- -
, + , ]); break; case 'experience': setOutput((prevOutput) => [ ...prevOutput, -
- -
, + , ]); break; case 'back': @@ -184,9 +108,7 @@ export default function Home() { case 'contact': setOutput((prevOutput) => [ ...prevOutput, -
- -
, + , ]); break; case 'clear': @@ -199,41 +121,59 @@ export default function Home() { default: setOutput((prevOutput) => [ ...prevOutput, -
- Error: Bad command - or file name: {command} +
+ Error:{' '} + + {command} is not a valid command or batch file. +
, ]); - break; } - } + }; const handleCommandInput = (e: React.KeyboardEvent) => { if (e.key === 'Enter') { enterAudio.current?.play(); setOutput((prevOutput) => [...prevOutput, `S:\\> ${input}.exe`]); processCommand(input); - setInput(''); // Clear the input - setSuggestion(''); // Clear the suggestion + setInput(''); + setSuggestion(''); } else if (e.key === 'Tab' && suggestion) { + e.preventDefault(); keyAudio.current?.play(); - e.preventDefault(); // Prevent the default tab behavior - setInput(suggestion); // Set input to the full suggestion - setSuggestion(''); // Clear the suggestion + setInput(suggestion); + setSuggestion(''); } else if (e.key === 'Escape') { keyAudio.current?.play(); - setInput(''); // Clear the input - setSuggestion(''); // Clear the suggestion + setInput(''); + setSuggestion(''); } else { keyAudio.current?.play(); } }; - // Adjustments to the component + const createCommandButton = (command: string, label: string) => ( +
+ +
+ ); + return (
- {/* Back Link */} < Back diff --git a/src/components/Experince.tsx b/src/components/Experience.tsx similarity index 100% rename from src/components/Experince.tsx rename to src/components/Experience.tsx diff --git a/src/components/Projects.tsx b/src/components/Projects.tsx index d29a432..c0d9e37 100644 --- a/src/components/Projects.tsx +++ b/src/components/Projects.tsx @@ -26,9 +26,6 @@ export default function Projects() { const maxDescriptionLength = Math.max( ...projects.map((project) => project.description.length), ); - const maxLinkLength = Math.max( - ...projects.map((project) => project.link.length), - ); // Step 2: Prepare projects with padded strings for rendering const preparedProjects = projects.map((project) => ({ @@ -41,13 +38,20 @@ export default function Projects() {

--- Reading database projects.db ---

- Found {projects.length} projects in database. Displaying all projects: + Found {projects.length} projects in database. Displaying all + projects:

{preparedProjects.map((project, index) => (

{project.title}

 |

 {project.description}

| -  {project.link} + +  {project.link} +
))}