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

feat(stepper): added stepper component #1500

Merged
merged 6 commits into from
Jan 28, 2025
Merged

feat(stepper): added stepper component #1500

merged 6 commits into from
Jan 28, 2025

Conversation

dprzybylek
Copy link
Contributor

@dprzybylek dprzybylek commented Jan 24, 2025

Resolves: #1496

Description

This pull request introduces a new Stepper component to the react-components package. The changes include the implementation of the component, its styles, tests, and stories for Storybook.

Key changes:

Component Implementation:

Styling:

Storybook:

Testing:

Type Definitions:

Storybook

https://feature-1496--613a8e945a5665003a05113b.chromatic.com

Checklist

Obligatory:

  • Self review (use this as your final check for proposed changes before requesting the review)
  • Add correct label
  • Assign pull request with the correct issue

Summary by CodeRabbit

  • New Features

    • Added a new Stepper component for tracking progress across multiple steps.
    • Implemented visual representation of step status (completed, active).
    • Supports customizable step count and current progress.
  • Documentation

    • Added Storybook stories to showcase Stepper component variations.
    • Included comprehensive unit tests for component functionality.
  • Style

    • Introduced SCSS module with styling for Stepper component.
    • Added dynamic styling for step states and visual progression.

Copy link
Contributor

coderabbitai bot commented Jan 24, 2025

Walkthrough

A new Stepper component has been developed for the React component library, introducing a visual representation of step progression. The implementation includes a TypeScript-based component with SCSS styling, Storybook stories for documentation, and comprehensive unit tests to ensure robust functionality.

Changes

File Change Summary
packages/react-components/src/components/Stepper/Stepper.module.scss Added SCSS styles for Stepper component with base, counter, steps container, and step styling.
packages/react-components/src/components/Stepper/Stepper.stories.tsx Created Storybook stories showcasing Stepper component in various states and sizes.
packages/react-components/src/components/Stepper/Stepper.tsx Implemented React functional component for Stepper with dynamic step rendering.
packages/react-components/src/components/Stepper/index.ts Exported Stepper component and its prop types.
packages/react-components/src/components/Stepper/types.ts Defined StepperProps interface for type-safe component usage.
packages/react-components/src/components/Stepper/Stepper.spec.tsx Added comprehensive unit tests for Stepper component functionality.

Assessment against linked issues

Objective Addressed Explanation
Create simple stepper component
Display number of steps
Show step progress

Suggested labels

High-prio

Suggested reviewers

  • vladko-uxds
  • marcinsawicki

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 28d339d and ebd0ae0.

