Skip to content
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@using MudExtensions.Utilities

<MudGrid Class="cursor-default">
<MudItem xs="12" sm="8" Class="d-flex align-center">
<MudItem xs="12" sm="8">
<MudStepperExtended @ref="_stepper" Class="mud-width-full" ContentStyle="min-height: 400px" Linear="_linear" Vertical="_vertical" Color="_color" Variant="_variant"
Animation="_animation" ShowPreviousButton="_showPreviousButton" ShowNextButton="_showNextButton"
ShowSkipButton="_showSkipButton" ShowStepResultIndicator="_showStepResultIndicator" HeaderBadgeView="_headerBadgeView"
Expand Down Expand Up @@ -70,14 +70,13 @@
{
<MudButton Color="Color.Secondary" Variant="_variant" OnClick="@(() => Snackbar.Add("Custom cancel button clicked.", Severity.Info))">Cancel</MudButton>
}
@* <MudSpacer /> *@
</ActionContent>
</MudStepperExtended>
</MudItem>

<MudItem xs="12" sm="4">
<MudStack Spacing="4">
<MudNumericField @bind-Value="_activeIndex" Label="Change ActiveIndex" @bind-Value:after="(() => _stepper.SetActiveStepByIndex(_activeIndex))" Variant="Variant.Outlined" Margin="Margin.Dense" />
<MudNumericField @bind-Value="_activeIndex" Label="Change ActiveIndex" @bind-Value:after="(async() => await _stepper.GoToStepAsync(_activeIndex))" Variant="Variant.Outlined" Margin="Margin.Dense" />
<MudCheckBox @bind-Value="_vertical" Color="Color.Secondary" Label="Vertical" Dense="true" />
<MudCheckBox @bind-Value="_linear" Color="Color.Secondary" Label="Linear" Dense="true" />
<MudCheckBox @bind-Value="_animation" Color="Color.Secondary" Label="Enable Animation" Dense="true" />
Expand Down Expand Up @@ -136,9 +135,9 @@
</MudGrid>

