Skip to content

Commit

Permalink
terminal-component-V1
Browse files Browse the repository at this point in the history
  • Loading branch information
AB10110F committed Jul 15, 2023
1 parent ba098ac commit 75e0cce
Show file tree
Hide file tree
Showing 6 changed files with 215 additions and 6 deletions.
13 changes: 11 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@types/react-dom": "18.2.4",
"eslint": "8.41.0",
"eslint-config-next": "13.4.4",
"lucide-react": "^0.260.0",
"next": "13.4.4",
"p5": "^1.6.0",
"react": "18.2.0",
Expand Down
7 changes: 5 additions & 2 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import './globals.css'
/* import './globals.css'*/
import { Inter } from 'next/font/google'

import Terminal from '@/components/Terminal'
import Dots from '@/components/Dots'
const inter = Inter({ subsets: ['latin'] })

export const metadata = {
Expand All @@ -16,6 +17,8 @@ export default function RootLayout({
return (
<html lang="en">
<body className={inter.className}>
<Terminal/>
<Dots/>
{children}
</body>
</html>
Expand Down
117 changes: 115 additions & 2 deletions src/components/Terminal.tsx
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.
83 changes: 83 additions & 0 deletions src/css/terminal.module.css
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;
}

0 comments on commit 75e0cce

Please sign in to comment.