Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mud blazor v7 #6

Merged
merged 2 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@inject ISnackbar Snackbar

<MudPopoverProvider></MudPopoverProvider>
<MudPopoverProvider />
<MudDialogProvider />
<MudSnackbarProvider />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<CascadingValue Value=false Name="UsePopoverProvider">
<MudThemeProvider Theme="MyTheme"></MudThemeProvider>
</CascadingValue>
<MudThemeProvider Theme="MyTheme"></MudThemeProvider>

@code {
public static MudTheme MyTheme => new()
{
Palette = new PaletteLight()
PaletteLight = new PaletteLight()
{
Primary = Colors.Teal.Default,
AppbarBackground = Colors.Teal.Default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

<ItemGroup>
<PackageReference Include="Blazr.RenderState.WASM" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.3" />
<PackageReference Include="MudBlazor" Version="6.19.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="8.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.6" />
<PackageReference Include="MudBlazor" Version="7.0.0-rc.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="8.0.6" />
</ItemGroup>

</Project>
11 changes: 5 additions & 6 deletions demo/StaticSample/StaticSample/StaticSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@

<ItemGroup>
<PackageReference Include="Blazr.RenderState.Server" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.3">
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.6" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.0.6" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.6">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MudBlazor" Version="6.19.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Components/MudStaticButton.razor
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ else
</button>;
}

private RenderFragment RenderHiddenReturnUrl()
private RenderFragment? RenderHiddenReturnUrl()
{
if (!string.IsNullOrEmpty(ReturnUrl))
{
Expand Down
6 changes: 1 addition & 5 deletions src/Components/MudStaticButton.razor.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Windows.Input;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;

namespace MudBlazor.StaticInput;
Expand All @@ -14,10 +13,7 @@ public partial class MudStaticButton : MudButton
protected new ButtonType ButtonType { get; set; }
protected new string HtmlTag { get; set; } = "button";
protected new string? Href { get; set; }
protected new string? Link { get; set; }
protected new string? Target { get; set; }
protected new ICommand? Command { get; set; }
protected new bool ClickPropagation { get; set; }
protected new object? CommandParameter { get; set; }
protected new EventCallback<MouseEventArgs> OnClick { get; set; }
}
2 changes: 1 addition & 1 deletion src/Components/MudStaticCheckBox.razor
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
id="@($"static-checkbox-{_elementId}")" disabled="@GetDisabledState()" @onclick:preventDefault="@GetReadOnlyState()"/>
<MudIcon Icon="@CheckedIcon" Color="HasErrors ? Color.Error : this.Color" Size="@Size"
id="@($"check-icon-{_elementId}")" style="display: none;"/>
<MudIcon Icon="@UncheckedIcon" Color="HasErrors ? Color.Error : this.UnCheckedColor ?? Color.Inherit" Size="@Size"
<MudIcon Icon="@UncheckedIcon" Color="HasErrors ? Color.Error : this.UncheckedColor ?? Color.Inherit" Size="@Size"
id="@($"unchecked-icon-{_elementId}")"/>
</span>
@if (!string.IsNullOrEmpty(Label))
Expand Down
3 changes: 1 addition & 2 deletions src/Components/MudStaticCheckBox.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ public partial class MudStaticCheckBox : MudCheckBox<bool>
* Hide these inherited properties to prevent *
* consumers from modifying them directly. *
**********************************************/
protected new bool Checked { get; set; }
protected new bool Value { get; set; }
protected new bool TriState { get; set; }
protected new bool KeyboardEnabled { get; set; }
protected new EventCallback<bool> ValueChanged { get; set; }
protected new EventCallback<bool> CheckedChanged { get; set; }
protected new string IndeterminateIcon { get; set; } = Icons.Material.Filled.IndeterminateCheckBox;
}
2 changes: 1 addition & 1 deletion src/Components/MudStaticSwitch.razor
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
container.classList.toggle("@UncheckedHoverColor", !force)

switchTrack.classList.toggle("@CheckedColor", force);
switchTrack.classList.toggle("@UncheckedColor", !force)
switchTrack.classList.toggle("@UnCheckedColor", !force)

if (switchToggle.checked) {
emptySwitch.removeAttribute("name");
Expand Down
9 changes: 4 additions & 5 deletions src/Components/MudStaticSwitch.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,20 @@ public partial class MudStaticSwitch : MudSwitch<bool>
* Hide these inherited properties to prevent *
* consumers from modifying them directly. *
**********************************************/
protected new bool Checked { get; set; }
protected new bool Value { get; set; }
protected new EventCallback<bool> ValueChanged { get; set; }
protected new EventCallback<bool> CheckedChanged { get; set; }

/*
* Options for SwitchClassname
*/
private string CheckedTextColor => $"mud-{Color.ToDescriptionString()}-text";
private string CheckedHoverColor => $"hover:mud-{Color.ToDescriptionString()}-hover";
private string UncheckedTextColor => $"mud-{UnCheckedColor.ToDescriptionString()}-text";
private string UncheckedHoverColor => $"hover:mud-{UnCheckedColor.ToDescriptionString()}-hover";
private string UncheckedTextColor => $"mud-{UncheckedColor.ToDescriptionString()}-text";
private string UncheckedHoverColor => $"hover:mud-{UncheckedColor.ToDescriptionString()}-hover";

/*
* Options for TrackClassname
*/
private string CheckedColor => $"mud-{Color.ToDescriptionString()}";
private string UncheckedColor => $"mud-{UnCheckedColor.ToDescriptionString()}";
private string UnCheckedColor => $"mud-{UncheckedColor.ToDescriptionString()}";
}
8 changes: 4 additions & 4 deletions src/Components/MudStaticTextField.razor
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
@code {
[Parameter] public Expression<Func<string>>? ValueExpression { get; set; }

private string _name;
private string _elementId;
private string _name = string.Empty;
private string _elementId = string.Empty;
private bool HasDefaultContent => ShrinkLabel ||
HasNativeHtmlPlaceholder() ||
Adornment == Adornment.Start ||
!string.IsNullOrWhiteSpace(Placeholder);

protected override void OnParametersSet()
{
UserAttributes["id"] = _elementId;
UserAttributes["data-static-id"] = _elementId;
UserAttributes["name"] = _name;

base.OnParametersSet();
Expand Down Expand Up @@ -58,7 +58,7 @@

<script>
(function () {
const inputElement = document.getElementById('@_elementId');
const inputElement = document.querySelector('[data-static-id="@_elementId"]');
const shrinkLabel = @HasDefaultContent.ToString().ToLower();
const showOnFocus = @HelperTextOnFocus.ToString().ToLower();

Expand Down
2 changes: 0 additions & 2 deletions src/Components/MudStaticTextField.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public partial class MudStaticTextField<T> : MudTextField<T>
protected new EventCallback<FocusEventArgs> OnBlur { get; set; }
protected new EventCallback<KeyboardEventArgs> OnKeyDown { get; set; }
protected new bool KeyDownPreventDefault { get; set; }
protected new EventCallback<KeyboardEventArgs> OnKeyPress { get; set; }
protected new bool KeyPressPreventDefault { get; set; }
protected new EventCallback<KeyboardEventArgs> OnKeyUp { get; set; }
protected new bool KeyUpPreventDefault { get; set; }
protected new EventCallback<T> ValueChanged { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src/MudBlazor.StaticInput.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MudBlazor" Version="6.19.1" />
<PackageReference Include="MudBlazor" Version="7.0.0-rc.2" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
@code {
MudTheme customTheme = new MudTheme()
{
Palette = new PaletteLight()
PaletteLight = new PaletteLight()
{
Primary = Colors.Teal.Default
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<DataAnnotationsValidator />
<MudStack Row="true" AlignItems="AlignItems.Center">
<MudStaticCheckBox @bind-Value="Input.Confirm" Class="my-4 ml-n4" Label="Confirm" For="() => Input.Confirm"
Color="Color.Primary" UnCheckedColor="Color.Error" Size="Size.Large" LabelPosition="LabelPosition.Start" />
Color="Color.Primary" UncheckedColor="Color.Error" Size="Size.Large" LabelPosition="LabelPosition.Start" />
<MudStaticButton FormAction="FormAction.Submit" Color="Color.Primary" Variant="Variant.Filled">Submit</MudStaticButton>
</MudStack>
</EditForm>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<DataAnnotationsValidator />
<MudStack Row="true" AlignItems="AlignItems.Center">
<MudStaticSwitch @bind-Value="Input.Confirm" Class="my-4 ml-n4" Label="Confirm" For="() => Input.Confirm"
Color="Color.Primary" UnCheckedColor="Color.Error" Size="Size.Large" LabelPosition="LabelPosition.Start" />
Color="Color.Primary" UncheckedColor="Color.Error" Size="Size.Large" LabelPosition="LabelPosition.Start" />
<MudStaticButton FormAction="FormAction.Submit" Color="Color.Primary" Variant="Variant.Filled">Submit</MudStaticButton>
</MudStack>
</EditForm>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ protected BaseComponentTest(ContextFixture contextFixture)
ContextFixture = contextFixture;
Context.JSInterop.Mode = JSRuntimeMode.Loose;
Context.Services.AddMudBlazorKeyInterceptor();
Context.Services.AddMudLocalization();
}

public async Task InitializeAsync()
Expand Down
10 changes: 5 additions & 5 deletions tests/StaticInput.UnitTests/Components/TextFieldTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void TextField_Input_Should_Shink_Label()
var comp = Context.RenderComponent<TextFieldLabelTest>();

var field = comp.FindComponents<MudStaticTextField<string>>()
.First(x => x.Instance.Label.Equals("Basic Label", StringComparison.OrdinalIgnoreCase));
.First(x => x.Instance.Label!.Equals("Basic Label", StringComparison.OrdinalIgnoreCase));

var index = field.Markup.IndexOf("<script>");

Expand All @@ -41,7 +41,7 @@ public void TextField_AdonrmentStart_Should_Shink_Label()
var comp = Context.RenderComponent<TextFieldLabelTest>();

var field = comp.FindComponents<MudStaticTextField<string>>()
.First(x => x.Instance.Label.Equals("Adornment Start", StringComparison.OrdinalIgnoreCase));
.First(x => x.Instance.Label!.Equals("Adornment Start", StringComparison.OrdinalIgnoreCase));

var index = field.Markup.IndexOf("<script>");

Expand All @@ -58,7 +58,7 @@ public void TextField_AdornmentEnd_Should_Not_Shink_Label()
var comp = Context.RenderComponent<TextFieldLabelTest>();

var field = comp.FindComponents<MudStaticTextField<string>>()
.First(x => x.Instance.Label.Equals("Adornment End", StringComparison.OrdinalIgnoreCase));
.First(x => x.Instance.Label!.Equals("Adornment End", StringComparison.OrdinalIgnoreCase));

var index = field.Markup.IndexOf("<script>");

Expand All @@ -75,7 +75,7 @@ public void TextField_Shrink_Label_Should_Shink_Label()
var comp = Context.RenderComponent<TextFieldLabelTest>();

var field = comp.FindComponents<MudStaticTextField<string>>()
.First(x => x.Instance.Label.Equals("Shrink Label", StringComparison.OrdinalIgnoreCase));
.First(x => x.Instance.Label!.Equals("Shrink Label", StringComparison.OrdinalIgnoreCase));

var index = field.Markup.IndexOf("<script>");

Expand All @@ -92,7 +92,7 @@ public void TextField_Placeholder_Should_Shink_Label()
var comp = Context.RenderComponent<TextFieldLabelTest>();

var field = comp.FindComponents<MudStaticTextField<string>>()
.First(x => x.Instance.Label.Equals("Placeholder", StringComparison.OrdinalIgnoreCase));
.First(x => x.Instance.Label!.Equals("Placeholder", StringComparison.OrdinalIgnoreCase));

var index = field.Markup.IndexOf("<script>");

Expand Down
12 changes: 6 additions & 6 deletions tests/StaticInput.UnitTests/StaticInput.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="bunit" Version="1.27.17" />
<PackageReference Include="bunit" Version="1.28.9" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="GitHubActionsTestLogger" Version="2.3.3">
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Microsoft.Playwright" Version="1.42.0" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Microsoft.Playwright" Version="1.44.0" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down