Skip to content

Commit

Permalink
Stepper Fix ProgressValue does not Update When Step Add/Remove (#391)
Browse files Browse the repository at this point in the history
* Stepper Fix ProgressValue does not Update When Step Add/Remove

* Change Example Names

* Fix Error and Warning
  • Loading branch information
mckaragoz authored May 3, 2024
1 parent 9729c29 commit bb90568
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 22 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@page "/mudstepperextended"
@namespace MudExtensions.Docs.Pages

<ExamplePage Title="MudStepperExtended">
<ExampleCard ComponentName="StepperExtended" ExampleName="StepperExtendedExample1" Title="Playground" Description="Place MudSteps in the MudStepper.">
<StepperExtendedExample1 />
</ExampleCard>

<ExampleCard ComponentName="StepperExtended" ExampleName="StepperExtendedExample2" Title="Order" Description="You can set each step's order dynamically.">
<StepperExtendedExample2 />
</ExampleCard>
</ExamplePage>
2 changes: 1 addition & 1 deletion CodeBeam.MudBlazor.Extensions.Docs/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
{
new("MudListExtended", "The extended MudList component."),
new("MudSelectExtended", "The extended MudSelect component."),
new("MudStepperExtended", "A wizard-like steps to control the flow with rich options."),
new("MudTextFieldExtended", "The extended MudTextField component."),
};

Expand All @@ -254,7 +255,6 @@
new("MudSignaturePad", "A signature pad."),
new("MudSpeedDial", "Stacked buttons in a menu content."),
new("MudSplitter", "A resizeable content splitter."),
new("MudStepper", "A wizard-like steps to control the flow with rich options."),
new("MudSwitchM3", "Material 3 switch component that has all MudBlazor features."),
new("MudTeleport", "Teleport the content to the specified parent and not follow the DOM hierarchy."),
new("MudTextM3", "Material 3 typography"),
Expand Down
2 changes: 1 addition & 1 deletion CodeBeam.MudBlazor.Extensions.Docs/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<MudNavLink Href="/mudsignaturepad">SignaturePad</MudNavLink>
<MudNavLink Href="/mudspeeddial">SpeedDial</MudNavLink>
<MudNavLink Href="/mudsplitter">Splitter</MudNavLink>
<MudNavLink Href="/mudstepper">Stepper</MudNavLink>
<MudNavLink Href="/mudstepperextended">StepperExtended</MudNavLink>
<MudNavLink Href="/mudswitchm3">SwitchM3</MudNavLink>
<MudNavLink Href="/mudteleport">Teleport</MudNavLink>
<MudNavLink Href="/mudtextfieldextended">TextFieldExtended</MudNavLink>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void SplitterPageRenderTest()
[Test]
public void StepperPageRenderTest()
{
var comp = Context.RenderComponent<StepperPage>();
var comp = Context.RenderComponent<StepperExtendedPage>();
comp.Markup.Should().NotBeNullOrEmpty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace MudExtensions
{
/// <summary>
///
/// </summary>
public partial class MudSpeedDial : MudComponentBase
{
Guid _animationGuid = Guid.NewGuid();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,18 @@ internal int ActiveIndex
set
{
_activeIndex = value;
ProgressValue = _activeIndex * (100.0 / (Steps.Count - 1));
UpdateProgressValue();
}
}

internal double ProgressValue;
/// <summary>
///
/// </summary>
protected void UpdateProgressValue()
{
ProgressValue = _activeIndex * (100.0 / (Steps.Count - 1));
}

/// <summary>
/// Provides CSS classes for the step content.
Expand Down Expand Up @@ -349,6 +356,7 @@ internal void AddStep(MudStepExtended step)
ReorderSteps();
}

UpdateProgressValue();
StateHasChanged();
}

Expand All @@ -364,6 +372,7 @@ internal void RemoveStep(MudStepExtended step)
{
Steps.Remove(step);
_allSteps.Remove(step);
UpdateProgressValue();
StateHasChanged();
}

Expand Down Expand Up @@ -633,10 +642,11 @@ public void SetStepStatus(int index, StepStatus status)
}

