prompt v1

This commit is contained in:
JuliusHerrmann 2022-02-23 02:02:54 +01:00
parent ba39aebbb2
commit b95720e7f1
7 changed files with 71 additions and 58 deletions

View File

@ -1,38 +0,0 @@
.App {
text-align: center;
}
.App-logo {
height: 40vmin;
pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}
.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
.App-link {
color: #61dafb;
}
@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

View File

@ -1,24 +1,9 @@
import logo from './logo.svg';
import './App.css'; import './App.css';
import CommandLineManager from './commandline/CommandLineManager';
function App() { function App() {
return ( return (
<div className="App"> <CommandLineManager/>
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
); );
} }

View File

@ -0,0 +1,9 @@
function CommandLineEntry() {
const text = "This is just a test\n breakline\t tab"
return(
<p>This is a test<br/> breakline </p>
);
}
export default CommandLineEntry;

View File

@ -0,0 +1,27 @@
import {useState} from 'react';
import CommandLineEntry from './CommandLineEntry.jsx';
import Prompt from './Prompt.jsx';
function CommandLineManager() {
const [input, setInput] = useState("");
const updateInput = (e) => {
setInput(e.target.value);
}
const submitInput = (e) => {
//check if enter was pressed
if (e.keyCode === 13) {
console.log(input);
}
}
return(
<div id="commandLineManager">
<CommandLineEntry/>
<Prompt input={input} updateInput={updateInput} submitInput={submitInput}/>
</div>
);
}
export default CommandLineManager;

View File

@ -0,0 +1,12 @@
#ps1 {
display: inline;
}
#promptInput {
display: inline;
border: none;
outline: none;
width: 70%;
padding: 0;
font-size: 10pt;
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
}

View File

@ -0,0 +1,13 @@
import './Prompt.css';
function Prompt(props) {
return(
<div className="Prompt">
<p id="ps1">visitor@julius $ </p>
<input id="promptInput" type="text" autoFocus={true} maxLength={20}
value={props.input} onChange={props.updateInput} onKeyDown={props.submitInput}/>
</div>
);
}
export default Prompt;

View File

@ -1,8 +1,13 @@
html {
margin: 0;
padding: 0;
height: 100vh;
width: 100vw;
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
font-size: 9pt;
}
body { body {
margin: 0; margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
} }