Skip to content

MudStepper: New Component #9911

Merged
henon merged 53 commits intoMudBlazor:devfrom
henon:feature/stepper
Oct 6, 2024
Merged

MudStepper: New Component #9911
henon merged 53 commits intoMudBlazor:devfrom
henon:feature/stepper

Conversation

@henon
Copy link
Contributor

@henon henon commented Oct 5, 2024

Description

Continuation of PR #7414 by @fondraco
Closes #7414
Resolves #881

@fondraco wrote

I want to create a stepper component; I've done some base work to kick it off. It should resolve #881. If you have any ideas for functionality, code implementation or anything else, please speak your mind. I'm very open to it. I'd love to see the MudStepper happen.

image
image
image
image
image
image
image
image

How Has This Been Tested?

This will need a few tests.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

image

Checklist:

  • The PR is submitted to the correct branch (dev).
  • My code follows the code style of this project.
  • I've added relevant tests.

fondraco and others added 30 commits October 5, 2024 17:08
… effect for nonlinear version, added renderfragments for Title and Label content
@henon
Copy link
Contributor Author

henon commented Oct 5, 2024

We now have the possibility for custom action buttons. This is the last major missing piece. I think we can merge it as experimental like this.

image

Will add some more tests.

@henon henon mentioned this pull request Oct 5, 2024
6 tasks
@henon
Copy link
Contributor Author

henon commented Oct 6, 2024

Big thanks to @fondraco for making the stepper. I did just polish and wrote all the tests.

Copy link
Member

@ScarletKuro ScarletKuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Only noticed few insignificant nits.

@danielchalmers
Copy link
Member

danielchalmers commented Oct 6, 2024

Love the idea as an experimental component. Things I noticed:

Can't use Next button after reaching end

Recording.2024-10-06.104625.mp4

No padding between hover effect and text below (effect should be shrunk)

image

Each section is a div with role=tab but I believe it should semantically be a button

-<div class="mud-stepper-nav-step active mud-ripple" role="tab" [...]>
+<button class="mud-stepper-nav-step active mud-ripple" role="tab" [...]>

NonLinear should be Linear=false as per previous efforts for inverted names?

image

AlternateLabel not descriptive. Could be CenterLabels, LabelPosition, etc?

image

Not fluid when there's too many items

Recording.2024-10-06.105956.mp4

Could hide labels when it gets too wide (and then start turning center steps into dots)

image

Consider icons (FirstPage, NavigateBefore, NavigateBefore, NavigateNext)

image

Warnings are positioned different than ToggleGroup

image

image

@henon
Copy link
Contributor Author

henon commented Oct 6, 2024

Awesome review @danielchalmers, thanks a lot. Can you help me with the visual stuff? If not we'll put it on a todo list with the rest of the things to do them in a follow-up PR.

In this PR I think I will solve these:

  • Next-button problem (fixed by also not showing previous button if completed)
  • Warning positioning in the docs
  • NonLinear -> Linear
  • Better name for AlternateLabel ... CenterLabels
  • Display "Complete" instead of "Next" on the last step
  • Merge examples Vertical Stepper and Non-Linear Vertical Stepper

Things for a follow-up PR:

  • No padding between hover effect and text below (effect should be shrunk)
  • Each section is a div with role=tab but I believe it should semantically be a button
  • Not fluid with many steps
  • Hide labels or even steps if too many steps
  • Icons for the action buttons
  • Make sure the action button Icons work with RTL
  • Customization example: Improve the action buttons (i.e. disable previous or next in certain situations, etc)
  • Docs: make some of the more boring examples more interesting
  • The numbers in the circles are misaligned, not centered.

@henon
Copy link
Contributor Author

henon commented Oct 6, 2024

Not sure about renaming NonLinear. Actually I think it is the perfect term to describe something that doesn't have to follow order. It is a well known term. We are not fundamentalistic about positivity in naming anyways because we didn't change Disabled to Enabled for similar reasons.

@henon
Copy link
Contributor Author

henon commented Oct 6, 2024

I tried icons but they look horribly out of alignment. This is standard for our buttons it seems :(

image

Will leave that for you too @danielchalmers to be done in a follow-up PR

@henon henon merged commit 739a914 into MudBlazor:dev Oct 6, 2024
@gabephudson
Copy link
Contributor

gabephudson commented Oct 10, 2024

Great new component! Our team has our own home-grown version of this, but will look at moving to the Stepper and dog fooding it soon.

FYI, one issue we had to overcome with our custom implementation was if the user input on a step made it so that another step was not needed, we needed to ensure it gracefully disappeared from the step list. IE, wrapping a MudStep in a conditional if.

@henon
Copy link
Contributor Author

henon commented Oct 11, 2024

Thanks for the feedback @gabephudson. We already have the possiblity to disable steps, it would look like this:

<MudPaper Style="width: 800px">
    <MudStepper ShowResetButton NonLinear>
        <MudStep Title="Step 1">
            <MudSwitch T="bool" @bind-Value="_step2" Color="Color.Primary">Ignore Step2</MudSwitch>
        </MudStep>
        <MudStep Title="Step 2" SecondaryText="Optional" @bind-Disabled="_step2">This can be switched off in Step 1</MudStep>
        <MudStep Title="Step 3">Final step</MudStep>
    </MudStepper>
</MudPaper>

@code {
    bool _step2 = false;    
}

image

However I discovered, that there is a bug because the next button doesn't work then. Will fix that.

https://try.mudblazor.com/snippet/QucoPulPdczUwCIy

@henon
Copy link
Contributor Author

henon commented Oct 11, 2024

Removing steps with an @if is also possible btw, I tried. Adding them back doesn't work for some reason though, so I will also consider adding a bindable Visible property.

Edit: actually there is a bug that can also be seen in the Add / Remove example. Adding a step does render it only after the next render so there is always one less shown than have been added. Will fix that, then the @if block around a step will also work.

@henon henon deleted the feature/stepper branch October 11, 2024 10:55
@gabephudson
Copy link
Contributor

Glad I brought that up. The way Blazor renders makes it tricky if the "steps collections" changes dynamically. Our implementation has each "step' register itself with the parent in the OnParametersSet() event. Even so, we still have issues with things like a consistent index and "active step" state when steps are not added/rendered due to a state change because of conditional @ifs. We have had to use OnAfterRender() in the "stepper" to fix edge cases and re-render. It's still not perfect for some combinations of prev/next steps and state changes (on our implementation).

That said, I really like the idea of using a visibility parameter (wish we implemented that on ours). This would allow the steps to remain in the stepper's collection and just simply be invisible/skipped. This allows a consistent steps collection and being able to keep track of an active index (that doesn't change because the collection size change). Wrapping a step in an @if would then be not recommended and perhaps only used if the steps are not needed on initialization. Visible would be used otherwise and when state changes dynamically when moving through steps.

LLauter pushed a commit to cannellamedia/MudBlazor that referenced this pull request Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Adds a new feature or enhances existing functionality (not fixing a defect) in the main library hacktoberfest Hacktoberfest 2021 hacktoberfest2024 hacktoberfest-accepted Issues and PRs which were accepted as Hacktoberfest submissions new component Proposal or addition of a new component (apply this instead of enhancement)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Steppers component

5 participants