-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
215 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,122 @@ | ||
"use client" | ||
import React from 'react'; | ||
import { useState, useRef, useEffect } from 'react'; | ||
import styles from '../css/terminal.module.css' | ||
import { ChevronRight, X, Minus, Square } from 'lucide-react'; | ||
|
||
|
||
const Terminal = () => { | ||
|
||
|
||
const banner = [ | ||
"██╗ ██╗███████╗██╗ ██████╗ ██████╗ ███╗ ███╗███████╗ ", | ||
"██║ ██║██╔════╝██║ ██╔════╝██╔═══██╗████╗ ████║██╔════╝ ", | ||
"██║ █╗ ██║█████╗ ██║ ██║ ██║ ██║██╔████╔██║█████╗ ", | ||
"██║███╗██║██╔══╝ ██║ ██║ ██║ ██║██║╚██╔╝██║██╔══╝ ", | ||
"╚███╔███╔╝███████╗███████╗╚██████╗╚██████╔╝██║ ╚═╝ ██║███████╗ ", | ||
" ╚══╝╚══╝ ╚══════╝╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝", | ||
"", | ||
"You can also check my social media:", | ||
"", | ||
"GitHub: AB10110F CodePen: AB10110F", | ||
"Twitter: AB10110F Reddit: AB10110F", | ||
"", | ||
"Type \"help\" to view the available commands" | ||
] | ||
|
||
const help = [ | ||
"This is the list of commands you can use: \n", | ||
"banner Displays the initial greeting", | ||
"help As you can see it shows a list of commands", | ||
"skills Displays the technologies I'm able to use", | ||
"info Shows all the information of the project", | ||
"cls Clears the content of the terminal", | ||
] | ||
|
||
const skills = [ | ||
"CSS [██████████████████▁▁▁▁▁▁] C++ [████████████████████▁▁▁▁]", | ||
"", | ||
"Typescript [█████████████▁▁▁▁▁▁▁▁▁▁] PHP [██████████████▁▁▁▁▁▁▁▁▁]", | ||
"", | ||
"React [███████████▁▁▁▁▁▁▁▁▁▁▁▁] Git [██████████████████▁▁▁▁▁▁]", | ||
|
||
] | ||
|
||
const info = [ | ||
"888b | 888~~ Y88b / ~~~888~~~", | ||
"|Y88b | 888___ Y88b / 888 ", | ||
"| Y88b | 888 Y88b/ 888 ", | ||
"| Y88b | 888 /Y88b 888 ", | ||
"| Y88b| 888 / Y88b 888 ", | ||
"| Y888 888___ / Y88b 888 ", | ||
"", | ||
"This project was built with Next.js 13", | ||
"The icons I used are the lucide-icons" | ||
] | ||
|
||
const preRef = useRef<HTMLDivElement>(null); | ||
const [input, setInput] = useState(""); | ||
const [output, setOutput] = useState(banner.join('\n')); | ||
|
||
useEffect(() => { | ||
if (preRef.current) { | ||
preRef.current.scrollTop = preRef.current.scrollHeight; | ||
} | ||
}, [output]); | ||
|
||
return ( | ||
<div>Prompt</div> | ||
<div ref={preRef} className={styles.terminal}> | ||
<section className={styles.windowOptions}> | ||
<article> | ||
<Minus /> | ||
<Square /> | ||
<X /> | ||
</article> | ||
</section> | ||
{<pre className={styles.history}>{output}</pre>} | ||
{/* <pre style={{ color: 'green' }}>{output}</pre>*/} | ||
<section className={styles.prompt}> | ||
<article>@guest from portfolio</article> | ||
<article className={styles.promptDown}> | ||
<ChevronRight /> | ||
<input | ||
type="text" | ||
value={input} | ||
onChange={e=>setInput(e.target.value)} | ||
onKeyDown={e=>{ | ||
let newOutput = ""; | ||
if (e.key === "Enter") | ||
{ | ||
newOutput = output + "\n\n@guest from portfolio\n" + "> " + input + "\n\n"; | ||
switch (input) | ||
{ | ||
case "banner": | ||
newOutput += banner.join('\n') | ||
break; | ||
case "help": | ||
newOutput += help.join('\n') | ||
break; | ||
case "skills": | ||
newOutput += skills.join('\n') | ||
break; | ||
case "info": | ||
newOutput += info.join('\n') | ||
break; | ||
case "cls": | ||
newOutput = "" | ||
break; | ||
default: | ||
newOutput += "x_x Syntax Error \"" + input + "\" is not a command" | ||
} | ||
setOutput(newOutput) | ||
setInput("") | ||
} | ||
}} | ||
/> | ||
</article> | ||
</section> | ||
</div> | ||
) | ||
} | ||
}; | ||
|
||
export default Terminal |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
.terminal | ||
{ | ||
height: 400px; | ||
width: 55%; | ||
background-color: rgb(26, 26, 26); | ||
color: white; | ||
box-sizing: border-box; | ||
font-size: 15px; | ||
overflow-y:auto; | ||
overflow-x: hidden; | ||
border: 1px solid rgb(26, 26, 26); | ||
} | ||
|
||
.windowOptions | ||
{ | ||
display: flex; | ||
justify-content: end; | ||
background-color: rgb(255, 255, 255); | ||
height: 30px; | ||
align-items: center; | ||
font-size: 15px; | ||
position: sticky; | ||
top: 0; | ||
} | ||
.windowOptions svg | ||
{ | ||
width: 25px; | ||
height: 30px; | ||
padding: 0 10px; | ||
color: rgb(142, 142, 142); | ||
} | ||
.windowOptions svg:nth-last-child(1):hover | ||
{ | ||
background-color: red; | ||
} | ||
|
||
.windowOptions svg:hover | ||
{ | ||
background-color: rgb(177, 177, 177); | ||
color: white; | ||
} | ||
|
||
.windowOptions article | ||
{ | ||
width: 110px; | ||
display: flex; | ||
} | ||
|
||
.terminal::-webkit-scrollbar{height: 10px; width: 8px;} | ||
.terminal::-webkit-scrollbar-thumb{background:#878787; border-radius: 50px;} | ||
|
||
.history | ||
{ | ||
padding: 0 10px; | ||
/* white-space: pre-wrap; | ||
word-wrap: break-word; */ | ||
width: 100%; | ||
color: rgb(214, 214, 214); | ||
} | ||
|
||
.prompt | ||
{ | ||
padding: 0 10px; | ||
} | ||
|
||
.promptDown | ||
{ | ||
display: flex; | ||
flex-direction: row; | ||
} | ||
|
||
.prompt svg{width: 15px;} | ||
|
||
.prompt input | ||
{ | ||
border: none; | ||
outline: none; | ||
width: 80%; | ||
background-color: transparent; | ||
color: white; | ||
/* margin-top: 10px */; | ||
font-size: 15px; | ||
} |