Skip to content

Commit 0e5b6f1

Browse files
committed
Upgrade MudBlazor
1 parent 50e3720 commit 0e5b6f1

8 files changed

Lines changed: 49 additions & 47 deletions

File tree

src/BF2WebAdmin.Blazor/BF2WebAdmin.Blazor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="9.0.4" />
1515
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.Json" Version="9.0.4" />
1616
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="9.0.4" />
17-
<PackageReference Include="MudBlazor" Version="6.0.19-dev1" />
17+
<PackageReference Include="MudBlazor" Version="8.6.0" />
1818
</ItemGroup>
1919

2020
<ItemGroup>

src/BF2WebAdmin.Blazor/Pages/Index.razor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
</CardHeaderActions>
4949
</MudCardHeader>
5050
<MudCardContent>
51-
<MudChip Size="Size.Small">@server.GameState</MudChip>
52-
<MudChip Size="Size.Small">@server.Map</MudChip>
53-
<MudChip Size="Size.Small">@server.Players / @server.MaxPlayers players</MudChip>
51+
<MudChip T="string" Size="Size.Small">@server.GameState</MudChip>
52+
<MudChip T="string" Size="Size.Small">@server.Map</MudChip>
53+
<MudChip T="string" Size="Size.Small">@server.Players / @server.MaxPlayers players</MudChip>
5454
</MudCardContent>
5555
</MudCard>
5656
</MudLink>

src/BF2WebAdmin.Blazor/Pages/Server.razor

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@
2828
</div>
2929

3030
<div class="mb-8">
31-
<MudChip Icon="@(_socketState == SocketState.Connected ? Icons.Material.Filled.Circle : Icons.Material.Filled.StopCircle)"
31+
<MudChip T="string" Icon="@(_socketState == SocketState.Connected ? Icons.Material.Filled.Circle : Icons.Material.Filled.StopCircle)"
3232
IconColor="@(_socketState == SocketState.Connected ? Color.Success : Color.Error)">
3333
@_socketState
3434
</MudChip>
35-
<MudChip>@_gameState</MudChip>
36-
<MudChip>@_ipAddress:@_gamePort (@_queryPort)</MudChip>
37-
<MudChip>@_map</MudChip>
38-
<MudChip>@_currentPlayers / @_maxPlayers players</MudChip>
39-
<MudChip>
35+
<MudChip T="string">@_gameState</MudChip>
36+
<MudChip T="string">@_ipAddress:@_gamePort (@_queryPort)</MudChip>
37+
<MudChip T="string">@_map</MudChip>
38+
<MudChip T="string">@_currentPlayers / @_maxPlayers players</MudChip>
39+
<MudChip T="string">
4040
<MudLink Variant="Variant.Text" Color="Color.Info" Href="@("/servergroup/" + _serverGroup)">@_serverGroup</MudLink>
4141
</MudChip>
4242
</div>
@@ -96,7 +96,7 @@
9696
<MudTabs Position="Position.Top" Outlined="true" @bind-ActivePanelIndex="ActiveTabIndex">
9797

9898
<MudTabPanel Text="Chat" Icon="@Icons.Material.Filled.Chat" Style="width: 50px">
99-
<ul id="chatlog" class="px-4 py-4" style="overflow-y: scroll; height: 500px; max-height: 500px;">
99+
<ul id="chatlog" class="px-4 py-4" style="overflow-y: scroll; height: 500px; max-height: 500px; list-style: none;">
100100
@foreach (var chat in _chatLog)
101101
{
102102
<li @key="chat.Message.Id" class="@GetChatClass(chat.Message)">
@@ -150,7 +150,7 @@
150150
</MudTabPanel>
151151

152152
<MudTabPanel Text="Events" Icon="@Icons.Material.Filled.Bolt">
153-
<ul id="eventlog" class="px-4 py-4" style="overflow-y: scroll; height: 350px; max-height: 350px;">
153+
<ul id="eventlog" class="px-4 py-4" style="overflow-y: scroll; height: 350px; max-height: 350px; list-style: none;">
154154
@foreach (var gameEvent in _eventLog)
155155
{
156156
<li @key="gameEvent.Id">@GetTimestamp(gameEvent.Timestamp) @gameEvent.Message</li>
@@ -159,7 +159,7 @@
159159
</MudTabPanel>
160160

161161
<MudTabPanel Text="Requests" Icon="@Icons.Material.Filled.DoubleArrow">
162-
<ul id="requestlog" class="px-4 py-4" style="overflow-y: scroll; height: 350px; max-height: 350px;">
162+
<ul id="requestlog" class="px-4 py-4" style="overflow-y: scroll; height: 350px; max-height: 350px; list-style: none;">
163163
@foreach (var request in _requestResponses)
164164
{
165165
<li class="mb-4">
@@ -182,7 +182,7 @@
182182
DisableUnderLine="true"
183183
Variant="Variant.Outlined"
184184
Margin="Margin.Dense"
185-
OnKeyPress="OnKeyPress"/>
185+
OnKeyDown="OnKeyDown"/>
186186
}
187187
</MudPaper>
188188
</MudItem>
@@ -462,7 +462,7 @@
462462
}
463463

464464
StateHasChanged();
465-
var scrolled = await _jsRuntime.InvokeAsync<bool>("ScrollToBottom", "requestlog", true);
465+
await _jsRuntime.InvokeVoidAsync("ScrollToBottom", "requestlog", true);
466466
})
467467
};
468468
}
@@ -635,7 +635,7 @@
635635
_snapshotReceived = false;
636636
}
637637