📒 Files selected for processing (1)
  • packages/react-components/src/components/Stepper/Stepper.module.scss (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/react-components/src/components/Stepper/Stepper.module.scss
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: chromatic-deployment

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (3)
packages/react-components/src/components/Stepper/Stepper.module.scss (3)

1-2: Consider adding a namespace prefix to prevent class name collisions.

-$base-class: 'stepper';
+$base-class: 'ds-stepper';

12-15: Consider mobile responsiveness.

Add media queries to handle overflow on small screens. Consider scrolling or wrapping behavior.

 &__steps__container {
   display: flex;
   flex-flow: row nowrap;
+  overflow-x: auto;
+  -webkit-overflow-scrolling: touch;
+  scrollbar-width: none;
+  &::-webkit-scrollbar {
+    display: none;
+  }
 }

20-21: Use CSS custom properties for step dimensions.

Extract hardcoded values to custom properties for better maintainability.

-    width: 22px;
-    height: 4px;
+    width: var(--stepper-step-width, 22px);
+    height: var(--stepper-step-height, 4px);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between df33d0d and 2618e8a.

📒 Files selected for processing (6)
  • packages/react-components/src/components/Stepper/Stepper.module.scss (1 hunks)
  • packages/react-components/src/components/Stepper/Stepper.stories.tsx (1 hunks)
  • packages/react-components/src/components/Stepper/Stepper.test.tsx (1 hunks)
  • packages/react-components/src/components/Stepper/Stepper.tsx (1 hunks)
  • packages/react-components/src/components/Stepper/index.ts (1 hunks)
  • packages/react-components/src/components/Stepper/types.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/react-components/src/components/Stepper/index.ts
🧰 Additional context used
🪛 GitHub Actions: Tests
packages/react-components/src/components/Stepper/Stepper.test.tsx

[error] 10-10: Test failure: Unable to find element with data-testid='stepper'. The component is rendered but missing the required test ID attribute.

🔇 Additional comments (2)
packages/react-components/src/components/Stepper/types.ts (1)

3-19: Interface looks solid!
Well-defined props with clear docstrings.

packages/react-components/src/components/Stepper/Stepper.stories.tsx (1)

1-60: Great Storybook coverage!
Nicely demonstrates various states and sizes.

Comment on lines 8 to 9
color: var(--content-basic-disabled);
font-weight: var(--font-weight-medium);
Copy link
Contributor

@coderabbitai coderabbitai bot Jan 24, 2025

Choose a reason for hiding this comment

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

💡 Codebase verification

Color contrast ratios are insufficient for accessibility

The disabled text color fails WCAG AA requirements in both themes:

  • Light theme: 3.39:1 (#8d8d95 on white)
  • Dark theme: 3.16:1 (#767680 on #202024)

Minimum required contrast ratio for normal text is 4.5:1.

🔗 Analysis chain

Verify color contrast for counter text.

Ensure that --content-basic-disabled provides sufficient contrast against the background for accessibility.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for the color variable definition
rg --type css "content-basic-disabled" -A 2

Length of output: 10416


Script:

#!/bin/bash
# Search for background color definitions in Stepper component
rg -B 2 -A 2 "background|surface" packages/react-components/src/components/Stepper/Stepper.module.scss

# Also search theme files for default surface colors
rg "surface-primary-default|surface-basic-default" packages/react-components/src/themes/

Length of output: 2032

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Choose a reason for hiding this comment

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

Let's use another one for those step number 1/3...
--Content-Basic-Placeholder

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vladko-uxds changed ✅

@dprzybylek dprzybylek added the feature New feature or request label Jan 24, 2025
@dprzybylek dprzybylek requested review from a team January 24, 2025 11:38
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/react-components/src/components/Stepper/Stepper.spec.tsx (2)

25-30: Custom class functionality
Coverage is good. You could also test multiple custom classes if needed.


42-49: Additional props coverage
Consider adding more props to verify broader attribute consistency.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2618e8a and fe7beda.

📒 Files selected for processing (2)
  • packages/react-components/src/components/Stepper/Stepper.spec.tsx (1 hunks)
  • packages/react-components/src/components/Stepper/Stepper.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/react-components/src/components/Stepper/Stepper.tsx
🔇 Additional comments (3)
packages/react-components/src/components/Stepper/Stepper.spec.tsx (3)

7-13: Test coverage is robust
Thanks for verifying the step count thoroughly.


15-23: Consider edge steps
Include a test when activeStep === steps to check final step class assignment.


32-40: Solid error handling
Your range validation test is well structured.

Comment on lines 8 to 9
color: var(--content-basic-disabled);
font-weight: var(--font-weight-medium);
Copy link
Contributor

Choose a reason for hiding this comment

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

@vladko-uxds vladko-uxds self-requested a review January 24, 2025 12:32
Copy link

@vladko-uxds vladko-uxds left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fe7beda and fab4ad6.

📒 Files selected for processing (5)
  • packages/react-components/src/components/Stepper/Stepper.module.scss (1 hunks)
  • packages/react-components/src/components/Stepper/Stepper.spec.tsx (1 hunks)
  • packages/react-components/src/components/Stepper/Stepper.stories.tsx (1 hunks)
  • packages/react-components/src/components/Stepper/Stepper.tsx (1 hunks)
  • packages/react-components/src/index.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/react-components/src/components/Stepper/Stepper.module.scss
  • packages/react-components/src/components/Stepper/Stepper.spec.tsx
  • packages/react-components/src/components/Stepper/Stepper.stories.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: chromatic-deployment
🔇 Additional comments (2)
packages/react-components/src/index.ts (1)

65-65: Export introduction looks good!
No issues spotted with adding the Stepper export here.

packages/react-components/src/components/Stepper/Stepper.tsx (1)

13-19: Kudos for including a default test ID!
This aligns with previous feedback and ensures tests run smoothly.

Copy link

@vladko-uxds vladko-uxds left a comment

Choose a reason for hiding this comment

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

Change color token for stepper label
--Content-Basic-Placeholder

Comment on lines 8 to 9
color: var(--content-basic-disabled);
font-weight: var(--font-weight-medium);

Choose a reason for hiding this comment

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

Let's use another one for those step number 1/3...
--Content-Basic-Placeholder

Copy link

@vladko-uxds vladko-uxds left a comment

Choose a reason for hiding this comment

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

👍

@dprzybylek dprzybylek merged commit 9e360ac into main Jan 28, 2025
6 checks passed
@dprzybylek dprzybylek deleted the feature/1496 branch January 28, 2025 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[stepper] new component
4 participants