Skip to content

Commit

Permalink
Terminal is now functioning (The styling and submitting) working on c…
Browse files Browse the repository at this point in the history
…ommands working soon.
  • Loading branch information
Oia20 committed Apr 23, 2024
1 parent 2141f1e commit 793b4f3
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 2 deletions.
8 changes: 6 additions & 2 deletions CropSQL/Pages/Components/Home.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
<WelcomeModal />
<Header />
<div class="container123">
<SideBarNav />
<Prompt />
<SideBarNav />
<div class="container1234">
<Prompt />
<Terminal />
</div>
</div>

6 changes: 6 additions & 0 deletions CropSQL/Pages/Components/Home.razor.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@
display: flex;
flex-direction: row;
width: 100%
}

.container1234 {
display: flex;
flex-direction: column;
width: 100%
}
2 changes: 2 additions & 0 deletions CropSQL/Pages/Components/Prompt.razor.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@
margin:auto;
margin-top: 5px;
margin-bottom:5px;
color: #f4d35d;
font-size: 1.2em;
}
42 changes: 42 additions & 0 deletions CropSQL/Pages/Components/Terminal.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
@inject IJSRuntime JSRuntime

<div class="terminal">
<div class="output" @ref="outputRef">
@foreach (var line in terminalOutput)
{
<div class="outText">@line</div>
}
</div>
<input type="text" @ref="inputRef" placeholder="CropSQL> Add Commands Here" @bind="currentInput" @onkeydown="HandleInput"/>
</div>

@code {
private List<string> terminalOutput = new List<string>();
private string currentInput = "";

private ElementReference outputRef;
private ElementReference inputRef;

private async Task HandleInput(KeyboardEventArgs e)
{
if (e.Key == "Enter")
{
// Get the value of the input field using JavaScript interop
currentInput = await JSRuntime.InvokeAsync<string>("getInputValue", inputRef);

ExecuteCommand(currentInput);
currentInput = ""; // Clear the input field
}
}

private void ExecuteCommand(string command)
{
// Process command here
// For demonstration purposes, just echo back the command
terminalOutput.Add("CropSQL> " + command);
terminalOutput.Add("Result: " + command);

// Notify Blazor that the component's state has changed
StateHasChanged();
}
}
48 changes: 48 additions & 0 deletions CropSQL/Pages/Components/Terminal.razor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* Terminal.razor.css */
.terminal {
font-family: monospace;
border: 1px solid #ccc;
padding: 10px;
width: 400px;
display: flex;
flex-direction: column;

background-image: linear-gradient(140deg, #a2b780, #5e8d61);
padding: 20px;
border-radius: 12px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.5); /* Increased shadow */
border: 2px solid #5e8d61; /* Solid border */
margin: 5px;
width:80%;
height:fit-content;
margin:auto;
margin-top: 5px;
margin-bottom:5px;
height:70%
}

.output {
min-height: 60%;
max-height: 70%;
overflow-y: auto;
border-bottom: 1px solid #ccc;
margin-bottom: 10px;
background-color: rgba(46, 121, 56, 0.226);
border: 2px solid #e8a073; /* Solid border */
color: #f4d35d;

}

input[type="text"] {
width: 100%;
box-sizing: border-box;
padding: 5px;
background-color: rgba(46, 121, 56, 0.226);
border: 2px solid #e8a073; /* Solid border */
color: #f4d35d;
}

.outText {
margin:2px;
margin-left: 5px;
}
6 changes: 6 additions & 0 deletions CropSQL/wwwroot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
<a class="dismiss">🗙</a>
</div>
<script src="_framework/blazor.webassembly.js"></script>
<script>
window.getInputValue = function(inputRef) {
return inputRef.value;
}
</script>

</body>

</html>

0 comments on commit 793b4f3

Please sign in to comment.