Skip to content

Commit 5d3ae85

Browse files
committed
Improve start menu responsive design
1 parent 479c05b commit 5d3ae85

File tree

7 files changed

+34
-24
lines changed

7 files changed

+34
-24
lines changed
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<div class="option-button">
22
<b style="width: @TextWidth" class="option-text">@Title</b>
3-
<button class="left-toggleButton toggleButton @LeftButtonClass" disabled="@IsDisabled" @onclick="SelectLeft">@LeftText</button>
4-
<button class="right-toggleButton toggleButton @RightButtonClass" disabled="@IsDisabled" @onclick="SelectRight">@RightText</button>
3+
<div class="buttons-container">
4+
<button class="left-toggleButton toggleButton @LeftButtonClass" disabled="@IsDisabled" @onclick="SelectLeft">@LeftText</button>
5+
<button class="right-toggleButton toggleButton @RightButtonClass" disabled="@IsDisabled" @onclick="SelectRight">@RightText</button>
6+
</div>
57
</div>
68

ChessChampion.Client/Components/ChooseOptionComponent.razor.css

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
.option-button {
22
display: flex;
33
align-items: center;
4+
justify-content: center;
5+
flex-wrap: wrap;
46
}
57

68
.option-text {
7-
text-align: right;
9+
margin-left: 2rem;
810
}
911

1012
.select {
1113
margin-left: 1rem;
1214
width: 10rem;
1315
}
1416

17+
.buttons-container {
18+
display: flex;
19+
align-items: center;
20+
}
21+
1522
.left-toggleButton {
1623
margin: 1rem 0 1rem 1rem;
1724
border-radius: 10px 0 0 10px;

ChessChampion.Client/Pages/Home.razor.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,21 @@ private async Task LeaveGame()
138138
if (ViewModel.GameId.HasValue && ViewModel.Player is not null && await JS.InvokeAsync<bool>("confirm", "Leave game?"))
139139
{
140140
Guid gameIdToLeave = ViewModel.GameId.Value;
141-
BaseError? error = await ChessService.LeaveGame(new LeaveGameRequest(gameIdToLeave, ViewModel.Player.Name));
141+
try
142+
{
143+
BaseError? error = await ChessService.LeaveGame(new LeaveGameRequest(gameIdToLeave, ViewModel.Player.Name));
144+
await Hub.LeaveGame(gameIdToLeave);
145+
ViewModel.StatusMessage = error.HasValue ? error.Value.Error : "You have left the game";
146+
}
147+
catch (Exception)
148+
{
149+
ViewModel.StatusMessage = "You have left the game";
150+
}
142151
ViewModel.GameState = null;
143152
ViewModel.GameId = null;
144153
ViewModel.Winner = null;
145154
ViewModel.OtherPlayer = null;
146155
ViewModel.GameCode = "";
147-
ViewModel.StatusMessage = error.HasValue ? error.Value.Error : "You have left the game";
148-
await Hub.LeaveGame(gameIdToLeave);
149156
}
150157
}
151158
}

ChessChampion.Server/Endpoints/EndpointsMapper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static async Task<Results<Ok<CreateGameResponse>, BadRequest<string>>> Cr
2222
Result<CreateGameResponse, BaseError> response = await chessService.CreateGame(createGameRequest);
2323
return response.Match<Results<Ok<CreateGameResponse>, BadRequest<string>>>(
2424
ok => TypedResults.Ok(ok),
25-
error => TypedResults.BadRequest(error.ToString())
25+
error => TypedResults.BadRequest(error.Error)
2626
);
2727
}
2828

@@ -31,7 +31,7 @@ public static async Task<Results<Ok<JoinGameResponse>, BadRequest<string>>> Join
3131
Result<JoinGameResponse, BaseError> response = await chessService.JoinGame(joinGameRequest);
3232
return response.Match<Results<Ok<JoinGameResponse>, BadRequest<string>>>(
3333
ok => TypedResults.Ok(ok),
34-
error => TypedResults.BadRequest(error.ToString())
34+
error => TypedResults.BadRequest(error.Error)
3535
);
3636
}
3737

ChessChampion.Server/Program.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,8 @@
2525

2626
app.MapStaticAssets();
2727
app.UseHttpLogging();
28-
if (app.Environment.IsProduction())
29-
{
30-
app.UseMiddleware<SecurityHeadersMiddleware>();
31-
}
3228
app.UseAntiforgery();
3329
app.UseRateLimiter();
34-
app.MapStaticAssets();
3530
app.MapEndpoints();
3631
app.MapHub<ChessHub>("/chesshub", options => options.AllowStatefulReconnects = true);
3732
app.MapRazorComponents<App>()

ChessChampion.Server/wwwroot/app.css

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,28 @@ a, .btn-link {
3030

3131

3232
.btn {
33-
border-radius: 5px;
34-
border: 2px solid gray;
35-
margin: 5px;
33+
border-radius: 0.5rem;
34+
border: none;
3635
font-size: 16px;
3736
padding: 6px 10px;
3837
white-space: nowrap;
38+
width: 130px;
39+
min-height: 50px;
3940
}
4041

41-
.btn :focus {
42-
border-color: black;
43-
outline: none;
44-
}
42+
4543

4644
.btn-primary {
47-
background-color: rgb(70, 148, 225);
45+
background-color: rgb(30, 121, 255);
46+
color: white;
4847
}
4948

5049
.btn-primary:hover {
5150
background-color: #1F7EC7;
52-
color: white;
5351
}
5452

5553
.btn-primary:active {
56-
background-color: blue;
54+
background-color: rgb(30, 94, 255);
5755
}
5856

5957
.valid.modified:not([type=checkbox]) {

ChessChampionWebUI/wwwroot/site.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ a, .btn-link {
4444
}
4545

4646
.btn-primary {
47-
background-color: rgb(70, 148, 225);
47+
background-color: rgb(30, 121, 255);
48+
color: white;
4849
}
4950

5051
.btn-primary:hover {

0 commit comments

Comments
 (0)