prompt v1
This commit is contained in:
parent
ba39aebbb2
commit
b95720e7f1
38
src/App.css
38
src/App.css
@ -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);
|
||||
}
|
||||
}
|
||||
19
src/App.js
19
src/App.js
@ -1,24 +1,9 @@
|
||||
import logo from './logo.svg';
|
||||
import './App.css';
|
||||
import CommandLineManager from './commandline/CommandLineManager';
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<div className="App">
|
||||
<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>
|
||||
<CommandLineManager/>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
9
src/commandline/CommandLineEntry.jsx
Normal file
9
src/commandline/CommandLineEntry.jsx
Normal 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;
|
||||
27
src/commandline/CommandLineManager.jsx
Normal file
27
src/commandline/CommandLineManager.jsx
Normal 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;
|
||||
12
src/commandline/Prompt.css
Normal file
12
src/commandline/Prompt.css
Normal 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;
|
||||
}
|
||||
13
src/commandline/Prompt.jsx
Normal file
13
src/commandline/Prompt.jsx
Normal 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;
|
||||
@ -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 {
|
||||
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;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user