Hi I am currently building a reusable stepper and I got a bit stuck with finding the logic.
I need to create a reusable component using React as tech. The component should take some props like an array of objects with every item holding some information.
Depending on the screen size, some steps should hide, depending on the total number of steps available, current step, steps to go and steps done. Its not only about hiding some steps, but also regrouping previous or next steps depending on current index.
If someone is interested helping i can share some code of what I did, and maybe could try explain what main info i should get and how to construct my component.
It might be easier with a repo so I can try things out, but just looking it over, I would be thinking about doing something like this…
You have steps.map..., I would think about doing a step before that, with a filter method or something else, to remove the unwanted steps and then map those. For readability, I would do that before the return statement. (And in general, I would extract most - if not all - of that logic and helper functions from the JSX - but that get’s into stylistic approaches.