/// <summary>
///
/// Update all component and render again.
/// </summary>
public void ForceRender()
{
UpdateProgressValue();
StateHasChanged();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

namespace MudExtensions
{
/// <summary>
///
/// </summary>
/// <typeparam name="T"></typeparam>
public partial class MudTextFieldExtended<T> : MudDebouncedInputExtended<T>
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

namespace MudExtensions
{
/// <summary>
///
/// </summary>
public partial class MudToggle : MudComponentBase
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

namespace MudExtensions
{
/// <summary>
///
/// </summary>
/// <typeparam name="T"></typeparam>
public partial class MudTransferList<T> : MudComponentBase
{
MudListExtended<T> _startList = new();
Expand Down Expand Up @@ -65,6 +69,9 @@ public partial class MudTransferList<T> : MudComponentBase
[Parameter]
public EventCallback<ICollection<T?>?> EndCollectionChanged { get; set; }

/// <summary>
///
/// </summary>
[Parameter]
[Category(CategoryTypes.FormComponent.ListBehavior)]
public Func<T?, string?>? ToStringFunc { get; set; }
Expand Down Expand Up @@ -357,6 +364,10 @@ protected internal async Task TransferAll(bool startToEnd = true)
}
}

/// <summary>
///
/// </summary>
/// <returns></returns>
public ICollection<T?>? GetStartListSelectedValues()
{
if (_startList == null)
Expand Down Expand Up @@ -408,6 +419,11 @@ protected void OrderItems()
EndCollection = OrderFunc.Invoke(EndCollection);
}

/// <summary>
///
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
protected async Task DoubleClick(ListItemClickEventArgs<T> args)
{
if (AllowDoubleClick == false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ namespace MudExtensions
/// <typeparam name="T"></typeparam>
public partial class MudWheel<T> : MudBaseInput<T>
{

/// <summary>
///
/// </summary>
[Inject] public IScrollManager ScrollManager { get; set; }

/// <summary>
Expand Down
11 changes: 7 additions & 4 deletions CodeBeam.MudBlazor.Extensions/Utilities/MudCssManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.JSInterop;
using MudBlazor.Extensions;
using System.ComponentModel;

namespace MudExtensions.Utilities
Expand All @@ -11,6 +10,10 @@ public class MudCssManager
{
private IJSRuntime JSRuntime;

/// <summary>
///
/// </summary>
/// <param name="jsRuntime"></param>
public MudCssManager(IJSRuntime jsRuntime)
{
JSRuntime = jsRuntime;
Expand All @@ -34,7 +37,7 @@ public async Task SetCss(string? className, CssProp cssProp, string? value)
className = "." + className;
}

object[] parameters = new object[] { className, cssProp.ToDescriptionString(), value };
object?[] parameters = new object?[] { className, cssProp.ToDescriptionString(), value };
await JSRuntime.InvokeVoidAsync("setcss", parameters);
}

Expand All @@ -56,7 +59,7 @@ public async Task SetCss(string? className, string? cssPropName, string? value)
className = "." + className;
}

object[] parameters = new object[] { className, cssPropName, value };
object?[] parameters = new object?[] { className, cssPropName, value };
await JSRuntime.InvokeVoidAsync("setcss", parameters);
}

Expand Down Expand Up @@ -99,7 +102,7 @@ public async Task SetCss(string? className, string? cssPropName, string? value)
className = "." + className;
}

object[] parameters = new object[] { className, cssPropName };
object?[] parameters = new object?[] { className, cssPropName };
var result = await JSRuntime.InvokeAsync<string?>("getcss", parameters);
return result;
}
Expand Down

0 comments on commit bb90568

Please sign in to comment.