Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stepper component #2465

Open
wants to merge 55 commits into
base: main
Choose a base branch
from
Open

Stepper component #2465

wants to merge 55 commits into from

Conversation

benlister-okta
Copy link
Contributor

@benlister-okta benlister-okta commented Jan 17, 2025

DES-6996

Summary

Adds Stepper component

  • Supports vertical and horizontal layouts
  • Variants: numeric (1) and non-numeric •
  • Supports optionally clickable steps (both all clickable or only completed steps clickable)
  • Has both a label and customizable description field
  • Has optional pagination-like navigation controls (next/previous as well as "dot" navigation, like on a carousel)
  • This component is based off MUI Stepper

Component checklist

Code structure

  • Organize code using a modular component architecture.
  • Use semantic HTML for clear and meaningful structure.
  • Break down complex components into smaller, reusable parts.

Accessibility implementation

  • Apply ARIA attributes to indicate roles and relationships.
  • Test focus management and ensure interactive elements are keyboard accessible.
  • Provide visual alternatives for auditory elements.

Internationalization (i18n) implementation

  • Separate any text content from the component's code for translation.

Documentation

  • Include code snippets, demos, and examples for various use cases.
  • Provide guidance on customization and handling special cases.

Finalize code

  • Interaction designers, UI eng and visual designers need to review that the Storybook code matches the intended Figma design
  • Interaction designers need to confirm Storybook code matches Supernova
  • Interaction and visual designers merge Figma and code at the same time

QA

  • Include necessary unit tests to continuously verify component functionality
  • Screen reader test error/success states or message
  • Test edge cases and error scenarios to validate robustness

@benlister-okta benlister-okta marked this pull request as ready for review January 17, 2025 23:30
@benlister-okta benlister-okta requested a review from a team as a code owner January 17, 2025 23:30
? odysseyDesignTokens.HueBlue600
: odysseyDesignTokens.HueNeutral600
}`,
background: completed
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Can we be more explicit and use backgroundColor here.

Also, if possible, can we do a more conditional approach to applying these? Rather than a nested ternary. This is less of a 'nit' as I think we'd like to generally move this direction with these types of styles

...(completed && (...

...(active && (...

: active
? odysseyDesignTokens.HueBlue600
: "transparent",
transition: `all ${odysseyDesignTokens.TransitionDurationMain}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd recommend against using 'all' here and be more explicit about what exactly is transitioning. There are performance concerns with all and, you get the added bonus of being able to tell at a glance what is being transitioned

transition: `all ${odysseyDesignTokens.TransitionDurationMain}`,

".MuiStep-root:hover &":
!active && !completed && nonLinear
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment about the conditional pattern, rather than a ternary here

completed || active
? odysseyDesignTokens.HueNeutralWhite
: odysseyDesignTokens.HueNeutral700,
border: `1px solid ${
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Can we break this into 2 declarations.

border:  '1px solid',

And then conditionally add the borderColor

? { border: `1px solid ${odysseyDesignTokens.HueNeutral900}` }
: undefined,

"& svg": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we targeting the child svg here? If so, we can lose the &.


"& svg": {
width:
variant === "numeric"
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment about the conditional pattern

? odysseyDesignTokens.Spacing4
: odysseyDesignTokens.Spacing3,
height:
variant === "numeric"
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment about the conditional pattern

/**
* Aria label for the stepper container, Falls back to "Progress steps"
*/
ariaLabel?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we define this as ariaLabel?: HtmlProps["ariaLabel"];. You can add additional comments by doing this:

/**
   *
   * Aria label for the stepper container, Falls back to "Progress steps"
   */

Notice the extra * above

/**
* Callback fired when back button is clicked
*/
onBack: () => void;
Copy link
Contributor

Choose a reason for hiding this comment

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

What do we send to the consumer onBack or onNext? Do they need a name or number of the step they are coming from? I would assume they would but, not sure

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The callbacks aren't currently sending any context, which definitely seems limiting. I'm going to update to add current and target step indexes.

display: "grid",
gridTemplateColumns: "1fr auto 1fr",
alignItems: "center",
marginTop: odysseyDesignTokens.Spacing3,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
marginTop: odysseyDesignTokens.Spacing3,
marginBlockStart: odysseyDesignTokens.Spacing3,

status === "current" ? odysseyDesignTokens.HueNeutral500 : "transparent",
margin: "0 2px",
cursor: isClickable ? "pointer" : "default",
"&:hover": isClickable
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd move all these isClickable styles into it's own block like

...(isClickable && ({
  ...all your clickable styles

border: "1px solid",
borderRadius: "50%",
borderColor:
status === "current"
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as below. Can move these into their own blocks like

...(status === 'current') && ({...

(excludedProps: string[]) => (prop: string) =>
!excludedProps.includes(prop);

export const shouldForwardStepProps = createShouldForwardProp([
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm all for abstraction but, I think we could get away with just using the base createShouldForwardProp inline when creating styled components. Although, I'm unsure about the name in that case. Maybe like... filterExcludedProps?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah that makes sense to me, it could be more explicit that way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants