Skip to content

Commit e4cccdc

Browse files
authored
StepperExtended: Add MobileBreakpoint Parameter and New Centered Aligned Option For Action Buttons (#567)
1 parent 58aee83 commit e4cccdc

File tree

5 files changed

+64
-1
lines changed

5 files changed

+64
-1
lines changed

CodeBeam.MudBlazor.Extensions.Docs.Wasm/wwwroot/CodeBeam.MudBlazor.Extensions.xml

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CodeBeam.MudBlazor.Extensions.Docs/Pages/Components/StepperExtended/Examples/StepperExtendedExample1.razor

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
ShowSkipButton="_showSkipButton" ShowStepResultIndicator="_showStepResultIndicator" HeaderBadgeView="_headerBadgeView"
1111
HeaderTextView="_headerTextView" PreventStepChangeAsync="new Func<StepChangeDirection, int, Task<bool>>(CheckChange)" LocalizedStrings="GetLocalizedStrings()"
1212
MobileView="_mobileView" IconActionButtons="_iconActionButtons" Loading="_loading" HeaderSize="_headerSize"
13-
StepperActionsJustify="_stepperActionsJustify">
13+
StepperActionsJustify="_stepperActionsJustify" MobileBreakpoint="_mobileBreakpoint">
1414
<StaticContent>
1515
@if (_showStaticContent)
1616
{
@@ -122,6 +122,13 @@
122122
<MudSelectItem Value="item">@item.ToDescriptionString()</MudSelectItem>
123123
}
124124
</MudSelect>
125+
<MudSelectExtended T="Breakpoint ?" @bind-Value="_mobileBreakpoint" Variant="Variant.Outlined" Label="Mobile Breakpoint" Margin="Margin.Dense" Dense="true">
126+
<MudSelectItemExtended T="Breakpoint?" Value="null">None</MudSelectItemExtended>
127+
@foreach (Breakpoint item in Enum.GetValues<Breakpoint>())
128+
{
129+
<MudSelectItemExtended T="Breakpoint ?" Value="item">@item.ToDescriptionString()</MudSelectItemExtended>
130+
}
131+
</MudSelectExtended>
125132
<MudSelectExtended @bind-Value="_headerSize" ItemCollection="@(Enum.GetValues<Size>())" Variant="Variant.Outlined" Label="Header Size" Margin="Margin.Dense" Dense="true" />
126133
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="(() => _stepper?.Reset())">Reset</MudButton>
127134
</MudStack>
@@ -154,6 +161,7 @@
154161
bool _vertical = false;
155162
Size _headerSize = Size.Medium;
156163
StepperActionsJustify _stepperActionsJustify = StepperActionsJustify.SpaceBetween;
164+
Breakpoint? _mobileBreakpoint;
157165

158166
private async Task<bool> CheckChange(StepChangeDirection direction, int targetIndex)
159167
{

CodeBeam.MudBlazor.Extensions/Components/StepperExtended/MudStepperExtended.razor

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
@namespace MudExtensions
22
@inherits MudComponentBase
3+
@inject IBrowserViewportService BrowserViewportService
4+
5+
@if(MobileBreakpoint != null)
6+
{
7+
<MudBreakpointProvider OnBreakpointChanged="OnBreakpointChanged" />
8+
}
39

410
<CascadingValue Value="this" IsFixed="true">
511
<MudStack Row="@Vertical" Class="@Class" Style="@Style">

CodeBeam.MudBlazor.Extensions/Components/StepperExtended/MudStepperExtended.razor.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public partial class MudStepperExtended : MudComponentBase
3535
///
3636
/// </summary>
3737
protected string? ActionClassname => new CssBuilder("d-flex gap-4")
38+
.AddClass("justify-center", StepperActionsJustify == StepperActionsJustify.Center)
3839
.AddClass(ActionClass)
3940
.Build();
4041

@@ -237,6 +238,14 @@ protected void UpdateProgressValue()
237238
[Parameter]
238239
public bool MobileView { get; set; }
239240

241+
/// <summary>
242+
/// Gets or sets the breakpoint at which the component automatically switches to mobile layout. Overrides MobileView parameter.
243+
/// </summary>
244+
/// <remarks>Use this property to define the responsive threshold for mobile-specific rendering.
245+
/// The value determines at which screen size the component adapts its layout for mobile devices.</remarks>
246+
[Parameter]
247+
public Breakpoint? MobileBreakpoint { get; set; }
248+
240249
/// <summary>
241250
/// If true, a linear loading indicator shows under the header.
242251
/// </summary>
@@ -650,5 +659,26 @@ public void ForceRender()
650659
StateHasChanged();
651660
}
652661

662+
/// <summary>
663+
/// Handles changes to the specified breakpoint and updates the mobile view state accordingly.
664+
/// </summary>
665+
/// <remarks>This method updates the mobile view only if a mobile breakpoint is defined. It is
666+
/// typically called when the application's layout needs to respond to breakpoint changes, such as during window
667+
/// resizing or device orientation changes.</remarks>
668+
/// <param name="breakpoint">The breakpoint value that triggered the change. Determines whether the mobile view should be enabled or
669+
/// disabled.</param>
670+
protected void OnBreakpointChanged(Breakpoint breakpoint)
671+
{
672+
if (MobileBreakpoint.HasValue && breakpoint <= MobileBreakpoint )
673+
{
674+
MobileView = true;
675+
}
676+
else
677+
{
678+
MobileView = false;
679+
}
680+
StateHasChanged();
681+
}
682+
653683
}
654684
}

CodeBeam.MudBlazor.Extensions/Enums/StepperActionsJustify.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ public enum StepperActionsJustify
1111
End,
1212
[Description("start")]
1313
Start,
14+
[Description("center")]
15+
Center,
1416
}
1517
}

0 commit comments

Comments
 (0)