Skip to content

Commit

Permalink
show instructions sooner
Browse files Browse the repository at this point in the history
  • Loading branch information
erinnmclaughlin committed Nov 24, 2023
1 parent 5b08f66 commit 56de51a
Showing 1 changed file with 12 additions and 24 deletions.
36 changes: 12 additions & 24 deletions PersonalWebsite/Components/TerminalCommands.razor
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
@if (CurrentState is State.Waiting)
{
<button id="start" type="button" aria-label="start" @onclick="Start">

@if (ShowInstructions)
{
<div id="mobile-instructions">
<span id="mobile-instructions">
<TerminalCommand Command="Tap to start" />
</div>
<div id="desktop-instructions">
</span>
<span id="desktop-instructions">
<TerminalCommand Command="Click to start" />
</div>
</span>
}
else
{
<span>> <TerminalCursor /></span>
<span>> <TerminalCursor /></span>
}
</button>
}
Expand All @@ -39,11 +38,6 @@ else

@code {

private readonly System.Timers.Timer _timer = new()
{
Interval = 5_000
};

private State CurrentState { get; set; } = State.Waiting;

private bool IsTyping { get; set; }
Expand All @@ -58,20 +52,14 @@ else
[Parameter]
public EventCallback OnComplete { get; set; }

protected override void OnInitialized()
{
_timer.Elapsed += TriggerInstructions;
_timer.Start();
}

private void TriggerInstructions(object? o, EventArgs e)
protected override async Task OnAfterRenderAsync(bool firstRender)
{
_timer.Stop();
_timer.Elapsed -= TriggerInstructions;
_timer.Dispose();

ShowInstructions = true;
StateHasChanged();
if (firstRender)
{
await Task.Delay(1500);
ShowInstructions = true;
StateHasChanged();
}
}

private async Task OnCommandCompleted()
Expand Down

0 comments on commit 56de51a

Please sign in to comment.