Skip to content

Stepper component #12

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

Merged
merged 7 commits into from
Jul 10, 2025
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
98 changes: 98 additions & 0 deletions components/StepperSimple/StepperSimple.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import React, { useState, useMemo } from 'react';

export const SimpleStepper = ({ children }) => {
const steps = useMemo(() => (Array.isArray(children) ? children : [children]), [children]);
const [currentStep, setCurrentStep] = useState(0);

const containerStyle = {
maxWidth: '600px',
margin: '40px auto',
padding: '20px',
border: '1px solid #ccc',
borderRadius: '8px',
textAlign: 'center',
};

const indicatorContainerStyle = { marginBottom: '20px' };

const indicatorStyle = (active) => ({
display: 'inline-block',
width: '30px',
height: '30px',
lineHeight: '30px',
borderRadius: '50%',
backgroundColor: active ? '#5A3E8B' : '#ddd', // Updated active color for better contrast
color: active ? 'white' : 'black',
margin: '0 5px',
fontWeight: 'bold',
boxShadow: active ? '0px 0px 10px rgba(90, 62, 139, 0.6)' : 'none', // Reflects new active color
transition: 'all 0.3s ease-in-out',
});

const buttonStyle = {
padding: '8px 16px',
margin: '10px',
border: 'none',
borderRadius: '4px',
backgroundColor: '#5A3E8B', // Updated button background for better contrast
color: 'white',
cursor: 'pointer',
};

const handlePrev = () => setCurrentStep((prev) => Math.max(prev - 1, 0));
const handleNext = () => setCurrentStep((prev) => Math.min(prev + 1, steps.length - 1));

return (
<div style={containerStyle}>
<div style={indicatorContainerStyle}>
{steps.map((_, index) => (
<span key={index} style={indicatorStyle(index === currentStep)}>
{index + 1}
</span>
))}
</div>
<div aria-live="polite">
{steps.length > 0 ? <>{steps[currentStep]}</> : <></>}
</div>
<div>
<button
type="button"
style={buttonStyle}
onClick={handlePrev}
disabled={currentStep === 0}
aria-label="Previous Step"
>
Back
</button>
<button
type="button"
style={buttonStyle}
onClick={handleNext}
disabled={currentStep === steps.length - 1}
aria-label="Next Step"
>
Next
</button>
</div>
</div>
);
};

export const SimpleStep = ({ header, children }) => (
<div>
<h2>{header}</h2>
<div>{children}</div>
</div>
);

<SimpleStepper>
<SimpleStep header="Step 1: Plan">
Plan your documentation and gather resources.
</SimpleStep>
<SimpleStep header="Step 2: Write">
Write effective and clear documentation.
</SimpleStep>
<SimpleStep header="Step 3: Review">
Review and refine your content.
</SimpleStep>
</SimpleStepper>
29 changes: 29 additions & 0 deletions components/StepperSimple/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# πŸͺœ Simple Stepper

The **Simple Stepper** component provides basic "Next" and "Back" navigation for stepping through content.

![Stepper](stepper.png)

## ✨ Features

- βœ… **ADA Compliant** – High-contrast colors, keyboard navigation, and screen reader support.
- 🎨 **Customizable** – Easily update colors and styles.
- ⚑ **Lightweight & Fast** – No dependencies, just React hooks.

---

## πŸ“¦ Usage

```mdx
<SimpleStepper>
<SimpleStep header="Step 1: Plan">
Plan your documentation and gather resources.
</SimpleStep>
<SimpleStep header="Step 2: Write">
Write effective and clear documentation.
</SimpleStep>
<SimpleStep header="Step 3: Review">
Review and refine your content.
</SimpleStep>
</SimpleStepper>
```
Binary file added components/StepperSimple/stepper.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.