Skip to content

Commit cee45d0

Browse files
committed
Added button for reseting the current move to the Playground component
1 parent 6de861d commit cee45d0

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/CodeBreaker.Blazor.Client/Components/Playground.razor

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,13 @@
3535
}
3636
@if (i == 1 && !GameFinished)
3737
{
38-
<div>
38+
<div class="selectable-game-buttons">
3939
<FluentButton Appearance="Appearance.Stealth" Disabled="PlayButtonDisabled" OnClick="SetMoveAsync">
4040
<FluentIcon Value="new Icons.Filled.Size48.PlayCircle()" />
4141
</FluentButton>
42+
<FluentButton Appearance="Appearance.Stealth" Disabled="ClearButtonDisabled" OnClick="ResetMove">
43+
<FluentIcon Value="new Icons.Filled.Size48.DismissCircle()" />
44+
</FluentButton>
4245
</div>
4346
}
4447
else

src/CodeBreaker.Blazor.Client/Components/Playground.razor.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ AvailableColors is not null && field.Color is null
3535
|| AvailableShapes is not null && field.Shape is null
3636
);
3737

38+
private bool ClearButtonDisabled => _currentMove.All(field => field.Color is null && field.Shape is null);
39+
3840
private string KeyPegsFormat => Game.NumberCodes > 4 ? "three-two" : "two-two";
3941

4042
private IEnumerable<string>? AvailableColors => Game?.FieldValues.GetOrDefault("colors");
@@ -108,6 +110,9 @@ public async Task SetMoveAsync()
108110
}
109111
}
110112

113+
private void ResetMove() =>
114+
InitialzePlayground();
115+
111116
#region ClickEvents
112117
private void SelectField(int index)
113118
{

src/CodeBreaker.Blazor.Client/Components/Playground.razor.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@
111111
transition: background-color .5s ease-in-out;
112112
}
113113

114+
.game-container .game-row .selectable-game-buttons {
115+
width: unset;
116+
margin-left: -5px;
117+
}
118+
114119
.game-container .game-row div.key-pegs {
115120
width: calc(var(--game-field-width) - 4px);
116121
height: calc(var(--game-field-height) - 4px);

0 commit comments

Comments
 (0)