638-
var scrolled = await _jsRuntime.InvokeAsync<bool>("ScrollToBottom", tabId, force);
638+
await _jsRuntime.InvokeVoidAsync("ScrollToBottom", tabId, force);
639639
}
640640

641641
public async ValueTask DisposeAsync()
@@ -658,7 +658,7 @@
658658
}
659659
}
660660

661-
private async void OnKeyPress(KeyboardEventArgs e)
661+
private async void OnKeyDown(KeyboardEventArgs e)
662662
{
663663
var isEnter = e.Code is "Enter" or "NumpadEnter";
664664
if (!isEnter)
@@ -685,7 +685,7 @@
685685
var dialog = _dialogService.Show<InputDialog>(text, parameters, new DialogOptions { });
686686
var result = await dialog.Result;
687687

688-
if (!result.Cancelled)
688+
if (!result.Canceled)
689689
{
690690
callback?.Invoke(result.Data.ToString());
691691
}

src/BF2WebAdmin.Blazor/Pages/ServerGroup.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ else
1919
<MudText Typo="Typo.h5" Class="mb-8">Modules</MudText>
2020

2121
<MudPaper MaxWidth="500px">
22-
<MudList Clickable="true">
22+
<MudList T="MudListItem<string>" Clickable="true">
2323
@foreach (var moduleName in _allModuleNames)
2424
{
25-
<MudListItem OnClick="() => ToggleModule(moduleName)" Disabled="@(_defaultModuleNames.Contains(moduleName) || ServerGroupName == "default")" Icon="@(_activeModuleNames.Contains(moduleName) ? Icons.Filled.CheckBox : Icons.Filled.CheckBoxOutlineBlank)" IconColor="Color.Primary" Text="@moduleName">
25+
<MudListItem T="string" OnClick="() => ToggleModule(moduleName)" Disabled="@(_defaultModuleNames.Contains(moduleName) || ServerGroupName == "default")" Icon="@(_activeModuleNames.Contains(moduleName) ? Icons.Material.Filled.CheckBox : Icons.Material.Filled.CheckBoxOutlineBlank)" IconColor="Color.Primary" Text="@moduleName">
2626
@* <MudIcon Icon="@(_activeModuleNames.Contains(moduleName) ? Icons.Filled.Check : Icons.Filled.CheckBox)" Color="Color.Success"/> *@
2727
@* <MudText>@moduleName</MudText> *@
2828
@* <MudCheckBox OnClick="() => ToggleModule(moduleName)" Checked="_activeModuleNames.Contains(moduleName)" Style="display: inline-block" Label="@moduleName" StopClickPropagation="false"></MudCheckBox> *@

src/BF2WebAdmin.Blazor/Shared/ConfirmDialog.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@code {
1212

1313
[CascadingParameter]
14-
MudDialogInstance MudDialog { get; set; }
14+
IMudDialogInstance MudDialog { get; set; }
1515

1616
[Parameter]
1717
public string ContentText { get; set; }

src/BF2WebAdmin.Blazor/Shared/InputDialog.razor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</TitleContent>
77

88
<DialogContent>
9-
<MudTextField @bind-Value="TextValue" Immediate="true" Label="@placeholder" OnKeyPress="OnKeyPress" AutoFocus="true"/>
9+
<MudTextField @bind-Value="TextValue" Immediate="true" Label="@placeholder" OnKeyDown="OnKeyDown" AutoFocus="true"/>
1010
</DialogContent>
1111

1212
<DialogActions>
@@ -18,7 +18,7 @@
1818
@code {
1919

2020
[CascadingParameter]
21-
MudDialogInstance MudDialog { get; set; }
21+
IMudDialogInstance MudDialog { get; set; }
2222

2323
[Parameter]
2424
public Action<string> callback { get; set; }
@@ -36,7 +36,7 @@
3636

3737
private MudButton _sendButton;
3838

39-
private async void OnKeyPress(KeyboardEventArgs e)
39+
private async void OnKeyDown(KeyboardEventArgs e)
4040
{
4141
var isEnter = e.Code is "Enter" or "NumpadEnter";
4242
if (!isEnter)

src/BF2WebAdmin.Blazor/Shared/MainLayout.razor

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
@inherits LayoutComponentBase
22

3-
<MudThemeProvider Theme="_currentTheme"/>
3+
<MudThemeProvider Theme="_currentTheme" IsDarkMode="true"/>
4+
<MudPopoverProvider/>
45
<MudDialogProvider/>
56
<MudSnackbarProvider/>
67

78
<MudLayout>
89
<MudAppBar Elevation="0">
9-
<MudIconButton Icon="@Icons.Material.Filled.Menu" Color="Color.Inherit" Edge="Edge.Start" OnClick="@((e) => DrawerToggle())"/>
10+
<MudIconButton Icon="@Icons.Material.Filled.Menu" Color="Color.Inherit" Edge="Edge.Start"
11+
OnClick="@((e) => DrawerToggle())"/>
1012
<MudSpacer/>
1113

1214
@if (_adminService.IsAuthenticated)
@@ -48,13 +50,13 @@
4850
private readonly MudTheme _darkTheme = new()
4951
{
5052
// Official https://github.com/MudBlazor/MudBlazor/blob/4ab9e29ff5ad25c4c1aba62577c487637331e781/src/MudBlazor/Themes/Models/Palette.cs
51-
Palette = new Palette
53+
PaletteDark = new PaletteDark
5254
{
5355
Primary = "#0bba83", // custom green
5456
// Primary = "#776be7", // default purple
5557
Black = "#27272f",
5658
Background = "#32333d",
57-
BackgroundGrey = "#27272f",
59+
BackgroundGray = "#27272f",
5860
Surface = "#373740",
5961
DrawerBackground = "#27272f",
6062
DrawerText = "rgba(255,255,255, 0.50)",
@@ -79,24 +81,24 @@
7981
Dark = "#27272f"
8082
}
8183

82-
// Alt. https://github.com/aksoftware98/mudblazorsample/blob/main/MudBlazorSample/MudBlazorSample/Shared/MainLayout.razor
83-
//Palette = new Palette
84-
//{
85-
// Black = "#27272f",
86-
// Background = "#32333d",
87-
// BackgroundGrey = "#27272f",
88-
// Surface = "#373740",
89-
// DrawerBackground = "#27272f",
90-
// DrawerText = "rgba(255,255,255, 0.50)",
91-
// AppbarBackground = "#27272f",
92-
// AppbarText = "rgba(255,255,255, 0.70)",
93-
// TextPrimary = "rgba(255,255,255, 0.70)",
94-
// TextSecondary = "rgba(255,255,255, 0.50)",
95-
// ActionDefault = "#adadb1",
96-
// ActionDisabled = "rgba(255,255,255, 0.26)",
97-
// ActionDisabledBackground = "rgba(255,255,255, 0.12)",
98-
// DrawerIcon = "rgba(255,255,255, 0.50)"
99-
//}
84+
// Alt. https://github.com/aksoftware98/mudblazorsample/blob/main/MudBlazorSample/MudBlazorSample/Shared/MainLayout.razor
85+
//Palette = new Palette
86+
//{
87+
// Black = "#27272f",
88+
// Background = "#32333d",
89+
// BackgroundGrey = "#27272f",
90+
// Surface = "#373740",
91+
// DrawerBackground = "#27272f",
92+
// DrawerText = "rgba(255,255,255, 0.50)",
93+
// AppbarBackground = "#27272f",
94+
// AppbarText = "rgba(255,255,255, 0.70)",
95+
// TextPrimary = "rgba(255,255,255, 0.70)",
96+
// TextSecondary = "rgba(255,255,255, 0.50)",
97+
// ActionDefault = "#adadb1",
98+
// ActionDisabled = "rgba(255,255,255, 0.26)",
99+
// ActionDisabledBackground = "rgba(255,255,255, 0.12)",
100+
// DrawerIcon = "rgba(255,255,255, 0.50)"
101+
//}
100102
};
101103

102104
bool _drawerOpen = true;

src/BF2WebAdmin.Blazor/Shared/ServerEditForm.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696

9797
var dialog = _dialogService.Show<ConfirmDialog>("Delete", parameters, options);
9898
var result = await dialog.Result;
99-
if (result.Cancelled)
99+
if (result.Canceled)
100100
return;
101101

102102
await _adminService.RemoveServerAsync(AdminService.UrlDecodeServerId(ServerId));

0 commit comments

Comments
 (0)