Skip to content

Commit

Permalink
click to start
Browse files Browse the repository at this point in the history
  • Loading branch information
erinnmclaughlin committed Nov 24, 2023
1 parent a0fe14d commit 7596bda
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
14 changes: 7 additions & 7 deletions PersonalWebsite/Components/StartupProgram.razor
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@if (!IsRunningProgram)
@if (CurrentState is not State.Running)
{
<div class="history">
<TerminalCommands Commands="Commands" OnComplete="OnCommandsCompleted" />

@if (IsBuilding)
@if (CurrentState is State.Building)
{
<p>Building...</p>
}
Expand All @@ -29,15 +29,15 @@ else
"dotnet run"
};

private bool IsBuilding { get; set; } = false;
private bool IsRunningProgram { get; set; } = false;
private State CurrentState { get; set; } = State.EnteringCommands;

private async Task OnCommandsCompleted()
{
IsBuilding = true;
CurrentState = State.Building;
await Task.Delay(2000);

IsBuilding = false;
IsRunningProgram = true;
CurrentState = State.Running;
}

enum State { EnteringCommands, Building, Running }
}
15 changes: 9 additions & 6 deletions PersonalWebsite/Components/TerminalCommands.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@

@if (!IsAnimating && ExecutedCommandCount != Commands.Length)
{
<div>> <TerminalCursor /></div>
<button id="start" type="button" @onclick="Start">> <TerminalCursor /></button>
}

@code {

private bool IsAnimating { get; set; } = false;
private int ExecutedCommandCount { get; set; } = 0;

[Parameter] public required string[] Commands { get; set; }
[Parameter] public EventCallback OnComplete { get; set; }
[Parameter]
public required string[] Commands { get; set; }

protected override async Task OnInitializedAsync()
[Parameter]
public EventCallback OnComplete { get; set; }

private void Start()
{
await Task.Delay(2000);
await AnimateNextCommand();
IsAnimating = true;
ExecutedCommandCount++;
}

private async Task AnimateNextCommand()
Expand Down
12 changes: 12 additions & 0 deletions PersonalWebsite/Components/TerminalCommands.razor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#start {
background: unset;
color: unset;
font-family: unset;
cursor: pointer;
margin-right: auto;
border: 0;
}

#start:hover {
color: lime;
}

0 comments on commit 7596bda

Please sign in to comment.