@code {
MudStepperExtended? _stepper = new();
MudForm? _form = new();
MudForm? _form2 = new();
MudStepperExtended _stepper = default!;
MudForm _form = default!;
MudForm _form2 = default!;
bool _checkValidationBeforeComplete = false;
bool _linear;
bool _mobileView;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
@namespace MudExtensions.Docs.Examples
@inject ISnackbar Snackbar
@inject IDialogService DialogService

<MudGrid Class="cursor-default">
<MudItem xs="12" sm="8" Class="d-flex align-center">

<MudStepperExtended @ref="_stepper"
Class="mud-width-full" ContentStyle="min-height: 400px"
Linear="_linear" Vertical="_vertical"
PreventStepChangeAsync="CheckChange" BeforeFinishedAsync="BeforeFinishedAsync" OnFinished="OnFinished"
Variant="Variant.Filled" Color="Color.Secondary" ContentClass="d-flex align-center justify-center mud-height-full"
MobileView="_mobileView" Loading="_loading" HeaderTextView="HeaderTextView.All" StepperActionsJustify="_stepperActionsJustify">

<ChildContent>
<MudStepExtended Icon="@Icons.Material.Filled.DoneAll" Title="Start Your Reservation" IsIntroStep="true">
<div class="d-flex flex-column align-center justify-center mud-height-full">
<MudIcon Icon="@Icons.Material.Filled.Book" Size="Size.Large" Color="Color.Secondary" />
<MudText Typo="Typo.h6" Class="mt-2">This is your reservation wizard.</MudText>
<MudText Typo="Typo.h6" Class="mt-2">Press start when you are ready.</MudText>
</div>
</MudStepExtended>

<MudStepExtended Icon="@Icons.Material.Filled.Approval" Title="Customer Info" StatusChanged="OnStatusChanged" Order="_infoStepOrder">
<MudForm @ref="_form">
<MudStack>
<MudTextField T="string" Label="Name" Variant="Variant.Filled" Required="true" />
<MudTextField T="string" Label="Last Name" Variant="Variant.Filled" Required="true" />
<MudTextField T="string" Label="Address" Variant="Variant.Filled" />
</MudStack>
</MudForm>
</MudStepExtended>

<MudStepExtended Title="Booking Options" Icon="@Icons.Material.Filled.MoreVert" Optional="true" Order="_optionsStepOrder">
<MudCheckBox T="bool" Label="Early Check-in" />
<MudCheckBox T="bool" Label="Late Check-out" />
<MudCheckBox T="bool" Label="Twin Bed" />
</MudStepExtended>

<MudStepExtended Icon="@Icons.Material.Filled.Money" Title="Payment" Order="_paymentStepOrder">
<MudForm @ref="_form2">
<MudStack>
<MudTextField T="string" Label="Card Number" Variant="Variant.Filled" Required="true" />
<MudStack Row="true">
<MudTextField T="string" Label="Expire Date" Required="true" />
<MudTextField T="string" Label="CVC" Required="true" />
</MudStack>
</MudStack>
</MudForm>
</MudStepExtended>

@if (_hasResultStep)
{
<MudStepExtended Icon="@Icons.Material.Filled.DoneAll" Title="Reservation Completed" IsResultStep="true">
<div class="d-flex flex-column align-center justify-center" style="height: 200px">
<MudIcon Icon="@Icons.Material.Filled.CheckCircle" Size="Size.Large" Color="Color.Secondary" />
<MudText Typo="Typo.h6" Class="mt-2">Your reservation is completed successfully.</MudText>
</div>
</MudStepExtended>
}

</ChildContent>

</MudStepperExtended>

</MudItem>

<MudItem xs="12" sm="4">
<MudStack Spacing="4">
<MudNumericField @bind-Value="_infoStepOrder"
Label="Info Step Order"
@bind-Value:after="@(() => _stepper.ForceRender())"
Variant="Variant.Outlined"
Margin="Margin.Dense"
Immediate="true" />

<MudNumericField @bind-Value="_optionsStepOrder"
Label="Options Step Order"
@bind-Value:after="@(() => _stepper.ForceRender())"
Variant="Variant.Outlined"
Margin="Margin.Dense"
Immediate="true" />

<MudNumericField @bind-Value="_paymentStepOrder"
Label="Payment Step Order"
@bind-Value:after="@(() => _stepper.ForceRender())"
Variant="Variant.Outlined"
Margin="Margin.Dense"
Immediate="true" />
<MudSelect @bind-Value="_stepperActionsJustify" Variant="Variant.Outlined" Label="Action Buttons Justify" Margin="Margin.Dense" Dense="true">
@foreach (StepperActionsJustify item in Enum.GetValues<StepperActionsJustify>())
{
<MudSelectItem Value="item">@item.ToDescriptionString()</MudSelectItem>
}
</MudSelect>
<MudCheckBox @bind-Value="_vertical" Label="Vertical" />
<MudCheckBox @bind-Value="_linear" Label="Linear" />
<MudSwitchM3 @bind-Value="_mobileView" Label="Mobile View" Color="Color.Secondary" />
<MudSwitchM3 @bind-Value="_hasResultStep" Label="Has Result Step" Color="Color.Secondary" />

<MudButton Variant="Variant.Filled" Color="Color.Secondary" OnClick="(() => _stepper?.Reset())">
Reset
</MudButton>
</MudStack>
</MudItem>

</MudGrid>

@code {
MudStepperExtended? _stepper;
MudForm _form = new();
MudForm _form2 = new();
bool _linear;
bool _mobileView;
bool _vertical;
bool _loading;
bool _hasResultStep = true;
int _infoStepOrder;
int _optionsStepOrder;
int _paymentStepOrder;
StepperActionsJustify _stepperActionsJustify = StepperActionsJustify.SpaceBetween;

private void OnStatusChanged(StepStatus status)
{
Snackbar.Add($"Customer Info step is now: {status}.", Severity.Info);
}

private async Task<bool> CheckChange(StepChangeDirection direction, int targetIndex)
{
if (direction == StepChangeDirection.Backward)
return false;

if (_stepper?.GetActiveIndex() == 0)
{
_loading = true;
StateHasChanged();
await Task.Delay(500);

await _form.Validate();
_loading = false;
StateHasChanged();

return !_form.IsValid;
}

if (_stepper?.GetActiveIndex() == 2)
{
_loading = true;
StateHasChanged();
await Task.Delay(500);

await _form2.Validate();
_loading = false;
StateHasChanged();

return !_form2.IsValid;
}

return false;
}

private async Task<bool> BeforeFinishedAsync()
{
var result = await DialogService.ShowMessageBox(
"Confirm",
"All steps are completed. Do you want to finish?",
yesText: "Finish",
cancelText: "Cancel"
);

return result == true;
}

private Task OnFinished()
{
Snackbar.Add("Reservation process finished successfully!", Severity.Success);
return Task.CompletedTask;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,29 @@
@namespace MudExtensions.Docs.Pages

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

<ExampleCard ComponentName="StepperExtended"
ExampleName="StepperExtendedExample1"
Title="Playground"
Description="Basic usage and interactive settings.">

<StepperExtendedExample1 />
</ExampleCard>

<ExampleCard ComponentName="StepperExtended" ExampleName="StepperExtendedExample2" Title="Order" Description="You can set each step's order dynamically.">
<ExampleCard ComponentName="StepperExtended"
ExampleName="StepperExtendedExample2"
Title="Order"
Description="You can set each step's order dynamically and reorder at runtime.">

<StepperExtendedExample2 />
</ExampleCard>

<ExampleCard ComponentName="StepperExtended"
ExampleName="StepperExtendedExample3"
Title="Full Flow & Validation"
Description="Advanced flow with BeforeFinishedAsync, OnFinished, validation, dynamic ResultStep, and step status events.">

<StepperExtendedExample3 />
</ExampleCard>

</ExamplePage>
Loading
Loading